Jump to content

Math noob - rotation formulas


art3mis

Recommended Posts

Hi

Trying to implement several of these rotation formulas with simple geometry

https://sites.google.com/site/fujitarium/technical-note/basic-math/rotation

for instance the first example

 

Quote

 

  • add rotation X (x, y*cos(rx) + z*sin(rx), y*-sin(rx) + z*cos(rx))

(x, y*cos(rx) + z*sin(Rx), y*-sin(rx) + z*cos(rx))

 

 

x = x

y = y*cos(rx) + z*sin(Rx)

z = y*-sin(rx) + z*cos(rx)

 

How would you implement this as Vex within a Point Wrangle?

Edited by art3mis
Link to comment
Share on other sites

Hi, 

While rotating an object, we are essentially changing the position of the points of the Geo. 

 

So, the above mentioned formula changes the point position along y and z axis but not x axis. To implement it in a point wrangle, just drop in a test object on to the grid followed by a point wrangle and enter the following code in the wrangle :

float angleX = ch("xRad");
float posY = @P.y*cos(angleX) + @P.z*sin(angleX);
float posZ = @P.y*(-sin(angleX)) + @P.z*cos(angleX);
@P = set(@P.x, posY, posZ);

Change the "xRad" parameter, the object "appears" to be rotating along the X-Axis, but in reality, it is just changing the point positions along Y and Z axis.

Hope it helps!

S

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...