functorial
functorial

Reputation: 687

Make a set of 3D points rotate around a point

What is the formula for calculating the position of 3D point after it has been rotated around another 3D point a certain radians/degrees? I am using Java / LWLJGL.

Could someone just fill in the blanks in the following?
public Vector3f rotate(Vector3f origin, Vector3f rotation)
{
Vector3f ret = new Vector3f();
ret.x = __________;
ret.y = __________;
ret.z = __________;
}

Upvotes: 0

Views: 938

Answers (1)

Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35547

Consider your fixed point has coordinates (a,b,c) and moving object (x1,y1,z1) at time t1 and at (x2,y2,z2) at time t2.

option 1 you can consider projection on x-yplane and projection on y-z plane and calculate angle in that 2D space.

option 2 you can consider two vectors. say vector A and B

A=(x1-a)i+(y1-b)j+(z1-c)k 
B=(x2-a)i+(y2-b)j+(z2-c)k 

Now use dot product of A and B

 A . B = |A||B|cos(angle)

Upvotes: 1

Related Questions