SFML community forums

Help => General => Topic started by: mar on May 29, 2017, 11:59:21 am

Title: really point values
Post by: mar 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

Title: Re: really point values
Post by: Laurent 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.
Title: Re: really point values
Post by: mar on May 29, 2017, 12:45:15 pm
yes, the angle in radians.
how I can to convert it to degrees?
Title: Re: really point values
Post by: eXpl0it3r on May 29, 2017, 02:28:56 pm
Google "radians to degrees". It's a very common math problem. ;)