.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vector and GetPerpendicularVector

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
2063 Views, 4 Replies

Vector and GetPerpendicularVector

Hallo,
i have two vectors, xAxis and yAxis. If yAxis is not perpendicular to xAxis
how do i make it perpendicular? I can get the perpendicular vector of the
xAxis with xAxis.GetPerpendicularVector, but i want to leave the plane the
original Vectors describe.
Does anyone know how to do this?

--
Roland Feletic
4 REPLIES 4
Message 2 of 5
ChrisArps
in reply to: Anonymous

GetPerpendicularVector is only worth something in 2d as there are an infinite number of perpendiculars to a 3d vector.
A bit of a roundabout but this works.

Dim org As New Point3d(0, 0, 0)
Dim xAxis3d As New Vector3d(1, 0, 0)
Dim v3d As New Vector3d(1, 1, 1)

Dim p As New Plane(org, xAxis3d, v3d)
Dim xAxis2d As Vector2d = xAxis3d.Convert2d(p)
Dim yAxis2d As Vector2d = xAxis2d.GetPerpendicularVector()

Dim m As Matrix3d = Matrix3d.PlaneToWorld(p)
Dim yAxis3d As New Vector3d(yAxis2d.X, yAxis2d.Y, 0)
yAxis3d = yAxis3d.TransformBy(m)

Chris Arps
Message 3 of 5
Mick Duprez
in reply to: Anonymous

Hi Roland,
you can get the y axis by using something like

yAxis = plane.Normal.CrossProduct(xAxis.Normal).GetNormal(Tolerance.Global);

This should give you a normalised vector perp to the xaxis that remains in the original plane.

Cheers,
Mick.

Message was edited by: Mick Duprez Message was edited by: Mick Duprez to adjust code to correct coordinate system handing.
Message 4 of 5
Anonymous
in reply to: Anonymous

Thank you,
i will try these steps.

--
Roland Feletic
Message 5 of 5
Anonymous
in reply to: Anonymous

Thank you , Mick.
your solution is great 😉

--
Roland Feletic

schrieb im Newsbeitrag news:5018479@discussion.autodesk.com...
Hi Roland,
you can get the y axis by using something like

yAxis = plane.Normal.CrossProduct(xAxis.Normal).GetNormal(Tolerance.Global);

This should give you a normalised vector perp to the xaxis that remains in
the original plane.

Cheers,
Mick.

Message was edited by: Mick Duprez

Message was edited by: Mick Duprez to adjust code to correct coordinate
system handing.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost