Voronoi in Maya with Qhull


Voronoi diagrams are cool, and it sucks that they aren’t in Maya. I wrote this wrapper around Qhull to create 3d voronoi diagrams. Just select a bunch of locators and run the script.

first you need to download Qhull at www.qhull.org

download my script here

run the script below in a python tab. Replace the directories with the bin’s directory from your Qhull download, and provide another temporary directory to dump the text files that Qhull creates

import dw_qvoronoi
	qhull_dir = r"C:\Users\Danny\Documents\qhull\bin", 
	tmp_dir = r"C:\Users\Danny\Documents\qhull\tmp"

the script will not clean up the temporary directory for safety reasons. I don’t want someone to delete an important directory. So just remember to clean it out each time you use it or add that functionality yourself.

I plan on exploring the Qhull c++ interface at some point to make it much faster. And I’d like to make a slick interface.

Triangulating a Point in Maya

triangulation test

I love applying math in a practical way. Here is a script I created that triangulates the coordinates of a target point based on three reference points and then outputs another target point based on a new set of reference points. An example of when this could be useful is for saving poses on a joint based face rig. If you set up poses on one face you could potentially apply them to other faces of different proportions.

Below is an image of a base space(left side) and a new space(right side). The script triangulates the position of the target (shown as a sphere) in the base space and uses that data to find where the position of the target should be in the new space. The three locators A, B, and C are similar to axis x,y,z, but they can be moved freely around. The script first finds how far along each A,B, and C axis the target is by forming a right angle from the axis to the target. This distance down the axis is the t parameter in the line equation Line = point + t*(Vector). The parameter is then used to find points in the new space’s A, B, and C axis. These points are used to create components in the algorithm. I will refer to these new points simply as point A, B or C. The locators are “reference point” A, B, or C.

tri test debug

There are three components in the algorithm. The A component is a plane equation with a normal of point A – origin. The B component is a ray that is perpendicular to vector formed by point B – origin with a base at point B. The B ray is swept across the A plane creating intersection points. It will stop once it finds a hit. A hit is when the dot product of the vector formed by the intersection point – point C and vector formed by reference point C – point C flips from negative to positive or vice versa.

Its a bit hard to explain, but I’ve included the script and a UI to test it with it!
download it here

in a python tab run:

import dw_triangulate_ui as tui