I haven't looked deeply into AutoCAD's matrix operations; but I think
they're standard.
In standard matrix operations the 3x3 matrix in the upper left corner is the
rotation _around_ _(0,0,0)_, the 1x3 vector at the upper right corner is the
translation after the rotation, and the last row is a dummy to make it come
out right. You do a standard matrix multiplication by a 4x1 coordinate
vector (that is, {X Y Z 1} with the 1 added to make it come out right).
So, your first example rotates 45 degrees around the Z axis and translates
by 5 in the X direction and translates -2.071068 in the Y direction.
You can look at your problem as three different successive problems. I'm
going to round to fewer digits to keep the display cleaner.
1. Translate (5,5,0) to (0,0,0):
1.0 0.0 0.0 -5.0
0.0 1.0 0.0 -5.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
2. Rotate 45 degrees around the Z axis:
0.707 -0.707 0.0 0.0
0.707 0.707 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
3. Translate (0,0,0) back to (5,5,0):
1.0 0.0 0.0 5.0
0.0 1.0 0.0 5.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
Multiplying the first matrix by the second, and then the result by the
third, gives the matrix that rotates 45 degrees around (5,5,0):
0.707 -0.707 0.0 -5.0
0.707 0.707 0.0 2.071
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
Which is your first matrix except for the signs in the last column. I don't
know why my signs are different from theirs. Maybe that's a non-standard
thing in AutoCAD.
--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services
In article <403a4891$1_3@newsprd01>, Richard Khaw wrote:
> On-line book about AutoCAD VBA, the elements on the matrix states that:
> 0.707107 -0.707107 0.0 5.0
> 0.707107 0.707107 0.0 -2.071068
> 0.0 0.0 1.0 0.0
> 0.0 0.0 0.0 1.0
>
> I've followed some literature about matrix translation and transformation
> and got the following elements:
> 0.707107 -0.707107 0.0 0.0
> 0.707107 0.707107 0.0 -7.07107
> 0.0 0.0 1.0 0.0
> 0.0 0.0 0.0 1.0
>
> Please suggest me how comes the elements are different and correct my
> mistake.