Jump to content
plazadelmar

Constrain random rotation to 90/180/270 degree

Recommended Posts

I copy the small grids to each point of the grid template and now I would like to rotate them in randomly so they snap to 90/180 and 270-degree intervals in Y-axis. Is there an easy way to solve it in VEX or with VOPS?

 

 

Screenshot_1.jpg

Share this post


Link to post
Share on other sites

Hi Dominic,
here is one possible way. File is attached.

@zero_to_three = floor( 4 * rand(@ptnum));

float   angle =  @zero_to_three * radians( 90 );
vector  axis  = {0,1,0};
matrix3 m     = ident();
rotate(m, angle, axis);

@up = {0,1,0};
@N  = m * {0,0,1};

0-270.hiplc

0-270.thumb.PNG.1ea9716dadc391c64ab8d148f62abe97.PNG

Edited by ikoon
  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, ikoon said:

Hi Dominic,
here is one possible way. File is attached.


@zero_to_three = floor( 4 * rand(@ptnum));

float   angle =  @zero_to_three * radians( 90 );  // 45 in 0 to 90
vector  axis  = {0,1,0};
matrix3 m     = ident();
rotate(m, angle, axis);

@N = m * {0,0,1};

0-270.hiplc

0-270.thumb.PNG.1ea9716dadc391c64ab8d148f62abe97.PNG

Thats amazing, thank you.

Share this post


Link to post
Share on other sites

Here is the same result, but orientation is set by the @orient attribute:

@zero_to_three = floor( 4 * rand(@ptnum));

float   angle =  @zero_to_three * radians( 90 );
vector  axis  = {0,1,0};

@orient = quaternion(angle,axis);

 

 

quaternion.PNG

quaternion.hiplc

  • Like 3

Share this post


Link to post
Share on other sites
13 minutes ago, ikoon said:

Here is the same result, but orientation is set by the @orient attribute:


@zero_to_three = floor( 4 * rand(@ptnum));

float   angle =  @zero_to_three * radians( 90 );
vector  axis  = {0,1,0};

@orient = quaternion(angle,axis);

 

 

quaternion.PNG

quaternion.hiplc

much cleaner, thank you :)

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

×