All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class primitives.geomtry.Geomtry

java.lang.Object
   |
   +----primitives.geomtry.Geomtry

public final class Geomtry
extends Object
The class Geomtry contains methods for preforming basic plane geomtry calculations required by related objects.


Variable Index

 o ANCHOR_SIZE
Determines the size in pixels of a drawn machine's anchor.
 o JOINT_SIZE
Determines the size in pixels of a drawn Machine's joint.

Constructor Index

 o Geomtry()
Don't let anyone instantiate this class.

Method Index

 o distance(Coordinate, Coordinate)
Returns the euclidean distance between 2 coordinate objects.
 o drawAnchor(Graphics, Point)
Draws a machine's anchor.
 o drawJoint(Graphics, Point)
Draws a machine's joint.
 o findPointOnPolygon(Coordinate, Coordinate, Polygon)
Returns the location of the intersection of a convex polygon and the line connecting 2 coordinates.
 o findPointOnPolygon(Coordinate, double, Polygon)
Returns the location of the intersection of a convex polygon and the line projecting of the coordinate with the given angle.
 o getAngle(Coordinate, Coordinate)
Returns the angle in radians between 2 coordinates.
 o getMidPoint(Coordinate, Coordinate, double)
Returns the convex sum of 2 locations.
 o getPointByVector(Coordinate, double, double)
Returns the coordinate location with the specified distance and angle from the given coordinate.
 o getStandartAngle(double)
Returns the corresponding argument value in the range 0-Math.PI*2
 o getTriPoint(Coordinate, double, Coordinate, double)
Returns the 2 possible locations of a point with the specified distances from 2 locations.
 o getTriPointEx(Coordinate, double, Coordinate, double, Coordinate, Coordinate)
Returns a location of a point with the specified distances from 2 locations.
 o modulo(double, double)
return the positive mod of an argument.
 o polarToCartes(Coordinate)
Converts polar coordinate to cartesian coordinate.
 o squareFormula(double, double, double)
Returns the 2 solutions of a quadratic equation.
 o toAngle(double)
Converts radians to degrees.
 o toRadian(double)
Converts degrees to radians.

Variables

 o ANCHOR_SIZE
 private static final int ANCHOR_SIZE
Determines the size in pixels of a drawn machine's anchor.

 o JOINT_SIZE
 private static final int JOINT_SIZE
Determines the size in pixels of a drawn Machine's joint.

Constructors

 o Geomtry
 private Geomtry()
Don't let anyone instantiate this class.

Methods

 o distance
 public static double distance(Coordinate d1,
                               Coordinate d2)
Returns the euclidean distance between 2 coordinate objects.

Parameters:
d1 - a coordinate.
d2 - a coordinate.
Returns:
the distance between d1 and d2.
 o squareFormula
 public static double[] squareFormula(double a,
                                      double b,
                                      double c) throws ArithmeticException
Returns the 2 solutions of a quadratic equation. Given the equation: ax2+bx+c=0.

Parameters:
a - a double.
b - a double.
c - a double.
Returns:
an array of double with length =2 of the solutions to the quadratic equation.
Throws: ArithmeticException
when there is no real solution to the quadratic equation.
 o getPointByVector
 public static Coordinate getPointByVector(Coordinate c,
                                           double modul,
                                           double arg)
Returns the coordinate location with the specified distance and angle from the given coordinate.

Parameters:
c - a coordinate.
modul - the distance from c.
arg - the angle in radians.
Returns:
the location of with the specified argument and modul from c.
 o findPointOnPolygon
 public static Coordinate findPointOnPolygon(Coordinate center,
                                             Coordinate state,
                                             Polygon polygon)
Returns the location of the intersection of a convex polygon and the line connecting 2 coordinates. The method uses an approximation algorithm rather than a linear computation which would be more efficient.

Parameters:
center - a coordiante presumed to lie inside the polygon.
state - a coordinate presumed to lie outside(or on) the polygon.
polygon - the polygon.
Returns:
the Coordinate location of the point on the polygon.
 o findPointOnPolygon
 public static Coordinate findPointOnPolygon(Coordinate center,
                                             double angle,
                                             Polygon polygon)
Returns the location of the intersection of a convex polygon and the line projecting of the coordinate with the given angle. The method uses an approximation algorithm rather than a linear computation which would be more efficient.

Parameters:
center - a coordiante presumed to lie inside the polygon.
angle - the angle of the line from centerto find the intersection.
polygon - the polygon.
Returns:
the Coordinate location of the point on the polygon.
 o getMidPoint
 public static Coordinate getMidPoint(Coordinate c1,
                                      Coordinate c2,
                                      double ratio)
Returns the convex sum of 2 locations.

Parameters:
c1 - a location.
c2 - a location.
ration - the convex ratio of c1 & c2.
Returns:
ratio*c1+(1-ratio)*c2.
 o getTriPoint
 public static Coordinate[] getTriPoint(Coordinate c1,
                                        double alpha,
                                        Coordinate c2,
                                        double beta) throws ArithmeticException
Returns the 2 possible locations of a point with the specified distances from 2 locations. if c1 & c2 represent equal locations and beta=alpha the return is the location with distance alpha and angle 0 from c1.

Parameters:
c1 - the first location.
alpha - the required distance from c1.
c2 - the second location.
beta - the requierd distance from c2.
Returns:
the locations with distances alpha from c1 & beta from c2.
Throws: ArithmeticException
if there is no valid location with the specified parameters.
 o getTriPointEx
 public static Coordinate getTriPointEx(Coordinate c1,
                                        double alpha,
                                        Coordinate c2,
                                        double beta,
                                        Coordinate reference,
                                        Coordinate secondReference) throws ArithmeticException
Returns a location of a point with the specified distances from 2 locations. The location returned is the closest to reference and secondReference in this order. a nil argument for these parameters will return one of the two possible solutions.

Parameters:
c1 - the first location.
alpha - the required distance from c1.
c2 - the second location.
beta - the requierd distance from c2.
reference - specifies a location to which to return the closest location of possible 2.
secondReference - used if two locations have equal distances from reference.
Returns:
the locations with distances alpha from c1 & beta from c2.
Throws: ArithmeticException
if there is no valid location with the specified parameters.
See Also:
getTriPoint
 o getAngle
 public static double getAngle(Coordinate p1,
                               Coordinate p2)
Returns the angle in radians between 2 coordinates.

Parameters:
p1 - a location.
p2 - a location.
Returns:
the angle in the direction from p1 to p2.
 o toRadian
 public static double toRadian(double Angle)
Converts degrees to radians.

Parameters:
Angle - an angle in degrees representation.
Returns:
a radian representaion of Angle by the formula:Math.PI*Angle/180.
 o toAngle
 public static double toAngle(double radian)
Converts radians to degrees.

Parameters:
radian - an angle in radian representation.
Returns:
a degrees representaion of radian by the formula:180*radian/Math.PI.
 o getStandartAngle
 public static double getStandartAngle(double angle)
Returns the corresponding argument value in the range 0-Math.PI*2

Parameters:
angle - the angle to convert.
Returns:
the corresponding argument value in the range 0-Math.PI*2.
 o modulo
 public static double modulo(double arg,
                             double mod)
return the positive mod of an argument.

Parameters:
arg - the value argument.
mod - the modolus argument.
Returns:
the positive argument of arg%mod.
 o drawJoint
 public static void drawJoint(Graphics g,
                              Point joint)
Draws a machine's joint.

Parameters:
g - Graphic object to draw on.
center - the center of the drawn joint.
 o drawAnchor
 public static void drawAnchor(Graphics g,
                               Point anchor)
Draws a machine's anchor.

Parameters:
g - Graphic object to draw on.
anchor - the center of the drawn joint.
 o polarToCartes
 public static Coordinate polarToCartes(Coordinate polar)
Converts polar coordinate to cartesian coordinate.

Parameters:
polar - a polar representation of the loction.
Returns:
the cartesian representation of polar.

All Packages  Class Hierarchy  This Package  Previous  Next  Index