Hey guys,
I am writing a script that takes two triangles (as separate objects and aligns the pivot and rotation to an edge. Kinda like this:
_2
/_\ /
1
So basically it was like the triangles were one shape and the faces were detached. The flow of the script is the following:
a) Gets the pivot from triangle 1
b) Gets center of each edge of triangle 2
c) Compares them to see which edge is closer
d) Places a locator on a vertex of the closes edge
e) Creates a null and aimconstrain it to the locator
f) Parents triangle 2 to this new group
g) Freezes tranforms on triangle 2
In the paper looks ok, but its kind of working 50-50. It does the right thing 50% of the times. When it goes wrong, it is slightly off about 20 degrees. and even, if I manually create a group and aim it to the locator created, still is wrong on some cases. any clues?
By the way, i even tried a non constrain solution: I discovered the euler angles comparing the edge vector to 1 0 0 (axis). and the applied the transforms to a null group with the same pivot position as the edge. STILL it gives me wrong results.
Am I doing the worng procedures? Is there another approach to it? thanks, and happy new year!
Daniel Moreno
www.danmoreno.com