Angle of Rotation from a transform matrix

Discuss SVG code, accessible via the XML Editor.
artimusp
Posts: 7
Joined: Sun Jun 13, 2010 11:17 am

Angle of Rotation from a transform matrix

Postby artimusp » Fri Jun 18, 2010 9:55 am

Is there a way to get the angle of rotation from a svg transform matrix?

for example:

rectangle =

x = 0
y = 0
width = 200
height = 200

then I rotate the rectangle by 45 degrees and get

matrix(0.70710678,-0.70710678,0.70710678,0.70710678,-41.421356,100)

is there a way I can extract the degree (in radians is fine) from the matrix. I'm hoping this is the final missing piece I need for what I'm working with.

<rect
style="fill:#b3b3b3;stroke:none"
id="rect3632"
width="200"
height="200"
x="0"
y="0"
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,-41.421356,100)" />

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Angle of Rotation from a transform matrix

Postby sas » Fri Jun 18, 2010 7:00 pm

For an SVG matrix of the form matrix(a,-b,b,a,c,d), where a and b are not both zero, the rotation angle is atan2(b,a). If an SVG matrix represents a rotation, then it will necessarily be of this form.

artimusp
Posts: 7
Joined: Sun Jun 13, 2010 11:17 am

Re: Angle of Rotation from a transform matrix

Postby artimusp » Sat Jun 19, 2010 4:00 am

Perfect. Thanks very much.


Return to “SVG / XML Code”

Who is online

Users browsing this forum: No registered users and 3 guests