Author Topic: Matrix3d Help.  (Read 2193 times)

0 Members and 1 Guest are viewing this topic.

WOWENS

  • Newt
  • Posts: 59
Matrix3d Help.
« on: July 06, 2012, 12:16:24 PM »
I'm trying to Align the Z Axis with 2 points, that works but I'm 90deg off around the Z Axis any help would be appreciated

Shared Function UCSAlignZaxix(ByVal Point1 As Point3d, ByVal Point2 As Point3d) As Matrix3d

        Try
            Dim ZAxis As Vector3d = Point1.GetVectorTo(Point2).GetNormal
            Dim yAxis As Vector3d = ZAxis.GetPerpendicularVector.GetNormal
            Dim xAxis As Vector3d = yAxis.CrossProduct(ZAxis).GetNormal

            Dim NewMatrix3d As Matrix3d = Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, Point1, xAxis, yAxis, ZAxis)

            Return NewMatrix3d
        Catch
            Return Nothing
        End Try
    End Function

zoltan

  • Guest
Re: Matrix3d Help.
« Reply #1 on: July 06, 2012, 01:36:13 PM »
Would it work better if you determined the X axis first and then arrived at the Y axis from the cross product?

Take a look at this:

http://www.autodesk.com/techpubs/autocad/acadr14/dxf/arbitrary_axis_algorithm_al_u05_c.htm

WOWENS

  • Newt
  • Posts: 59
Re: Matrix3d Help.
« Reply #2 on: July 06, 2012, 02:02:06 PM »
that took care of it, thanks

Dim XAxis As Vector3d = ZAxis.GetPerpendicularVector.GetNormal
Dim YAxis As Vector3d = ZAxis.CrossProduct(XAxis).GetNormal