Jump to content
kiryha

Rotation matrix pivot point

Recommended Posts

The rotation of each point occurs around the origin:

matrix3 matrx = ident();
vector axis = {1, 0, 0};
float angle = 256;

rotate ( matrx, angle, axis); 
@P *= matrx; 

How to define coordinates for rotation different from the origin?

Share this post


Link to post
Share on other sites

I found the answer:

matrix3 matrx = ident();
vector axis = {1, 0, 0};
float angle = 256;

rotate ( matrx, angle, axis);

vector pivot = {0, 0.8, 0};
@P = (@P - pivot) * matrx + pivot;

 But I can`t understand how it`s working, why this line `(@P - pivot) * matrx + pivot` puts pivot of rotation to a required point?

Share this post


Link to post
Share on other sites

It's like you translate the points at origin with pivot as center (@P - pivot), then rotate (* matrix) and replace at the pivot position (+ pivot)

  • Like 1

Share this post


Link to post
Share on other sites

its a bit more readable like this.

@P -= pivot;
@P *= matrix;
@P += pivot;

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×