Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


basic math problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Mon Nov 23, 2015 12:47 pm    Post subject: basic math problem Reply with quote

so, I'm making a game in which player should rotate depending on where the cursor is placed.
In multimedia library that I'm using its asking for how much degrees it wants to rotate and that's where my problem is.


Code:
click1Pos.x = (int)sf::Mouse::getPosition(cliff->window).x;
        click1Pos.y = (int)sf::Mouse::getPosition(cliff->window).y;
        moveToCursor = true;

        double one = playerYposition - mouseYposition;
        double two = playerX - mouseXposition;
        double tanges = (tan(one/two)* RAD);

        player1.setRotation(tanges);


for some reason it isn't working properly
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Mon Nov 23, 2015 1:38 pm    Post subject: Reply with quote

I guess, at least
Code:
double tanges = (tan(one/two)* RAD);
//should be?
double tanges = (atan(one/two)* RAD);  // atan is inverse of tan,ie.  tan(angle)==ydiff/xdiff => atan(ydiff/xdiff)==angle

and atan should already give radian unit (-pi<->pi, instead of -180<->180)??,
unless RAD mean RAD2DEGREE and setRotation accept degree unit instead of radian.

_________________
- Retarded.
Back to top
View user's profile Send private message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Tue Nov 24, 2015 7:28 am    Post subject: Reply with quote

panraven wrote:
I guess, at least
Code:
double tanges = (tan(one/two)* RAD);
//should be?
double tanges = (atan(one/two)* RAD);  // atan is inverse of tan,ie.  tan(angle)==ydiff/xdiff => atan(ydiff/xdiff)==angle

and atan should already give radian unit (-pi<->pi, instead of -180<->180)??,
unless RAD mean RAD2DEGREE and setRotation accept degree unit instead of radian.


RAD means RAD2DEGREE and setRotation accepts degree units.

thank you, that was the problem
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites