I have a locator that is on my curve. it has some coordonates - x,y,z . i want to find out the parameter number of that point on my curve ( something like 0.346789 )
SO, if i know the coordinates of a point that is on a curve, how do i select that point on the curve in order to use the pointOnCurve command and get the parameter value of it?
I would be really greatful if anyoane can help me out
thanks!
PS: more detailed situation: ( i have a locator that is a result of the intersection of a curve with another curve. the result of this are some locators. i want to transform the position of one locator in a parameter regarding the (first) curve.)
Basically all this is doing is creating a pointOnCurveInfo node plugging the worldSpace of your curve into it, grabbing the X position of your locator, querying the current world position in X of the pointOnCurveInfo node (which when connected to the curve sits at cv[0] and stepping the parameter until the pointOnCurve info node is pretty much on the locator. Now somethings to be wary of. This script isn't generic. This particular script is querying the X position of the locator, depending on your curve you may need to query the Y or Z (or all 3 would probably be better) Also the while loop, at the moment I have it set as while the $currentPosX (the world space x position of the pointOnCurveInfo node) is greater than $targetPosX (the world space x position of the locator) Now its set like that because of the way I build my curve, it started in positive X and finished in negative. So you will have to adjust that aswell. Now theres two reasons why I said this isnt exactly precise. First is, if your curve ever does a fancy S bend and say loops back on itself, it will stop as soon as the X is met, meaning is could stop far before it actually reaches the locator, which is why more than one axis would be better. Also xforming the worldspace of anything can return a large floating point number, the parameter on the pointOnCurveInfo only allows you to adjust a 4 digit floating point. So it will never be spot on the money. Close, but not exactly.
Now that will give you the parameter of the curve, but what exactly are you trying to do with the second locator? haha.
:EDIT: Turns out you can plug a parameter of 0.000001 through anyway. With a small increment like that you could probably get away with ($currentPosX != $targetPosX). Just be prepared to crash maya a few times before you get it right. Oh and ofcourse with a small increment also comes the time factor i just tried it returned an exact position and a nicely detailed parameter but it took a good minute and a half to do it.