Quantcast

Maximum PC

It is currently Thu Oct 23, 2014 8:53 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Calculate angles with Java
PostPosted: Sat May 30, 2009 5:52 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Hey, I'm doing a simple trajectory calculation in Java and it seems that the Math.sin method is giving me a negative number. Not only that but the number i'm looking for is all wrong.


Top
  Profile  
 
 Post subject: Re: Calculate angles with Java
PostPosted: Sat May 30, 2009 6:16 pm 
Little Foot
Little Foot

Joined: Sat Feb 11, 2006 11:04 am
Posts: 174
Dwood15 wrote:
Hey, I'm doing a simple trajectory calculation in Java and it seems that the Math.sin method is giving me a negative number. Not only that but the number i'm looking for is all wrong.


maybe your algorithm is wrong. Post your code here for people can see it.


Top
  Profile  
 
 Post subject:
PostPosted: Sat May 30, 2009 6:23 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Also remember that all Java's trig functions work in radians. If you're doing degrees, then it won't work.


Top
  Profile  
 
 Post subject:
PostPosted: Sat May 30, 2009 6:49 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quertior wrote:
Also remember that all Java's trig functions work in radians. If you're doing degrees, then it won't work.


it's just Math.sin(angle) so how do I get it into degrees? Math.toDegrees();?


Top
  Profile  
 
 Post subject:
PostPosted: Sat May 30, 2009 8:00 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Dwood15 wrote:
it's just Math.sin(angle) so how do I get it into degrees? Math.toDegrees();?


Wait, let me clarify. Math.sin() will NOT work correctly with an angle in degrees. If you are using radians, you should be FINE.

However, if not:
Code:
double angleInDegrees = /*some angle in degrees*/ ;
double sineOfAngle = Math.sin(Math.toRadians(angleInDegrees));

Hope that helps.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 6 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.