# Re: Rotation matrix - pyode and goocanvas

• From: Fionn Ziegler <fionnziegler gmail com>
• To: goocanvas-list gnome org
• Subject: Re: Rotation matrix - pyode and goocanvas
• Date: Sat, 4 Dec 2010 13:06:04 +0100

```Ok I managed getting the ball rotating:

matrix = cairo.Matrix(1, 0, 0, 1, 0, 0);
matrix.translate(x2,y2)
matrix.rotate(angle)
matrix.translate(-x2,-y2)
goo.set_transform(matrix)
That works fine.

On Fri, Dec 3, 2010 at 1:51 PM, Fionn Ziegler <fionnziegler gmail com> wrote:
> Hi,
> I'm writing a small game (for adding) using goocanvas and the open
> dynamics engine (ODE) or thre python wraper for that.
> A already managed a lot but now I've a unsolved problem. Maybe its a
> lack of math skills I don't know.
> Ho can I spin a (Goocanvas) Ellipse.
> From ODE i get the Rotation
> "getRotation()
> Get the current orientation of the geom. If the geom is attached to a
> body the returned value is the body's orientation.
>    Returns:
>        9-tuple"
> Is there a way to manipulate directly the object matrix?
> in the ODE FAQ is the following explanation:
>
>        | A B C |
> M =  | D E F |
>        | G H I |
>
> which is the reverse of what you'd use in OpenGL (which is also column
> vector on the right).
>
> So my question is: how can I apply these ODE matrix to the goocanvas?
> Or how to change the matrix (like orientation/direction)
>
> Thanks for any help,
> Regards,
> Fionn
>
>
> This is the code to set the ellipse position of the ode_body
>
> x2, y2, z2 = body.getPosition()
> goo.set_properties(center_y=y2, center_x=x2)
>
> an interesting topic: http://osdir.com/ml/lib.ode/2002-12/msg00176.html
> more math stuff:
> http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
>
```