canvas.Rotation vs Trig function rotation

About Monkey 2 Forums Monkey 2 Development canvas.Rotation vs Trig function rotation

This topic contains 14 replies, has 5 voices, and was last updated by  Mark Sibly 1 year, 2 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #13000

    Jesse
    Participant

    I was trying to figure out why I couldn’t get a program to work correctly and I couldn’t figure out why. Well it happens to be that rotation on the canvas method works counter clockwise while the trig functions such as sin, Cos, Tan etc.. all work in clockwise direction. Is this intentional or is it bug? I would like to think it’s a bug and would like this fixed if/when possible.

    en example:

    [/crayon]

    Both lines should be turning clockwise direction I HOPE.

    #13001

    Simon Armstrong
    Participant

    IMHO it is traditional in 2D computer graphics that Y is down not up and hence your trig should read cos,-sin not cos,sin.

    #13003

    Jesse
    Participant

    is it really traditional?
    I never had that issue before. Even Blitzmax does it clockwise.

    #13005

    abakobo
    Participant

    Canvas.Rotate could have been defined as clockwise (inverting y axis in the matrix stuff). But seem a bit late to change it now.

    #13006

    Jesse
    Participant

    Yea, this makes more sense to me than the traditional…

    I just hope I can remember that for later projects.

    I am sure others will run in to this problem sooner or later.

    #13007

    Simon Armstrong
    Participant
    #13008

    Jesse
    Participant

    So, would that make the Sin function in Monkey2 wrong?

    #13010

    abakobo
    Participant

    The “angle of rotation” article is not so great in a mathematical point of view (IMHO).
    To me,this is the real stuff I think: https://en.wikipedia.org/wiki/Cartesian_coordinate_system

    Trigs functions are usually set in a “standard” or “positive” orientation/handedness.
    https://en.wikipedia.org/wiki/Cartesian_coordinate_system#Orientation_and_handedness.

    So, would that make the Sin function in Monkey2 wrong?

    If there is something wrong, it is not inverting y axis in the canvas.matrix formulas. The formulas there are the ones for positive coordinate system but a canvas has negative coordinate system.
    But on the other hand, it’s ok that AffineMatX uses a positive coordinate system as they are standart Maths concept. Canvas matrix directly uses AffineMat3 and that’s where it hurts.

    Edit: Canvas is turning counter clockwise so it’s actualy ok!? I’m confused now with all these definitions. ;P

    #13011

    Jesse
    Participant

    I am trying to get to the bottom of a very insignificant problem that is bothering me and it has to to with the way Monkey2 handles rotation in relation to trig functions and graphics. I would like to see some consistencies thats all. Either way, I have already accepted it. Not that your most recent explanation abakobo made more cense to me. 🙂

    Hahaha!, I just so your edit. Now it makes cense! 😉

    #13012

    abakobo
    Participant

    Some more reading (that could make even less sense!) https://en.wikipedia.org/wiki/Rotation_matrix#Non-standard_orientation_of_the_coordinate_system.

    In this article a rotation on negative coordinate system should turn clockwise… So there are several opinions!?

    True that it would have been easier for this to be consistent.

    BUT you can make canvas Extension with a “ConsistentRotate” method ..?

    Ok I stop sorry

    #13013

    Jesse
    Participant

    everything would be so much easier if the computer world would have done everything in standard scholastic trig methods to start with but we are here so OK.

    #13178

    cocon
    Participant

    I found a third way of inverting the Y axis. However visually it would not make sense because it will turn graphics upside down. But if you take this concept and perform the transformations using Matrix object the calculations will be applied only to values.

    #13189

    Mark Sibly
    Keymaster

    I think the problem here is that I use the ‘standard’ 2d rotation matrix…

    https://en.wikipedia.org/wiki/Rotation_matrix

    …but I guess this assumes +y is ‘up’ (and I never really thought about this before) so perhaps the cosines or something need to be negated or perhaps you need to use: scale( 1,-1 ) * rotate( r ) * scale( 1,-1 )?

    If this is the case, it wouldn’t be hard to add a canvas ‘mode’ that addressed this if enough people wanted it.

    #13192

    abakobo
    Participant

    Consistency over all the “rotation” angles would be cool if doable without breaking previous angles things!

    #13193

    Mark Sibly
    Keymaster

    I had a quick look at bmx (welll, glanced at digesteroids src), and rotation seems to be the same there, ie: +rotation=ccw. And I think, in the context of  a +y=down coord system this is actually correct, these are just numbers after all.

    What people are possibly really after here is a way to change +y=down to +y=up? This is probably doable and I think would be quite cool – cooler than just fudging rotation or something.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.