Class Geometry

java.lang.Object
  extended by Geometry

public class Geometry
extends Object

Class to hold methods for doing simple geometry All methods are static (class) methods. You do not need to create an object of the Geometry class to use these methods.

Author:
Barb Ericson ericson@cc.gatech.edu Copyright 2005

Constructor Summary
Geometry()
           
 
Method Summary
static double getDistance(double x1, double y1, double x2, double y2)
          Method to get the distance between two points
static Point getPointAtDistance(int x1, int y1, double heading, double distance)
          Method to get a new point at a given distance from an old point along a heading (angle in degrees)
static Point getPointAtDistance(Point startPoint, double heading, double distance)
          Method to get a new point at a given distance from an old point along a heading (angle in degrees)
static double getSlope(double x1, double y1, double x2, double y2)
          Method to get the slope between two points
static double getSlopeAngle(double x1, double y1, double x2, double y2)
          Method to get the slope angle between 2 points The slope angle is the interior angle of the triange of the slope line with the y and x axis.
static double getTurtleHeading(double x1, double y1, double x2, double y2)
          Method to return the heading for a turtle which uses 0 degrees as north
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geometry

public Geometry()
Method Detail

getSlope

public static double getSlope(double x1,
                              double y1,
                              double x2,
                              double y2)
Method to get the slope between two points

Parameters:
x1 - the x value for one of the points
y1 - the y value for one of the points
x2 - the x value for a second point
y2 - the y value for a second point
Returns:
the slope

getSlopeAngle

public static double getSlopeAngle(double x1,
                                   double y1,
                                   double x2,
                                   double y2)
Method to get the slope angle between 2 points The slope angle is the interior angle of the triange of the slope line with the y and x axis. So it is the angle from the x axis.

Parameters:
x1 - the x value for one of the points
y1 - the y value for one of the points
x2 - the x value for a second point
y2 - the y value for a second point
Returns:
the slope angle in degrees

getTurtleHeading

public static double getTurtleHeading(double x1,
                                      double y1,
                                      double x2,
                                      double y2)
Method to return the heading for a turtle which uses 0 degrees as north

Parameters:
x1 - x from the first point
y1 - y from the first point
x2 - x from the second point
y2 - y from the second point
Returns:
the heading in degrees from north

getPointAtDistance

public static Point getPointAtDistance(int x1,
                                       int y1,
                                       double heading,
                                       double distance)
Method to get a new point at a given distance from an old point along a heading (angle in degrees)

Parameters:
x1 - x of a point
y1 - y of a point
heading - the heading in degrees with north being 0 and south 180
distance - the distance for the returned point
Returns:
the point at the distance in the direction of the heading

getPointAtDistance

public static Point getPointAtDistance(Point startPoint,
                                       double heading,
                                       double distance)
Method to get a new point at a given distance from an old point along a heading (angle in degrees)

Parameters:
startPoint - the point to get the distance from
heading - the heading in degrees with north being 0 and south 180
distance - the distance for the returned point
Returns:
the point at the distance in the direction of the heading

getDistance

public static double getDistance(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Method to get the distance between two points

Parameters:
x1 - x value of first point
y1 - y value of first point
x2 - x value of second point
y2 - y value of second point
Returns:
distance between the points