Re: Rotated objects.
I can give you the math if you want to calculate the angle by pencil and paper:
- Align each axis one at a time. You'll want to repeat this procedure for each axis until aligned.
- For convenience, select an edge that's already nearly aligned with the axis you want to align to. Write down the position of the two end vertices.
- Create a vector by subtracting the first vertex from the second.
- Normalize your vector making it a unit vector. You can do this by first calculating the magnitude of the vector using Pythagoras: square root of x^2 + y^2 + z^2. Then, divide the x, y, and z components of your vector by the magnitude.
- Calculate the dot product (inner product) of your normalized vector and the axis you want to align to.
- Take the arc cosine of your dot product. This is the angle, in radians, you want to rotate by.
Just curious, though... why do you need it so precise? I'd think you could get it pretty close just by eyeballing it, then square up the corners after you rotate. (I assume you're doing something more tricky than that!)
|