CH.ifa.draw.util
Class Geom
- java.lang.Object
-
- CH.ifa.draw.util.Geom
-
public class Geom extends java.lang.ObjectSome geometric utilities.
-
-
Field Summary
Fields Modifier and Type Field and Description static intEASTstatic intNORTHstatic intSOUTHstatic intWEST
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.awt.PointangleToPoint(java.awt.Rectangle r, double angle)Gets the point on a rectangle that corresponds to the given angle.static java.awt.Pointcenter(java.awt.Rectangle r)static intdirection(int x1, int y1, int x2, int y2)Returns the direction NORTH, SOUTH, WEST, EAST from one point to another one.static java.awt.Pointeast(java.awt.Rectangle r)static java.awt.Pointintersect(int xa, int ya, int xb, int yb, int xc, int yc, int xd, int yd)Standard line intersection algorithm Return the point of intersection if it exists, else nullstatic longlength(int x1, int y1, int x2, int y2)Gets the distance between to pointsstatic longlength2(int x1, int y1, int x2, int y2)Gets the square distance between two points.static booleanlineContainsPoint(int x1, int y1, int x2, int y2, int px, int py)Tests if a point is on a line.static java.awt.Pointnorth(java.awt.Rectangle r)static java.awt.PointovalAngleToPoint(java.awt.Rectangle r, double angle)Gets the point on an oval that corresponds to the given angle.static doublepointToAngle(java.awt.Rectangle r, java.awt.Point p)Gets the angle of a point relative to a rectangle.static java.awt.PointpolarToPoint(double angle, double fx, double fy)Converts a polar to a pointstatic intrange(int min, int max, int value)Constains a value to the given range.static java.awt.Pointsouth(java.awt.Rectangle r)static java.awt.Pointwest(java.awt.Rectangle r)
-
-
-
Field Detail
-
NORTH
public static final int NORTH
- See Also:
- Constant Field Values
-
SOUTH
public static final int SOUTH
- See Also:
- Constant Field Values
-
WEST
public static final int WEST
- See Also:
- Constant Field Values
-
EAST
public static final int EAST
- See Also:
- Constant Field Values
-
-
Method Detail
-
lineContainsPoint
public static boolean lineContainsPoint(int x1, int y1, int x2, int y2, int px, int py)Tests if a point is on a line.
-
direction
public static int direction(int x1, int y1, int x2, int y2)Returns the direction NORTH, SOUTH, WEST, EAST from one point to another one.
-
south
public static java.awt.Point south(java.awt.Rectangle r)
-
center
public static java.awt.Point center(java.awt.Rectangle r)
-
west
public static java.awt.Point west(java.awt.Rectangle r)
-
east
public static java.awt.Point east(java.awt.Rectangle r)
-
north
public static java.awt.Point north(java.awt.Rectangle r)
-
range
public static int range(int min, int max, int value)Constains a value to the given range.- Returns:
- the constrained value
-
length2
public static long length2(int x1, int y1, int x2, int y2)Gets the square distance between two points.
-
length
public static long length(int x1, int y1, int x2, int y2)Gets the distance between to points
-
pointToAngle
public static double pointToAngle(java.awt.Rectangle r, java.awt.Point p)Gets the angle of a point relative to a rectangle.
-
angleToPoint
public static java.awt.Point angleToPoint(java.awt.Rectangle r, double angle)Gets the point on a rectangle that corresponds to the given angle.
-
polarToPoint
public static java.awt.Point polarToPoint(double angle, double fx, double fy)Converts a polar to a point
-
ovalAngleToPoint
public static java.awt.Point ovalAngleToPoint(java.awt.Rectangle r, double angle)Gets the point on an oval that corresponds to the given angle.
-
intersect
public static java.awt.Point intersect(int xa, int ya, int xb, int yb, int xc, int yc, int xd, int yd)Standard line intersection algorithm Return the point of intersection if it exists, else null
-
-
DataMelt 3.0 © DataMelt by jWork.ORG