Jump to content

[SOLVED]Modify Rotation Of Aligned Copies?


Atom

Recommended Posts

I kind of have an orientation conundrum. The red arrows are aligned correctly along the curve and move along it's surface. They're alignment is to the surface normal. The blue arrows are randomly rotated along the Y-axis via VEX @orient equation. But the blue arrows no longer align to the surface the way the red arrows do. They are kind of acting like escalator steps. Basically I want to randomly rotate the red arrows along the Y-axis. How can I mix these two orientations together so the arrows follow the surface orientation but also have a random Y-axis alignment? Here is my current blue arrow orientation code.

// 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);

Basically I want to randomly rotate the red arrows along the Y-axis so they point in random directions but still conform to the surface.

untitled-1.jpg

ap_arrows_align_along_curved_surface.hiplc

Edited by Atom
Link to comment
Share on other sites

I inserted two nodes here.

The first is to create a stable p@orient attribute on your plane, before it starts animating. The scattered points inherit this orientation. It's just based on the maketransform() function, using the existing @N and an arbitrary up vector (+X in this case).

The second is to use the quaternion() function to create a second quaternion from an axis and angle. The axis you want to rotate around is @N, and the angle is any random angle between -PI and PI radians, which corresponds to -180 and 180 degrees. The qmultiply() function then adds this rotation to the existing orientation. The great thing about quaternions here is that you can take any axis and angle, make a quaternion out of it, then qmultiply that against your existing rotation, and you'll get a combined rotation back.

ap_arrows_align_along_curved_surface_fixed.hiplc

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