Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: really point values  (Read 913 times)

0 Members and 1 Guest are viewing this topic.

mar

  • Newbie
  • *
  • Posts: 5
    • View Profile
really point values
« on: May 29, 2017, 11:59:21 am »

Hello,

I tried to create a RectangleShape that start-point of it at 0, 0 (the set position is in this point), the angle of it is 300, and the end-point is: {x=-7.73381662 y=-349.914551 }.
The calculate of the end-point by:



// calculate the second point of the stick by point1 and the angle
point2 = { point1.x + (float)(cos(angle)*STICK_LENGTH) , point1.y + (float)(sin(angle)*STICK_LENGTH) };

when I click on the end-point in the rectangle it gives me completely different values:
The mouseCoords is: {x=432.999969 y=245.000031 }.



auto mouseCoords = window.mapPixelToCoords({ event.mouseButton.x, event.mouseButton.y });


how I can get the really values of the point?


Thank you


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: really point values
« Reply #1 on: May 29, 2017, 12:40:31 pm »
First of all, is your angle in radians? SFML wants angles as degrees but the standard math library wants them in radians.
Laurent Gomila - SFML developer

mar

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: really point values
« Reply #2 on: May 29, 2017, 12:45:15 pm »
yes, the angle in radians.
how I can to convert it to degrees?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
Re: really point values
« Reply #3 on: May 29, 2017, 02:28:56 pm »
Google "radians to degrees". It's a very common math problem. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything