Help understanding the rotation vector

Help understanding the rotation vector

Anonymous
Not applicable
555 Views
8 Replies
Message 1 of 9

Help understanding the rotation vector

Anonymous
Not applicable
Hi,
I'm having a problem inserting a steel section in to an assembly. The part is called by the script and inserted using the following:

Call oMatrix.SetToRotation(3.14159265358979 / 2, _
noticeable(0, 1, 0), oTG.CreatePoint(0, 0, 0))
Call oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))
Set oOcc = oAsmCompDef.Occurrences.Add(CHANNELFILENAME, oMatrix)

My problem is this createvector(0,1,0) does not give me the desired orientation of the steel. It is not symetric in its geometry. I have tried 1,0,0 and 0,0,1 and 0,0,0. I can rotate any of these orientations about the axis by adjusting the pi/2 part in SetRoatationTo. I can't get the part to face the right way though. No matter what! Am i missing something here? It seems I almost need to use another transfomation but if I add one after the original, then it just inserts the part at the last transformation in my code and disregards the first. My question, i guess, is really, how can i perform multiple rotation transformation on a part as it is inserted in to the assembly. Else, how do i write the transformation matrix for one transformation to achieve the rotation I desire?

Kind regards

Matt
0 Likes
556 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
can you post a pic of what you are getting and what you want?
0 Likes
Message 3 of 9

Anonymous
Not applicable
Ok, I have just made a picture. Hope this speaks a thousand words!

Its like its inserted as normal at (0,0,0). I specify the angle of rotation and the axis of rotation, but I can't get it to face the way I want! Help!! Its ruining my day!!!
0 Likes
Message 4 of 9

Anonymous
Not applicable
you will need two rotations. I wasn't sure of the original coordinate system, so I have illustrated a possible CS on your drawing. You may need to modify the code slightly if your assembly CS is different. Code in next post...
0 Likes
Message 5 of 9

Anonymous
Not applicable
Public Sub TestMatrixMath()

Dim dPI As Double
dPI = 3.14159265358979

Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Dim oP0 As Point
Dim oV0 As Vector

Set oP0 = oTG.CreatePoint(0, 0, 0)
Set oV0 = oTG.CreateVector(0, 0, 0)

Dim oM1 As Matrix
Dim oM2 As Matrix

Set oM1 = oTG.CreateMatrix
Set oM2 = oTG.CreateMatrix

DebugPrintMatrix oM1
DebugPrintMatrix oM2

' set M1 to be a rotation about assembly CS Y axis
Set oV0 = oTG.CreateVector(0, 1, 0)
oM1.SetToRotation -dPI / 2#, oV0, oP0

DebugPrintMatrix oM1


' set M2 to be a rotation about Z axis
Set oV0 = oTG.CreateVector(0, 1, 0)
oM2.SetToRotation dPI, oV0, oP0

DebugPrintMatrix oM2


' post-multiply oM1 by oM2
oM1.PostMultiplyBy oM2

DebugPrintMatrix oM1

End Sub
0 Likes
Message 6 of 9

Anonymous
Not applicable
alternatively, I believe you could have gotten the same result with

Set oV0 = oTG.CreateVector(-1, 0, 1)
oM1.SetToRotation dPI , oV0, oP0
0 Likes
Message 7 of 9

Anonymous
Not applicable
Thanks for your help Josh, but I'm really having trouble grasping this whole matrix rotation thing!! I ran the script you typed up and I'm even getting a problem with the DebugPrintMatrix oM1 line and all lines that contain DebugPrintMatrix...I've tried to replace these with Msgbox but can't even get that to work...I'm tearing out my hair!!

Can you help further?

Regards

Matt
0 Likes
Message 8 of 9

Anonymous
Not applicable
oops yes I forgot to add the DebugPrintMatrix function, here it is:




Public Sub DebugPrintMatrix(m As Matrix)

Dim str As String

' assume that matrix is stored in row-wise format
For i = 1 To 4
For j = 1 To 4

str = str & m.Cell(i, j) & Chr(9)

Next j

str = str & Chr(10)
Next i


Debug.Print str

End Sub






As for understanding the matrix rotations, search the web for "rotation matrix", "transformation matrix", "homogeneous transformation matrix". These matrices are very common in computer graphics and there are lots of pages explaining them.
0 Likes
Message 9 of 9

Anonymous
Not applicable
Ok thanks a lot! Thats great! I can't believe how helpful people on this forum are!! Have a good day.

Matt
0 Likes