Normalized position of a point on a quadrilateral


I’m running into a problem that I have no clue about how to solve.

I’m drawing a quadrilateral with coordinates [x,y,z] for the 4 points with a scriptSOP and I would like to get the normalized position of a point on this quadrilateral, given that I know its coordinates within the system.

I thought I could find an easy formula to solve that, but I have to say it’s more complicated than what I expected and far behond my math level…
I have no clue how to “translate” this or this in a python script…

Any math guru around or would there be some SOP trick that I don’t know to get this result


Ok in the end I did 4 range between the points 2 by 2 and I’m interpolating between the different scales with crossChop depending on the position.
Not the most elegant way, but it’s kind of doing the job!

If anybody see this post and has something better to offer, I’m still interested for knowledge purposes :slight_smile:

Hey @flashbacker,

are you looking for a perspective or bilinear mapping? The easiest way to solve this is via hymnographies - or basically figuring out the transform matrix that converts between a unit square and your 4 point positions.
A component that does this is the cornerPinSOP in the Mapping palette folder. We could add a function for it to return a normalized coordinate given a point in the deformed square.
A similar thing is also done in Kantan, but it’s a bit deep in there.


Thanks Markus,

I think what I need is a perspective mapping.
I looked a bit into the code of the scriptSOP inside the cornerPinSOP, and I guess what I would need is to reverse the transformation which is applied to the grid and shift it to (0,1) instead of (-1,1) to get my point normalized coordinates…
But once again my rusty math makes my brain going into an infinite loop :sweat_smile: