Atom Posted March 5, 2018 Share Posted March 5, 2018 (edited) 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. ap_arrows_align_along_curved_surface.hiplc Edited March 5, 2018 by Atom Quote Link to comment Share on other sites More sharing options...
toadstorm Posted March 5, 2018 Share Posted March 5, 2018 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 Quote Link to comment Share on other sites More sharing options...
Atom Posted March 5, 2018 Author Share Posted March 5, 2018 Thanks Henry, that does it! Now my clouds can have random orientation while floating above the curved surface. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.