No announcement yet.

COS and SIN functions don't seem to work

  • Filter
  • Time
  • Show
Clear All
new posts

  • COS and SIN functions don't seem to work

    Hi, i am trying to manually draw a gauge, and i am drawing the needle using the COS and SIN functions like this: radius*COS(angle), radius*SIN(angle)

    the problem is the needle goes infinitely off the screen. even if i reduce radius to 1 it still goes off the scale.

    i don't want to use the Orbit function because eventually the dial won't be perfectly round.

    gfx_Line(84, 284, 80*(127/COS(angle)), 80*(127/SIN(angle)), 0xF000);
    am i doing something wrong?

    thanks for the help
    Last edited by NeX; 17 April 2015, 01:58 AM.

  • #2
    Did you mean something more like

            gfx_Line(84,284, 84+80*COS(angle)/127, 284+80*SIN(angle)/127, 0xF000);

    Remember that all calculations will be done as 16bit signed integers. For the above that works just fine, but for other values it might produce odd reults


    • #3
      Thank you so much! that works perfectly, i just needed an example, now it all makes perfect sense, of course i need to offset the end value from the edge of the screen using my center points, and divide the result by 127 by putting that at the end of the equation.

      thanks again it works exactly how i wanted now.