Reputation: 1546
I am building the following:
public class Point2
{
private double _radius , _alpha;
public Point2 ( int x , int y )
{
_radius = Math.sqrt ( Math.pow(x,2) + Math.pow (y,2) ) ;
_alpha = Math.atan(y/x) ;
}
}
The only thing that stuck me is the _alpha calc. I'm trying to think how to operate this one using Math class the shortest and readable way... Is my way OK ? thnx
Upvotes: 0
Views: 191
Reputation: 21836
Mr E is correct, atan2 seems to be the way to go. Here is the link to the appropriate javadoc for atan2.
Upvotes: 0