kiryha Posted October 15, 2019 Share Posted October 15, 2019 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? Quote Link to comment Share on other sites More sharing options...
kiryha Posted October 15, 2019 Author Share Posted October 15, 2019 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? 1 Quote Link to comment Share on other sites More sharing options...
fsimerey Posted October 15, 2019 Share Posted October 15, 2019 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) 1 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted October 18, 2019 Share Posted October 18, 2019 its a bit more readable like this. @P -= pivot; @P *= matrix; @P += pivot; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.