5 Replies - 7886 Views - Last Post: 18 December 2009 - 12:40 PM Rate Topic: -----

#1 hiddenghost   User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Derive arbitrary 2d matrix rotation

Posted 15 December 2009 - 11:17 PM

I want to derive the matrix that does arbitrary rotation of a point around a point.

There are a few versions of the already derived rotation matrix on the net.

I did the derivation and found mine doesn't look like what some one else has done.
It would be good to see what I'm doing wrong.

Please use this form:
T1 = transform 1 = subtraction of A
T2 = transform 2 = rotation
T3 = transform 3 = addition of A
A = original

Premultiply:
T = [T1] x [T2] x [ T3] x [A]


These attachements show the difference of my messed up derivation and another persons derivation.
My version has no -1 in the first two of the right column. One sin and cos are switched.
Attached Image
His version has a -1 in the first two of the right column. The sin and cos functions line up vertically in the right column.
Attached Image

This post has been edited by hiddenghost: 15 December 2009 - 11:40 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Derive arbitrary 2d matrix rotation

#2 hiddenghost   User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Re: Derive arbitrary 2d matrix rotation

Posted 15 December 2009 - 11:46 PM

Ok, now I see that the Px(sin) + Py(cos) are commutative so the reason for the switch of the two is apparent.

I still can't quite see how the -1 got next to the two cosines in the right column for his.

This post has been edited by hiddenghost: 15 December 2009 - 11:48 PM

Was This Post Helpful? 0
  • +
  • -

#3 LaFayette   User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 326
  • Joined: 24-November 08

Re: Derive arbitrary 2d matrix rotation

Posted 17 December 2009 - 03:30 AM

edit: Ok, now I read it more carefully.


Thinking about it without any calculations, all matrices have a 1 in the bottem right corner which lead to terms looking something like Px*cos (theta) - Px = Px(cos (theta) - 1). You are probably doing some simple mistake..

What does your translation matrices look like??

I did it like this on the computer

R = {{Cos[x], - Sin[x], 0}, {Sin[x], Cos[x], 0}, {0, 0, 1} }
T1 = {{1, 0, Px}, {0, 1, Py}, {0, 0, 1}}

Inverse[T1]*R*T1

and got exactly what the other guy got.

This post has been edited by LaFayette: 17 December 2009 - 06:01 AM

Was This Post Helpful? 0
  • +
  • -

#4 hiddenghost   User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Re: Derive arbitrary 2d matrix rotation

Posted 18 December 2009 - 01:11 AM

View PostLaFayette, on 17 Dec, 2009 - 03:30 AM, said:

What does your translation matrices look like??

The translation to the origin
Attached Image
The rotation
Attached Image
The translation back to the arbitrary point
Attached Image

Everything is correct for me accept the -1 so yeah, it probably is a simple error. :blush:
Was This Post Helpful? 0
  • +
  • -

#5 LaFayette   User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 326
  • Joined: 24-November 08

Re: Derive arbitrary 2d matrix rotation

Posted 18 December 2009 - 02:04 AM

Opposite to what I wrote yesterday, given a point p to rotate about an arbitrary point q you should first apply the translation to origin, the rotation, and then the translation back.

So
R = {{Cos[x], - Sin[x], 0}, {Sin[x], Cos[x], 0}, {0, 0, 1} } //Rotation
T1 = {{1, 0, -Px}, {0, 1, -Py}, {0, 0, 1}} //Translation to origin
T2 = {{1, 0, Px}, {0, 1, Py}, {0, 0, 1}} //Translation back

And T = T2 x R x T1 which in steps are:

A = R x T1 = { {Cos[x], -Sin[x], -Px Cos[x] + Py Sin[x]}, {Sin[x],
Cos[x], -Py Cos[x] - Px Sin[x]}, {0, 0, 1} }

T = T2 x R x T1 = T2 x A = { {Cos[x], -Sin[x], Px - Px Cos[x] + Py Sin[x]}, {Sin[x], Cos[x],
Py - Py Cos[x] - Px Sin[x]}, {0, 0, 1} }

(Hope you get the notation I'm using)
Changing the order gives a slightly different result (other signs) but given that we are in a normal coordinate system I think this should be correct. (I actually tried writing a program in Mathematica using that matrix and it worked)

This post has been edited by LaFayette: 18 December 2009 - 02:21 AM

Was This Post Helpful? 2
  • +
  • -

#6 hiddenghost   User is offline

  • D.I.C Addict
  • member icon

Reputation: 39
  • View blog
  • Posts: 621
  • Joined: 15-December 09

Re: Derive arbitrary 2d matrix rotation

Posted 18 December 2009 - 12:40 PM

I think I get your notation.
Another way to write it would be:
R = {{Cos[x], - Sin[x], 0},
------{Sin[x], Cos[x], 0},
------ {0,-------0,----1} } //Rotation
T1 = {{1, 0, -Px},
------- {0, 1, -Py},
------- {0, 0, 1}} //Translation to origin
T2 = {{1, 0, Px},
------- {0, 1, Py},
------- {0, 0, 1}} //Translation back

Thank you LaFayette.

When I get time I will try to calculate it again to see if I missed something.

This post has been edited by hiddenghost: 18 December 2009 - 12:42 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1