faultymoose
10-02-2006, 11:57 PM
Hi all!
I thought it might be of some help to us floundering mayafish if we could start a thread dedicated to providing some formulae, tricks and shortcuts for calculating various 3D trigonometric conditions! I know that it can be frustrating relying on google for this kind of information, especially for people like me who aren't mathematical experts, and who often don't quite now what it is we're looking for!
I hope there are others out there who would find a Vector Mathematics / Trigonometry Cheat Sheet of some use! To all the human supercomputers out there, please jump on board and share some of your repository of number art! Feel free to post tips and tricks, or provide easier solutions to problems listed here-in (corrections, too if required!).
I don't know about anyone else, but I'd also appreciate the 'long' solutions alongside the Maya inbuilt functions, if possible!
P.S. If a thread of this nature already exists, please forgive me and point me in the right direction ;)
My first contribution:
Calculate the center point <x,y,z> of n coordinates.
// Pseudo-code: Calculate the center point <x,y,z> of n coordinates.
// < x, y, z > = < ((x[1] + x[2]... + x[n]) / n), ((y[1] + y[2]... + y[n]) / n), ((z[1] + z[2]... + z[n]) / n) >
// EXAMPLE:
// Calculate the center of polygon triangle "polyTri"
// Populate arrays pntA, pntB and pntC with vertex x,y,z coords
$pntA = `xform -q -ws -t polyTri.vtx[0]`;
$pntB = `xform -q -ws -t polyTri.vtx[1]`;
$pntC = `xform -q -ws -t polyTri.vtx[2]`;
// Calculate the center of the three points
$cntX = ($pntA[0] + $pntB[0] + $pntC[0]) / 3;
$cntY = ($pntA[1] + $pntB[1] + $pntC[1]) / 3;
$cntZ = ($pntA[2] + $pntB[2] + $pntC[2]) / 3;
// Create locator at center point
spaceLocator -p $cntX $cntY $cntZ;
I thought it might be of some help to us floundering mayafish if we could start a thread dedicated to providing some formulae, tricks and shortcuts for calculating various 3D trigonometric conditions! I know that it can be frustrating relying on google for this kind of information, especially for people like me who aren't mathematical experts, and who often don't quite now what it is we're looking for!
I hope there are others out there who would find a Vector Mathematics / Trigonometry Cheat Sheet of some use! To all the human supercomputers out there, please jump on board and share some of your repository of number art! Feel free to post tips and tricks, or provide easier solutions to problems listed here-in (corrections, too if required!).
I don't know about anyone else, but I'd also appreciate the 'long' solutions alongside the Maya inbuilt functions, if possible!
P.S. If a thread of this nature already exists, please forgive me and point me in the right direction ;)
My first contribution:
Calculate the center point <x,y,z> of n coordinates.
// Pseudo-code: Calculate the center point <x,y,z> of n coordinates.
// < x, y, z > = < ((x[1] + x[2]... + x[n]) / n), ((y[1] + y[2]... + y[n]) / n), ((z[1] + z[2]... + z[n]) / n) >
// EXAMPLE:
// Calculate the center of polygon triangle "polyTri"
// Populate arrays pntA, pntB and pntC with vertex x,y,z coords
$pntA = `xform -q -ws -t polyTri.vtx[0]`;
$pntB = `xform -q -ws -t polyTri.vtx[1]`;
$pntC = `xform -q -ws -t polyTri.vtx[2]`;
// Calculate the center of the three points
$cntX = ($pntA[0] + $pntB[0] + $pntC[0]) / 3;
$cntY = ($pntA[1] + $pntB[1] + $pntC[1]) / 3;
$cntZ = ($pntA[2] + $pntB[2] + $pntC[2]) / 3;
// Create locator at center point
spaceLocator -p $cntX $cntY $cntZ;
