Normalize node?

   5928   3   1
User Avatar
Member
267 posts
Joined: July 2013
Offline
Hello,

I am finding it difficult to understand what the normalize node does. Could someone explain?

In particular, I saw a tutorial in which cubes are scattered on a grid using copytopoints node and the cubes are then rotated randomly by using an Attribute VOP.

In the VOP, a normalize node is connected to a 3D noise node (used to randomize position) to normalize the “vector” from the noise so it can be connected to a rotate node to rotate the cubes on an axis. What is the normalize node actually doing (converting) so the rotate node can use its value?

Thanks
User Avatar
Member
38 posts
Joined: July 2019
Offline
If you were to, for example, move some points along their normals by a fixed amount, but the normals were not all of the same length, some points would move more than others. The normalize node (or function in vex), will return a vector in the same direction as the input but with a length of one.

So in a wrangle you might write:
float distanceAlongNormal = 0.7;
@N = normalize(@N);
@P += @N * distanceAlongNormal;

Then you can be sure the points move exactly 0.7 units away from their starting position.

Of course there are lots of other instances when you need to make a vector unit length.

The rotate function (or node), will apply a rotation in radians about an axis. It requires this axis to be normalized to work.
User Avatar
Member
267 posts
Joined: July 2013
Offline
Hello,

Thanks, yes I did discover the basic definition of normalizing a vector, but my question is what are these nodes I mentioned doing? My best guess is the noise node is creating a vector for each point/box (random direction) which then needs to be normalized for it to be possible to feed in the rotate node (I get lost here). The rotate node then sets an axis of rotation and the quaternion node performs the actual rotation. Is this remotely correct?
User Avatar
Member
38 posts
Joined: July 2019
Offline
You are correct, the 3d noise outputs a vector. By normalizing this you are only concerned with the direction.
The rotate node creates a rotation matrix. If you are using a matrix3 to quaternion, you are converting this matrix to a quaternion, it is not creating the rotation. You would bind this quaternion to the @orient attribute to be used by the copy to points.

The reason to use a quaternion is that it contains the complete information to orient the boxes (as does the rotation Matrix, but these are memory inefficient).

You can also use the normal attribute with copy to points.
You can see in my example images I have done this. The problem is that the copy to points node doesn't know how the box should be rotated around the axis. To fix this you can also provide an ‘up’ vector attribute so that the copy to points node can resolve this.

In my first example, the up vector is set to {0, 0, 1}.
In the second it is set to {0, 1, 0}.

Edit: the vectors were in the wrong order for the images. First is with {0, 0, 1}, second with {0, 1, 0}.

You can see that although both are oriented along the normal, they are rotated differently about this normal.
Edited by FDX3245 - Dec. 22, 2019 03:06:01

Attachments:
Screenshot from 2019-12-22 17-09-23.png (382.1 KB)
Screenshot from 2019-12-22 17-09-39.png (355.9 KB)

  • Quick Links