.NET

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

Vector and GetPerpendicularVector

278 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
ChrisArps
Posts: 311
Registered: ‎07-29-2004
Message 2 of 5 (278 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
Mick Duprez
Posts: 14
Registered: ‎11-19-2005
Message 3 of 5 (278 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
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 4 of 5 (278 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
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 5 of 5 (278 Views)

Re: Vector and GetPerpendicularVector

11-21-2005 11:17 PM in reply to: RolandF
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.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.