Math for VSFX

Updated on March 1  2024

also Houdini Resources


 Overview (pictoral)


copyright © Deborah R. Fowler




Deborah R. Fowler



Dot Product - Any polygon

Posted Nov 25  2020
updated on Dec 8  2020 adding video links
updated on June 19  2020 adding links to further generalizations

Tags: point wrangle, attribute promote, dot product, acos, normalize, length



"Dot Product
is the product of the magnitudes of the two vectors and the cosine of the angle between them. The name "dot product" is derived from the centered dot\cdot " that is often used to designate this operation."  See wiki entry.



Also on youtube at https://www.youtube.com/watch?v=UqpmteoWF6s


MECHANICS



This project was inspired by two things:
... the method for the circle will not work since there is no tangent to an arbitrary polygon that we can guarantee to hit. Bbox and intersection analysis are out because we do not know where it intersects.

It started off with a simple geometric proof of concept and one line of pointwrangle code:



The key to the solution is to calculate the dot product between the axis (z-axis in this case) and each point of the polygon. Then take the acos to find out the angle and convert it into degrees for use in the hscript expression. I love math!
The point that needs to be used is the maximum angle. A really useful method for doing this in Houdini is to use Attribute Promote and promote the parameter to detail and select the maximum value. Sweet! I love Houdini!




That seemed like an excellent solution to the problem. Done. But ...

After deciding on a model to use (see modeling section below for details) the next step was to figure out how the problem applied if instead of rotating the line corresponding to a line at the bottom part of a box we were rotating around the origin with the box shown below. This is where it becomes similar to the tangent to a circle problem, but again we are going to do this for every point on the polygon.


MECHANICS - line with "thickness"

The above was based on a line and the box is rotating at the bottom point, however most often we want the line to have "thickness". The example below has the box centered as the model I will use.


Now the problem is not just the line crossed with the z-axis as above. We need to focus on the green box rotation. The solution is as given in the point wrangle, with the explanation below




We can generalize this even further by adding the ability to go up and down. See the "Spin" example by cliicking here.


MODELING

I started to think about what kind of example I could create that was not just a line and also tried objects that were 3D. This is where it gets a bit more interesting (and similar to the tangent to the circle).

My inspiration (yes, reference, reference, reference) was from a pieces of lego from my son's toy bin, and some gears I found pictures of online.

Building the parts in a procedural manner made it easier to modify and adopt to the configuration. The "arm" base was a serious of circle arcs, add points, joins and delete spheres. The other parts were relatively straightforward.