Archived

This topic is now archived and is closed to further replies.

Prgmer02

Vector Rotation?? GAH!!

Recommended Posts

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

Share this post


Link to post
Share on other sites
* 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 ]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites