Hi Sam,

If your three vectors are all perpendicular to each other, you can just
take the dot product of your vector with each of the two vectors on the
plane to get local coordinates, then multiply by a rotation matrix built
from the axes.  Here's the method I use (If I'm starting with two vectors
that aren't perpendicular).

We'll call our first two vectors v1 and v2, and the vector we want to
project vProj. Also, I'm using pseudocode (I've been working in Eigen
lately, so it's probably more similar to that than to pymel, but since I
don't have a interpreter handy, this is the general idea for the math :)

zAxis = v1.cross( v2 ).normalized() # Perpendicular to both original vectors
yAxis = normal.cross( v1 ).normalized() # Perpendicular to the first vector
and the normal
xAxis = v1.normalized()

# Now we can just project against x and y
projectedX = vProj.dot(xAxis)
projectedY = vProj.dot(yAxis)

localProjection= Vector( projectedX, projectedY, 0 )

matrix = [ xAxis[0], xAxis[1], xAxis[2], 0,
               yAxis[0], yAxis[1], yAxis[2], 0,
               zAxis[0], zAxis[1], zAxis[2], 0,
               0,           0,            0,           1 ]

finalProjection = matrix * localProjection


That should get you most of the way :)

On Tue, Mar 22, 2016 at 6:16 AM <[email protected]> wrote:

> Hi there,
>
> i am struggling to understand exactly how this works, but i think i have
> the building blocks for figuring this thing out.
>
> so i have two vectors which effectively represent a plane that i want to
> project a third vector onto.
>
> i have the perpendicular vector using cross product also. Can anyone tell
> me how easy it is to project the third vector onto the plane defined by the
> perpendicular vector.
>
> is there a simple way to do this?
>
> thanks alot for your help,
> Sam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/1dcdb40b-cb07-418c-be8d-9e85da3cad83%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da5oLMLyrejGXXdv83PBPZ1P0qd6ByGwHxAypCSOdukukQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to