Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by tal on 4/25/17.
- */
- public class Point {
- private double _radius;
- private double _alpha;
- public Point(double x, double y)
- {
- _radius = Math.sqrt(Math.pow(x,2) + Math.pow(y,2));
- _alpha = Math.atan(y/x);
- if(_alpha >= ((Math.PI)/2) & _alpha < (Math.PI))
- _alpha = Math.PI/2;
- if(_alpha >= Math.PI & _alpha < (Math.PI * 3/4))
- _radius = 0;
- if(_alpha >= (Math.PI * 3/4))
- _alpha = 0;
- }
- public Point(Point other)
- {
- this._radius = other._radius;
- this._alpha = other._alpha;
- }
- public double getX()
- {
- return(_radius * Math.cos(_alpha));
- }
- public double getY()
- {
- return(_radius * Math.sin(_alpha));
- }
- public void setX(double num)
- {
- if (num >= 0)
- {
- _radius = num / Math.cos(_alpha);
- _alpha = Math.atan(Math.sqrt(Math.pow(_radius, 2) - Math.pow(num, 2)) / 2);
- }
- }
- public void setY(double num)
- {
- if (num >= 0)
- {
- _radius = num / Math.sin(_alpha);
- _alpha = Math.atan(Math.sqrt(Math.pow(_radius, 2) - Math.pow(num, 2)) / 2);
- }
- }
- public String toString()
- {
- return ("(" + _radius * Math.cos(_alpha) + "," + (_radius * Math.sin(_alpha)) + ")"); // need to round it.
- }
- public boolean equals(Point other)
- {
- return ((_radius == other._radius) & (_alpha == other._alpha)); // need to round number to check if they are equal
- }
- public boolean isAbove(Point other)
- {
- //check what to put here
- }
- public boolean isLeft(Point other)
- {
- // check what to put here
- }
- public boolean isRIght(Point other)
- {
- //check what to put here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement