edu.uci.ics.jung.algorithms.layout
Class PolarPoint

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.layout.PolarPoint

public class PolarPoint
extends 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 Summary
PolarPoint()
          Creates a new instance with radius and angle each 0.
PolarPoint(double theta, double radius)
          Creates a new instance with radius radius and angle theta.
 
Method Summary
static PolarPoint cartesianToPolar(double x, double y)
          Returns the result of converting (x, y) to polar coordinates.
static PolarPoint cartesianToPolar(Point2D point)
          Returns the result of converting point to polar coordinates.
 double getRadius()
          Returns the radius for this point.
 double getTheta()
          Returns the angle for this point.
static Point2D polarToCartesian(double theta, double radius)
          Returns the result of converting (theta, radius) to Cartesian coordinates.
static Point2D polarToCartesian(PolarPoint polar)
          Returns the result of converting polar to Cartesian coordinates.
 void setLocation(PolarPoint p)
          Sets the angle and radius of this point to those of p.
 void setRadius(double radius)
          Sets the radius for this point to theta.
 void setTheta(double theta)
          Sets the angle for this point to theta.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 radius radius and angle theta.

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)
Sets the angle for this point to theta.


setRadius

public void setRadius(double radius)
Sets the radius for this point to theta.


polarToCartesian

public static Point2D polarToCartesian(PolarPoint polar)
Returns the result of converting polar to Cartesian coordinates.


polarToCartesian

public static Point2D polarToCartesian(double theta,
                                       double radius)
Returns the result of converting (theta, radius) to Cartesian coordinates.


cartesianToPolar

public static PolarPoint cartesianToPolar(Point2D point)
Returns the result of converting point to polar coordinates.


cartesianToPolar

public static PolarPoint cartesianToPolar(double x,
                                          double y)
Returns the result of converting (x, y) to polar coordinates.


toString

public String toString()
Overrides:
toString in class Object

setLocation

public void setLocation(PolarPoint p)
Sets the angle and radius of this point to those of p.



Copyright © 2009. All Rights Reserved.