{"id":5,"date":"2012-04-15T00:00:46","date_gmt":"2012-04-15T00:00:46","guid":{"rendered":"http:\/\/www.dannywynne.com\/blog\/?p=5"},"modified":"2012-06-06T12:16:12","modified_gmt":"2012-06-06T12:16:12","slug":"test","status":"publish","type":"post","link":"http:\/\/www.dannywynne.com\/blog\/?p=5","title":{"rendered":"Triangulating a Point in Maya"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/dannywynne.com\/images\/tri_test_playblast.gif\" alt=\"triangulation test\" \/><br \/>\n<br \/>\nI 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.<\/p>\n<p>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\u00e2\u20ac\u2122s 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 \u00e2\u20ac\u0153reference point\u00e2\u20ac\u009d A, B, or C.<br \/>\n<br \/>\n<img decoding=\"async\" src=\"http:\/\/dannywynne.com\/images\/tri_test_debug.jpg\" alt=\"tri test debug\" \/><br \/>\n<br \/>\nThere are three components in the algorithm. The A component is a plane equation with a normal of point A &#8211; origin. The B component is a ray that is perpendicular to vector formed by point B &#8211; 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 &#8211; point C and vector formed by reference point C &#8211; point C flips from negative to positive or vice versa. <\/p>\n<p>Its a bit hard to explain, but I\u00e2\u20ac\u2122ve included the script and a UI to test it with it!<br \/>\ndownload it <a href=\"http:\/\/www.dannywynne.com\/scripts\/dw_triangulate.zip\" title=\"download scripts\">here<\/a><\/p>\n<p>in a python tab run:<\/p>\n<p>import dw_triangulate_ui as tui<br \/>\ntui.main()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[3,5],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-maya-scripting","tag-maya","tag-python"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5"}],"version-history":[{"count":0,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.dannywynne.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}