Jump to content

Constrain random rotation to 90/180/270 degree


Recommended Posts

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.hiplcFetching info...

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

Edited by ikoon
  • Like 1
Link to comment
Share on other sites

  On 9/14/2020 at 11:19 AM, 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.hiplcFetching info...

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

Expand  

Thats amazing, thank you.

Link to comment
Share on other sites

  On 9/14/2020 at 11:33 AM, 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.hiplcFetching info...

Expand  

much cleaner, thank you :)

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...