How to rotate on scattered geos on Y axis (@N with @up ??)

   152   3   0
User Avatar
Member
294 posts
Joined: April 2017
Offline
Hi!

I'm scattering a bunch of trees. All the points have a normal pointing upward. Now I would like each tree to randomly rotate around the Y axis.

I thought the @up was for that but I read that it is a vector, not a float… I'm confused.

Any help is apreciated!

-Olivier

Attachments:
rotate_around_y.JPG (147.0 KB)

User Avatar
Member
15 posts
Joined: April 2017
Offline
Long version: A Long-Winded Guide to Houdini Instancing [www.toadstorm.com]

Basically any orientation of a copy is determined by a 3x3 transform matrix. Imagine a little gnomon for each of those copies. The matrix is three vectors that describe which way is “up”, which is “front” and which is “side”. To build this matrix you need at least two vectors, from which you can compute the third using the cross product. This is why N and up are both vectors, and both required to get a steady orientation. If “N” is pointing straight up, then your “up” vector would need to be pointing anywhere along the XZ plane to get random rotation around the “N” vector.

If you want the easy answer, I'll just toot my own horn here and recommend MOPs [www.motionoperators.com]. The MOPs Instancer and MOPs Randomize SOPs will get you this effect a little more intuitively.
User Avatar
Member
1843 posts
Joined: Sept. 2011
Online
If you are lazy like me, you can use an orient attribute to align them and attribute randomize to pick the angle.

Attribute randomize:
name: theta
distribution: Uniform
dimensions: 1
min value: 0.0
max value: 1.0

Then use an attribute wrangle to create a quaternion:

float u = @theta * M_PI;
@orient = set(0, sin(u), 0, cos(u));

or if Eulers with degrees are more your thing:
vector rot = set(0, 360*@theta, 0);
@orient = eulertoquaternion(radians(rot), 0);
User Avatar
Member
294 posts
Joined: April 2017
Offline
My point @N were already pointing up. All I needed was to make that last rotation. I multiplied my random value (fitrand) from 0 to 6.28. I used that in a quaternion function.


float fitrand = rand(@ptnum)*6.2831;

@orient = quaternion(fitrand, @N);


-Olivier
  • Quick Links