The title may be a bit confusing, so let me put it this way:
I have a polygon strip at a tilted angle, I want to add a curve(in a straight line) that goes through the strip, from start to end, and stays centered in the strip.
I can get the starting point, middle point and endpoint of the strip with the use of these variables:
startPos = polygonStrip.getTranslation() # I've moved the pivot point to be at the base of the strip. This variable is where I want the curve to start.
centerXCoord = pm.objectCenter(polygonStrip,x=True) #this variable gets the center of the strip.
endPos = centerXCoord + (startPos[0]/2) # this variable gets the endpoint. This is where I want the curve to end.
Basically, I want to find a way for all of the curve points to fall between the start and end points evenly so they form a tilted but straight line between them. I've got the Y and Z values working, it's just X that is giving me trouble.
Does anyone have any suggestions? Thank you!
To summarize you have:
With these parameters we can compute points coords along your strip, to do that we will use a very basic math formula :
In the function I made below I added multiple early return to avoid unnecessary calculation. I also a lot of comments so you can follow along what the function is doing.
This is a pure Python function, this means that it work with numpy but also pymel vector (or 3D points).