Class PolarPoint


  • public class PolarPoint
    extends java.lang.Object
    Represents a point in polar coordinates: distance and angle from the origin. Includes conversions between polar and Cartesian coordinates (Point2D).
    Author:
    Tom Nelson - tomnelson@dev.java.net
    • Constructor Detail

      • PolarPoint

        public PolarPoint()
        Creates a new instance with radius and angle each 0.
      • PolarPoint

        public PolarPoint​(double theta,
                          double radius)
        Creates a new instance with the specified radius and angle.
        Parameters:
        theta - the angle of the point to create
        radius - the distance from the origin of the point to create
    • Method Detail

      • getTheta

        public double getTheta()
        Returns:
        the angle for this point
      • getRadius

        public double getRadius()
        Returns:
        the radius for this point
      • setTheta

        public void setTheta​(double theta)
      • setRadius

        public void setRadius​(double radius)
      • polarToCartesian

        public static java.awt.geom.Point2D polarToCartesian​(PolarPoint polar)
        Parameters:
        polar - the input location to convert
        Returns:
        the result of converting polar to Cartesian coordinates.
      • polarToCartesian

        public static java.awt.geom.Point2D polarToCartesian​(double theta,
                                                             double radius)
        Parameters:
        theta - the angle of the input location
        radius - the distance from the origin of the input location
        Returns:
        the result of converting (theta, radius) to Cartesian coordinates.
      • cartesianToPolar

        public static PolarPoint cartesianToPolar​(java.awt.geom.Point2D point)
        Parameters:
        point - the input location
        Returns:
        the result of converting point to polar coordinates.
      • cartesianToPolar

        public static PolarPoint cartesianToPolar​(double x,
                                                  double y)
        Parameters:
        x - the x coordinate of the input location
        y - the y coordinate of the input location
        Returns:
        the result of converting (x, y) to polar coordinates.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setLocation

        public void setLocation​(PolarPoint p)
        Sets the angle and radius of this point to those of p.
        Parameters:
        p - the point whose location is copied into this instance