#### Archived

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

# Vector Rotation?? GAH!!

This topic is 5752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 on other sites
this is an easy way to do rotation

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

will make your life easier :-D

##### 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.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5
JoeJ
12

• 10
• 9
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632647
• Total Posts
3007639
• ### Who's Online (See full list)

There are no registered users currently online

×