The Cross product: Examples (2/3) - orienting objects on another surface.

Опубликовано: 02 Апрель 2026
на канале: Peter Claes
3,784
121

PART 1: Understanding how the cross product works.
   • The Cross product: Theory (1/3)  

PART 2: Examples of how the cross product can help you better orient objects (this video).

PART 3: Example of how the cross product can create custom directions for forces.
   • The Cross product: Examples (3/3) - creati...  

Add me on Instagram: pclaesvfx

Hipfile: http://bit.ly/cross_product_hipfile

Cross product wikipedia: http://bit.ly/WikiCross
Cross product on Khan Academy: http://bit.ly/KhanCross

Related: Dot product video & radians/degrees explanation
   • Understanding the DOT product!  

FIRST: Example of scattering objects onto other objects.
Scattering the pigs head test geometry on a grid. Scatter 20 points on a grid and copy the pigs head to the scattered points. With an 'attribute randomize' we can modify the N (direction) so the pigs heads are pointing in random directions. The problem is that some pigs heads are upside down. Ideally we want to rotate them in relation to the surface normal.
By default the pigs head is pointing in the z-axis which will align the pigs head by the N (normal).

SECOND: creating a custom direction vector.
Inside of an attribute vop on the template points we create an initial direction vector (0,0,1). Next we will create a rotation matrix and apply it to the initial direction vector to rotate the direction vector. We specify an angle in degrees, which get converted to radians which is what the rotate vop requires (see dot product video for more info on radians and degrees). We use the y-axis (0,1,0) as our axis of rotation. When we manipulate the angle slider, the outgoing Normal is rotating.

THIRD: Calculating random tangent vectors.
Cross the random vector against the surface normal, currently represented by the y-axis. This outputs random vectors that are tangential to the surface. Next we hook up the rotation matrix, where the surface normal is used for the axis of the rotation and the normalized result of the cross product as the axis to apply the rotation matrix to.

FOURTH: visualizing the local coordinate systems.
We add an 'up' attribute and a 'cross' attribute so we can visualize the local coordinate system of the points in the viewport. We start with a Normal going into a random direction, then we have the y-up vector and the angle between the two can be bigger or smaller than 90 degrees. As long as the vectors are not lying on top of each other, they can still define a plane. The normal of this plane is the perpendicular vector which is the cross product, which is tangential to the surface of the object. This also works for objects with complex 3d topology.

FIFTH: Creating the local coordinate vectors for the scattered points on a sphere.
We create a new sphere and compute the normal, the scattered points will inherit the normals that are computed on the sphere. On the atribrandomize we can rename the newly generated random normal to 'N_rand'. Inside of the attribvop we bring in the 'N_rand' with a bind vop, then we cross it against the incoming normal (which represents the surface normal).

SIXTH: Visualizing the vectors in the viewport.
Hover over the attribrandomize sop, press the 'i' to bring up information on the node and then click on the underlined 'N_rand' attribute to create a new visualizer in the viewport. Next we edit the visualizer so that instead of a color it is displayed as a marker and the style is 'Vector'. Next we can see the planes/triangles defined by both the 'N' and the 'N_rand'.

SEVENTH: Fixing the rotation.
Inside of the attribute vop where we compute the cross vector, we need to update the axis of rotation. So instead of using the (0,1,0) for the axis of rotation, we can use the surface normal which comes in through 'N'. The incoming surface normal will also be plugged into the 'up' bind export.

EIGHT: resulting copies oriented correctly.
Pigsheads are nicely aligned with the surface. We are also able to rotate them around the surface normals.

In the next section we will build a custom velocity field using the cross product vectors:
   • The Cross product: Examples (3/3) - creati...  

For business or one-on-one visual effects consulting inquiries, you can reach me at [email protected]