Rotate also rotates x,y coordinates? [ANSWERED]

When you use rotate() function, why is the x,y changed? it is supposed to not change the coordinates system! isnt it? :-@

rotate() rotates the entire frame of reference. translate() and scale() do the same.

You can wrap it in pushMatrix() and popMatrix() to get the effect you’re probably looking for (rotating a sprite, not the frame of reference).

Codea’s graphics model is largely inspired by processing ( which does it the same way. The idea behind moving the whole frame of reference is it makes it easier to do things like a scenegraph.

I have wrote to Simeon this email:
i’m trying to understand the coordinates system we have in Codify.
If I use the rotate function and then draw a sprite, it coordinates are rotates also, it is a bit confusing to me, since in major engines when you rotate an object the coordinates system remains the same…

For example, with this code

function draw(x ,y,angle)
–translate(x,y) – do we need to do this?
sprite(“…”, x,y)

after rotate, x is not the normal x in the screen, it is the x rotated…i think this is a wrong approximation, but if it is right and i am wrong, do we need to create a function to convert from the rotated to the not rotated coordinates system?

so, you are saying that if i use pushMatrix and popMatrix to rotate a sprite and then translate it to x,y?

The order (for what you’re trying to represent, a sprite rotating) should be:
draw your graphics

If you rotate first, you indeed rotate your coordinate system; you might want this, if, for example, your rotation represents the observer/camera moving rather than the sprite - Imagine a chessboard with pieces on it. When you wanted to change your point-of-view, you want both the pieces and the chessboard they’re on to rotate.

I hope that makes sense.

It makes sense, thanks :slight_smile:

Sorry juaxix for not getting back to your email. It was on my list but this rename issue is taking up a lot of time at the moment.

It sounds like Bortels has sorted it out for you.

Yes, he is a machine :slight_smile:
Hey, change also this page “title” ,great work as always…and be strong!

LOL - I do look forward to my robot body! :slight_smile:

I gotta say - totally off topic - I’m having a lovely time messing with Codify/Codea. It really hits the sweet spot for casual kinda mess-with-it coding, one that really hasn’t been available since the 8-bit days (I’m not a Java fan, so processing hasn’t pushed my buttons the way lua does). There’s gaps, of course, but that’s kinda part of the fun in a weird, twisted way - how do we work around limitations (for now) and still do awesome stuff?

hahaha, well, you know, kids need limits (gaps) to break them so they can feel they are free, we are like kids with a new toy and that new toy is Codea ,but this time we are grew up and in our adult form XD