Vector Rotation?? GAH!!

Started by
2 comments, last by Prgmer02 21 years, 4 months ago
Ok math geeks, i need some help! I need to know how to rotate a vector around a given point given: a point to rotate about and an angle (radians or degrees, it doesnt matter to me) -> create a second vector to represent the rotation This is what ive gotten so far. (note: I SUCK AT MATH) D3DXVECTOR3 RotateVector(D3DXVECTOR3 v, D3DXVECTOR3 point, float angle) { D3DXVECTOR3 ret; ret.x = distance(point, v)*(cos(angle)*(-1/cos(angle))); ret.y = distance(point, v)*(sin(angle)*(-1/sin(angle))); ret.z = distance(point, v)* ??????; return ret; } Thanks for the help! Am i asking the impossible? OR am i just way off :-(? Rob
Advertisement
* You did not provide enough information to determine a 3D axis of rotation. You cannot "rotate about a point" unless you are working in a plane. In 3D, you rotate about an axis, defined by a point and a vector.

* Mathematically, vectors (unlike points) are invariant by translation, therefore all vector rotations are centered at (0,0,0).

* cos(angle)*(-1/cos(angle)) is always equal to 1. Idem with sin().

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
this is an easy way to do rotation

D3DXMatrixRotationX(... , ...);
D3DXMatrixRotationY(... , ...);
D3DXMatrixRotationZ(... , ...);

will make your life easier :-D
Nothing to do, try complimenting someone, it will make you feel better!
he wants to take a point in space, and rotate another point around it. so if you called his function like this:

Rotate(0, 0, 0, 1, 1, 1, 45, 45, 45)

it would rotate 1, 1,1 around 0, 0, 0, by 45 degrees in each axis. but i''m not sure how to do it.

This topic is closed to new replies.

Advertisement