Jump to content

[SOLVED]Random Orient All 3-Axis?


Atom

Recommended Posts

How can I modify this code to randomly rotate in all axis? Currently it does rotate randomly around the Y axis.

I could make a quat variable for each axis, but how do I combine them into a final @orient?

 

// Randomize rotation.
vector nvec = {0,0,0};
vector axis = {0,1,0};
float rand = 0;
vector4 quat = {0,0,0,1};
vector4 product = {0,0,0,1};

nvec = normalize(axis);
rand = fit01(random(@ptnum),0,360);
quat = quaternion(radians(rand), nvec);
@orient = qmultiply({0,0,0,1}, quat);

 

Edited by Atom
Link to comment
Share on other sites

Ah ha, a one liner thank you!

So if I wanted a different random seed on each axis I could break the vector apart.

float x = rand(@ptnum);
float y = rand(@ptnum+311);
float z = rand(@ptnum-801);
@orient = sample_orientation_uniform(set(x,y,z));

 

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