Vector and GetPerpendicularVector

Vector and GetPerpendicularVector

Anonymous
Not applicable
2,551 Views
4 Replies
Message 1 of 5

Vector and GetPerpendicularVector

Anonymous
Not applicable
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
0 Likes
2,552 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
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
0 Likes
Message 3 of 5

Anonymous
Not applicable
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.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Thank you,
i will try these steps.

--
Roland Feletic
0 Likes
Message 5 of 5

Anonymous
Not applicable
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.
0 Likes