Results 1 to 2 of 2

Thread: sin(); and cos(); dont work correctly! (math.h) Help me please

                  
   
  1. #1
    DCEmu Newbie
    Join Date
    Nov 2007
    Posts
    18
    Rep Power
    0

    Default sin(); and cos(); dont work correctly! (math.h) Help me please

    Im trying to get points of a circle using sin() and cos()...
    I did it on the calculator like this
    x = circle x + radius * cos(angle)
    y = circle y + radius * sin(angle)

    x = 240 + 60 * cos(180);
    y = 136 + 60 * sin(180);

    on the caluculator I get
    x = 180 (correct)
    y = 136 (also correct)

    but when I use the psp's math.h sin() and cos() I get
    x = 204
    y = 87
    ???
    any Ideas on what is causing this
    maybe its a stupid mistake I made, here are the functions I use to get both the x and y values:

    int GetCircleCoordX(int x,int r,int angle)
    {
    return x + r * cos(angle);
    }
    int GetCircleCoordY(int y,int r,int angle)
    {
    return y + r * sin(angle);
    }

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Sin and cos functions in cmath/math.h use radians, not degrees.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •