.NET

.NET

Distinguished Contributor
Posts: 172
Registered: ‎11-19-2003
Message 1 of 5 (242 Views)

Vector and GetPerpendicularVector

242 Views, 4 Replies
11-15-2005 07:42 AM
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
Distinguished Contributor
Posts: 311
Registered: ‎07-29-2004
Message 2 of 5 (242 Views)

Re: Vector and GetPerpendicularVector

11-18-2005 09:17 AM in reply to: RolandF
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
Contributor
Posts: 14
Registered: ‎11-19-2005
Message 3 of 5 (242 Views)

Re: Vector and GetPerpendicularVector

11-19-2005 09:14 PM in reply to: RolandF
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.
Distinguished Contributor
Posts: 172
Registered: ‎11-19-2003
Message 4 of 5 (242 Views)

Re: Vector and GetPerpendicularVector

11-21-2005 12:11 AM in reply to: RolandF
Thank you,
i will try these steps.

--
Roland Feletic
Distinguished Contributor
Posts: 172
Registered: ‎11-19-2003
Message 5 of 5 (242 Views)

Re: Vector and GetPerpendicularVector

11-21-2005 11:17 PM in reply to: RolandF
Thank you , Mick.

--
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.

Recently Solved