60000577 Change the Viewing direction using azimouth tilt and twist angles.

Article 60000577
Type Wish
Product Engine
Version 6012
Date Added 7/14/2008 12:00:00 AM
Fixed (7/14/2008 12:00:00 AM)
Submitted by Marc Seguin

Summary

Change the Viewing direction using azimouth tilt  and twist angles.

Solution



In Version 6013 new methods was added in VectorDraw.Geometry.Matrix  object


 


        /// <summary>
        /// Modify this Matrix using the view direction vector.
        /// </summary>
        /// <param name="Direction">A Vector defines the camera point offset from the target point.</param>
        /// <param name="twist">Rotation of the created matrix from Direction , about Z in radians in clockwise direction.</param>
        void SetToViewDirection(Vector Direction, double twist);
        /// <summary>
        /// Modify this Matrix using azimouth, tilt  and twist angles that specify the view direction relative to World Coordinate System.
        /// </summary>
        /// <param name="azimouth">Watching angle on XY plane relative to X axis in radians in clockwise direction.</param>
        /// <param name="tilt">Vertical watching angle relative to XY plane in radians.</param>
        /// <param name="twist">Rotation of the created matrix from azimouth and tilt , about Z in radians in clockwise direction.</param>
        void SetToViewAngles(double azimouth, double tilt, double twist);
        /// <summary>
        /// Returns the View Direction and the Angles that define this Matrix.
        /// </summary>
        /// <param name="direction">A Vector defines the camera point offset from the target point.</param>
        /// <param name="azimouth">Watching angle on XY plane relative to X axis in radians in clockwise direction.</param>
        /// <param name="tilt">Vertical watching angle relative to XY plane in radians.</param>
        /// <param name="twist">Rotation of the created matrix from azimouth and tilt , about Z in radians in clockwise direction.</param>
        void GetWorldToViewProperties(out Vector direction, out double azimouth, out double tilt, out double twist);



Example in C#



                ////defining the viewing direction using azimouth tilt  and twist angles.
                vdFramedControl.BaseControl.ActiveDocument.Prompt("azimouth,tilt,twist in Degrees:");
                gPoint pt = vdFramedControl.BaseControl.ActiveDocument.ActionUtility.getUserPoint() as gPoint;
                vdFramedControl.BaseControl.ActiveDocument.Prompt(null);
                if (pt == null) return;
                double azimouth = pt.x;
                double tilt = pt.y;
                double twist = pt.z;
                Vector v;
                Matrix mm = new Matrix();
                mm.SetToViewAngles(Globals.DegreesToRadians(azimouth), Globals.DegreesToRadians(tilt), Globals.DegreesToRadians(twist));
                vdFramedControl.BaseControl.ActiveDocument.World2ViewMatrix = mm;
                vdFramedControl.BaseControl.ActiveDocument.Redraw(true);



                //Verify te values.
                vdFramedControl.BaseControl.ActiveDocument.World2ViewMatrix.GetWorldToViewProperties(out v, out azimouth, out tilt, out twist);
                twist = Globals.RadiansToDegrees(twist);
                tilt = Globals.RadiansToDegrees(tilt);
                azimouth = Globals.RadiansToDegrees(azimouth);
                vdFramedControl.BaseControl.ActiveDocument.Prompt("\r\n" + azimouth.ToString("0.0000") + "," + tilt.ToString("0.0000") + "," + twist.ToString("0.0000") + " --- " + v.ToString());
                vdFramedControl.BaseControl.ActiveDocument.Prompt(null);




Example in VB6 using Wrapper components and TLB Interops









''because in vectordraw wrapper we can not set the WorldToView Matrix directly but only with Axis3dRotations we use the VectorDraw_Professional(VectorDraw.Professional.tlb) and VectorDraw_Geometry(VectorDraw.Geometry.tlb) library to do this.
Dim globals As New vectordraw_geometry.GlobalsInterRop



Private Sub cmdGetView_Click()
    Dim document As VectorDraw_Professional.vdDocument
    Dim mat As vectordraw_geometry.Matrix



    Dim Angle_azimouth As Double
    Dim Angle_tilt As Double
    Dim Angle_twist As Double
    Dim viewdir As vectordraw_geometry.Vector
   
    Set document = VDraw1.ActiveDocument.WrapperObject
   
    Set mat = document.World2ViewMatrix
    mat.GetWorldToViewProperties viewdir, Angle_azimouth, Angle_tilt, Angle_twist
  
    azimouth.Text = globals.RadiansToDegrees(Angle_azimouth)
    tilt.Text = globals.RadiansToDegrees(Angle_tilt)
    twist.Text = globals.RadiansToDegrees(Angle_twist)
   
End Sub



Private Sub cmdRotate_Click()
    VDraw1.CommandAction.View3D "VROT"
End Sub



Private Sub cmdSetView_Click()
    Dim mat As New vectordraw_geometry.Matrix
    mat.SetToViewAngles globals.DegreesToRadians(CDbl(azimouth.Text)), globals.DegreesToRadians(CDbl(tilt.Text)), globals.DegreesToRadians(CDbl(twist.Text))



   
    Dim document As VectorDraw_Professional.vdDocument
    Set document = VDraw1.ActiveDocument.WrapperObject
    Set document.World2ViewMatrix = mat
   
    VDraw1.Redraw
End Sub




Private Sub Form_Load()
    ''set the showAxis on
    VDraw1.ShowWCSAxis = UCSICON_Show_Origin
    Call cmdSetView_Click
   
End Sub

 

 

Example in C++ 2005

#import "System.Drawing.tlb"
#import "C:\vdraw6\REDIS\x86\VectorDraw.Geometry.tlb"

void TestMatrixRotations()
{

 //Create a new matrix
 Cvdmatrix mat=m_Vdraw.CreateInstance(25);
 
 //rotate matrix about x,y,z
 mat.RotateX(m_Vdraw.GetUtility().geomDegreesToRad(30));
 mat.RotateY(m_Vdraw.GetUtility().geomDegreesToRad(40));
 mat.RotateZ(m_Vdraw.GetUtility().geomDegreesToRad(50));

 //get the interface of VectorDraw Framework manage object.
 VectorDraw_Geometry::IMatrixPtr vdfmat = mat.GetWrapperObject();
 VectorDraw_Geometry::IVectorPtr direction;
 double azimouth,_azimouth;
 double tilt,_tilt;
 double twist,_twist;
 CString str;

 /// Returns the View Direction and the Angles that define this Matrix.
   /// <param name="direction">A Vector defines the camera point offset from the target point.</param>
   /// <param name="azimouth">Watching angle on XY plane relative to X axis in radians in clockwise direction.</param>
   /// <param name="tilt">Vertical watching angle relative to XY plane in radians.</param>
   /// <param name="twist">Rotation of the created matrix from azimouth and tilt , about Z in radians in clockwise direction.</param>
 vdfmat->GetWorldToViewProperties(&direction,&azimouth,&tilt,&twist);
 _azimouth = m_Vdraw.GetUtility().geomRadToDegrees(azimouth);
 _tilt = m_Vdraw.GetUtility().geomRadToDegrees(tilt);
 _twist = m_Vdraw.GetUtility().geomRadToDegrees(twist);
 str.Format(_T("\nazimouth=%.3f,tilt=%.3f,twist=%.3f"),_azimouth,_tilt,_twist);
 OutputDebugString(str);

        /// Modify this Matrix using azimouth, tilt  and twist angles that specify the view direction relative to World Coordinate System.
        /// <param name="azimouth">Watching angle on XY plane relative to X axis in radians in clockwise direction.</param>
        /// <param name="tilt">Vertical watching angle relative to XY plane in radians.</param>
        /// <param name="twist">Rotation of the created matrix from azimouth and tilt , about Z in radians in clockwise direction.</param>

    vdfmat->SetToViewAngles(azimouth,tilt,twist);

 //Verify the azimouth,tilt and twist angles.
 vdfmat->GetWorldToViewProperties(&direction,&azimouth,&tilt,&twist);
 _azimouth = m_Vdraw.GetUtility().geomRadToDegrees(azimouth);
 _tilt = m_Vdraw.GetUtility().geomRadToDegrees(tilt);
 _twist = m_Vdraw.GetUtility().geomRadToDegrees(twist);
 str.Format(_T("\nazimouth=%.3f,tilt=%.3f,twist=%.3f"),_azimouth,_tilt,_twist);
 OutputDebugString(str);

}

 



Send comments on this topic.