The Cross product: Theory (1/3)

PART 1: Understanding how the cross product works (this video). PART 2: Examples of how the cross product can help you better orient objects.    • The Cross product: Examples (2/3) - orient...   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: Geometric definition of the cross product. Geometric definition of the dot product: a x b = |a| . |b| . sin(theta) . n Where n is a unit vector perpendicular to the plane containing a and b in the direction given by the right-hand rule. The dot product has two vectors as an input and a single float as an output. The cross product on the other hand takes in two vectors as an input and a vector as an output. They are computed in a different way. SECOND: Demo in Houdini. Inside of Houdini we have a N (normal) and an up vector, the cross product is going to be the result from the computation of the two incoming vectors. We create a single point and add a N attribute (0,0,1) and an up attribute (0,1,0). Inside of an attribute vop, we can take the normalized up vector and the normalized N and plug them into a cross product vop to get a resulting cross product vector. We normalize the result and output it in a cross attribute that we visualize in the viewport. THIRD: The right hand rule. The right hand rule defines the relationship between the two vectors and the direction of the cross vector. Notice that it is the 'right' hand and not the 'left' hand. The thumb is going to represent the first vector (the up vector), the index finger is going to represent the second vector (the Normal), the middle finger is going to represent the resulting direction of the cross product (the cross vector). The order of operations is important. If you input the N first and then the up vector, then the resulting cross vector will be flipped. FOURTH: Second demo example. The normal and the up vector lie on the unit circle. Together they can define a parallelogram. We can compute both the area of the parallelogram as well as the length of the cross product vector. As we move forward in the timeline, and the up vector starts to trace along the unit circle, the shape of the square changes into a parallelogram. Also the resulting cross vector is changing in length and direction. The area calculation of the parallelogram is the length of a times the length of b times the sin of theta: area of parallelogram = |a| . |b| . sin(theta) FIFTH: building the various line segments. The Normal line segment lies on the (0,0,1) axis. The up segment traces a circle defined by the sin($FF*5) in the y-axis and cos($FF*5) in the z-axis. Showing how to normalize the line segment that represent the up vector. Next we compute the cross product. SIXTH: computing the cross product. We compute the cross product inside an attribute vop. We can use a 'get attribute' to grab the positions of the end points (that represent the incoming normals) of both the 'normal' segment and the 'up' segment. We compute the cross product with a 'cross product' vop and output it into a 'cross' vector attribute. SEVENTH: Compute the length of the cross vector. After computing the cross vector we compute the length of the cross vector and convert it into a rounded string. EIGHT: Building the cross line segment. We add a point at the origin, then bring in the computation of the cross product and move the point to the cross value (displacing it by the cross vector). Together the two points form the cross line segment. We can create the line segment that connects the incoming points. A measure sop can then be used to measure the perimeter of the line segment so that we can later on compare it against the area size of the parallelogram. NINTH: Creating the parallelogram. We displace the N vector line segment in the direction of the up vector line segment and get a displaced N line segment. We use a skin sop to build a new polygon between the N line segment and the displaced N line segment. Next we can measure the area size of the resulting primitive. As the parallelogram updates, the area size updates with it. TENTH: Building the symbols for perpendicular behavior. We create 'L-shaped' segments between the various segments using the carve sop to create sub-segments and displacing the sub-segments in the direction of the cross product vector. ELEVENTH: Create the annotations for the length and area. Inside of a font sop we use the 'points' expression to reference the rounded length of the cross produce and the 'prims' expression to reference the rounded area size of the parallelogram. For business or one-on-one visual effects consulting inquiries, you can reach me at [email protected]