TransformBy does not appear to work

TransformBy does not appear to work

Anonymous
Not applicable
761 Views
3 Replies
Message 1 of 4

TransformBy does not appear to work

Anonymous
Not applicable

I have a point 'point5', 'angle' (1.04 radians) and a vector 'awayDir' which is '-Z' and I wish to create 'point8' rotated as shown

 

      point5

        |\

        |  \

 d     |    \

        |      \

        |        \

                point8 

        

 Here is my code:

 

            Dim point8 As Point = point5.Copy()
            point8.TranslateBy(vertticalHeightVector)

            If angle > 0.0000001 Then
                Dim mat As Matrix = _invApp.TransientGeometry.CreateMatrix()
                mat.SetToRotation(angle, awayDir, point5)
                point8.TransformBy(mat)
            End If

It is seemingly simple, but point8 remains unchanged even after TransformBy call

 

Am I missing anything?

 

 

       

0 Likes
Accepted solutions (1)
762 Views
3 Replies
Replies (3)
Message 2 of 4

Vladimir.Ananyev
Alumni
Alumni

I've tested your steps in the VBA.  Your workflow works fine on my side.

Sub RotatePoint()
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    
    'initial point = rotation center
    Dim point1 As Point
    Set point1 = oTG.CreatePoint(0, 0, 0)
    
    'another point
    Dim point2 As Point
    Set point2 = point1.Copy
    Debug.Print "Position 0: ", point2.x, point2.y, point2.z
    
    'translation vector
    Dim V As Vector
    Set V = oTG.CreateVector(0, -10, 0)
    Call point2.TranslateBy(V)
    Debug.Print "Position 1: ", point2.x, point2.y, point2.z
    
    'rotation axis
    Dim axisDir As Vector
    Set axisDir = oTG.CreateVector(0, 0, 1)
    
    'rotation angle = 90°
    Dim Angle As Double
    Angle = Math.Atn(1) * 2
    
    'transformation matrix
    Dim Mat As Matrix
    Set Mat = oTG.CreateMatrix
    Call Mat.SetToRotation(Angle, axisDir, point1)
    
    'rotate point2
    Call point2.TransformBy(Mat)
    Debug.Print "Position 2: ", point2.x, point2.y, point2.z
        
End Sub


Results:

Position 0:    0             0             0 
Position 1:    0            -10            0 
Position 2:    10           -2,22044604925031E-15        0

Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks Vladimir.

 

I guess the mistake I may be doing is in the supply of wrong axis of roation. That axis should be perpendicular to the plane these both vectors make, right?

 

Let me check.

0 Likes
Message 4 of 4

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

Yes, the axis must be perpendicular to this plane


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network