Class PolarPoint


  • public class PolarPoint
    extends Object
    Immutable Point. Represents a point in polar coordinates: distance and angle from the origin. Includes conversions between polar and Cartesian coordinates (Point).
    Author:
    Tom Nelson
    • Field Detail

      • theta

        public final double theta
      • radius

        public final double radius
    • Method Detail

      • of

        public static PolarPoint of​(double theta,
                                    double radius)
      • newRadius

        public PolarPoint newRadius​(double radius)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • polarToCartesian

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

        public static Point 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​(Point 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.