public final class Geometry extends Object
Constructor and Description |
---|
Geometry() |
Modifier and Type | Method and Description |
---|---|
static double |
computeAngle(double[] p0,
double[] p1,
double[] p2)
Find the angle between twree points.
|
static double[] |
computeCrossProduct(double[] v0,
double[] v1)
Compute the cross product (a vector) of two vectors.
|
static double |
computeDotProduct(double[] v0,
double[] v1)
Compute the dot product (a scalar) between two vectors.
|
static double[] |
computePointOnLine(double[] p0,
double[] p1,
double fractionFromP0)
Find the point on the line p0,p1 [x,y,z] a given fraction from p0.
|
static double[] |
computePointOnLine(double x0,
double y0,
double x1,
double y1,
double fractionFrom0)
Find the point on the line defined by x0,y0,x1,y1 a given fraction
from x0,y0.
|
static double |
computePolygonArea(double[] xy)
Compute the area of the specfied polygon.
|
static double |
computePolygonArea(double[] x,
double[] y)
Compute the area of the specfied polygon.
|
static double[] |
computePolygonCentroid(double[] x,
double[] y)
Compute centorid (center of gravity) of specified polygon.
|
static int[] |
createArrow(int[] x,
int[] y,
double length,
double angle,
double inset)
Create the geometry of an arrow.
|
static int[] |
createArrow(int x0,
int y0,
int x1,
int y1,
double length,
double angle,
double inset)
Create geometry for an arrow along the specified line and with
tip at x1,y1.
|
static double[] |
createCircle(double x0,
double y0,
double radius)
Create geometry for a circle.
|
static int[] |
createCircle(int x0,
int y0,
int radius)
Create geometry for a circle.
|
static double[] |
createEllipse(double x0,
double y0,
double dx,
double dy)
Create the geometry for an unrotated, unskewed ellipse.
|
static int[] |
createEllipse(int[] x,
int[] y)
Return the geometry of an ellipse based on its four top points.
|
static int[] |
createEllipse(int x0,
int y0,
int dx,
int dy)
Create the geometry for an unrotated, unskewed ellipse.
|
static double[] |
createRectangle(double x0,
double y0,
double width,
double height)
Create geometry for a rectangle.
|
static int[] |
createRectangle(int x0,
int y0,
int width,
int height)
Create geometry for a rectangle.
|
static int[] |
createSector(int x0,
int y0,
int radius,
double angle0,
double angle1)
Create the geometry of a sector of a circle.
|
static int[] |
createSector(int x0,
int y0,
int dx,
int dy,
double angle0,
double angle1)
Create the geometry of a sector of an ellipse.
|
static double[] |
createStar(double x0,
double y0,
double innerRadius,
double outerRadius,
int nArms)
Create geometry of a star.
|
static int[] |
createStar(int x0,
int y0,
int innerRadius,
int outerRadius,
int nArms)
Create geometry of a star.
|
static double[] |
createVector(double[] p0,
double[] p1)
Construct the vector specified by two points.
|
static double |
distance(int x0,
int y0,
int x1,
int y1,
int x,
int y)
Return distance bwetween the line defined by (x0,y0) and (x1,y1)
and the point (x,y).
|
static void |
extendLine(double[] p0,
double[] p1,
double toLength)
Extend a given line segment to a given length and holding the first
point of the line as fixed.
|
static void |
extendLine(double[] p0,
double[] p1,
double toLength,
double anchor)
Extend a given line segment to a specified length.
|
static double[] |
findLinePolygonIntersections(double[] x,
double[] y,
double x0,
double y0,
double x1,
double y1)
Find the intersections between a polygon and a straight line.
|
static int |
findLineSegmentIntersection(double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double[] intersection)
Compute the intersection between two line segments, or two lines
of infinite length.
|
static void |
findPolygonExtent(double[] x,
double[] y,
double[] z,
double[] xExtent,
double[] yExtent,
double[] zExtent)
Find the 3D extent of a polyline.
|
static void |
findPolygonExtent(int[] x,
int[] y,
int[] xExtent,
int[] yExtent)
Find the extent of a polygon.
|
static boolean |
findPolygonPosition(int[] x,
int[] y,
double length,
int[] position)
Return the x,y position at distance "length" into the given polyline.
|
static boolean |
isLineIntersectingLine(int x0,
int y0,
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Check if two line segments intersects.
|
static boolean |
isLineIntersectingRectangle(int lx0,
int ly0,
int lx1,
int ly1,
int x0,
int y0,
int x1,
int y1)
Check if a specified line intersects a specified rectangle.
|
static boolean |
isPointInsidePolygon(double[] x,
double[] y,
double pointX,
double pointY)
Check if a given point is inside a given (complex) polygon.
|
static boolean |
isPointInsidePolygon(int[] x,
int[] y,
int pointX,
int pointY)
Check if a given point is inside a given polygon.
|
static boolean |
isPointInsideRectangle(int x0,
int y0,
int x1,
int y1,
int x,
int y)
Check if a specified point is inside a specified rectangle.
|
static boolean |
isPolygonIntersectingRectangle(int[] x,
int[] y,
int x0,
int y0,
int x1,
int y1)
Check if a specified polygon intersects a specified rectangle.
|
static boolean |
isPolylineIntersectingRectangle(int[] x,
int[] y,
int x0,
int y0,
int x1,
int y1)
Check if a specified polyline intersects a specified rectangle.
|
static double |
length(double[] v)
Return the length of a vector.
|
static double |
length(double[] p0,
double[] p1)
Compute distance between two points.
|
static double |
length(double x0,
double y0,
double x1,
double y1)
Compute the length of the line from (x0,y0) to (x1,y1)
|
static double |
length(int[] x,
int[] y,
boolean isClosed)
Compute the length of a polyline.
|
static double |
length(int x0,
int y0,
int x1,
int y1)
Compute the length of the line from (x0,y0) to (x1,y1)
|
public static boolean isPointInsideRectangle(int x0, int y0, int x1, int y1, int x, int y)
x0,
- y0, x1, y1 Upper left and lower right corner of rectangle
(inclusive)x,y
- Point to check.public static boolean isPointInsidePolygon(double[] x, double[] y, double pointX, double pointY)
x,
- y Polygon.pointX,
- pointY Point to check.public static boolean isPointInsidePolygon(int[] x, int[] y, int pointX, int pointY)
x,
- y Polygon.pointX,
- pointY Point to check.public static double[] computePointOnLine(double[] p0, double[] p1, double fractionFromP0)
p0
- First coordinale of line [x,y,z].p0
- Second coordinale of line [x,y,z].fractionFromP0
- Point we are looking for coordinates ofp
- Coordinate of point we are looking forpublic static double[] computePointOnLine(double x0, double y0, double x1, double y1, double fractionFrom0)
x0,
- y0 First point defining the linex1,
- y1 Second point defining the linefractionFrom0
- Distance from (x0,y0)public static void extendLine(double[] p0, double[] p1, double toLength, double anchor)
p0,
- p1 Line segment to extend [x,y,z].toLength
- Length of new line segment.anchor
- Specifies the fixed point during extension.
If anchor is 0.0, p0 is fixed and p1 is adjusted.
If anchor is 1.0, p1 is fixed and p0 is adjusted.
If anchor is 0.5, the line is adjusted equally in each
direction and so on.public static void extendLine(double[] p0, double[] p1, double toLength)
p0,
- p1 Line segment to extend. p0 is fixed during extensionlength
- Length of new line segment.public static double length(double[] v)
v
- Vector to compute length of [x,y,z].public static double length(double[] p0, double[] p1)
p0,
- p1 Points to compute distance between [x,y,z].public static double length(int x0, int y0, int x1, int y1)
x0,
- y0 First line end point.x1,
- y1 Second line end point.public static double length(double x0, double y0, double x1, double y1)
x0,
- y0 First line end point.x1,
- y1 Second line end point.public static double length(int[] x, int[] y, boolean isClosed)
x,
- y Arrays of x,y coordinatesnPoints
- Number of elements in the above.isClosed
- True if this is a closed polygon, false otherwisepublic static double distance(int x0, int y0, int x1, int y1, int x, int y)
x0,
- y0 First point of line.x1,
- y1 Second point of line.x,
- y, Point to consider.public static double computeAngle(double[] p0, double[] p1, double[] p2)
p0,
- p1, p2 Three points finding angle between [x,y,z].public static double computeDotProduct(double[] v0, double[] v1)
v0,
- v1 Vectors to compute dot product between [x,y,z].public static double[] computeCrossProduct(double[] v0, double[] v1)
v0,
- v1 Vectors to compute cross product between [x,y,z].crossProduct
- Cross product of specified vectors [x,y,z].public static double[] createVector(double[] p0, double[] p1)
p0,
- p1 Points the construct vector between [x,y,z].public static boolean isLineIntersectingLine(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
x0,
- y0, x1, y1 End points of first line to check.x2,
- yy, x3, y3 End points of second line to check.public static boolean isLineIntersectingRectangle(int lx0, int ly0, int lx1, int ly1, int x0, int y0, int x1, int y1)
lx0,
- ly0 1st end point of linely1,
- ly1 2nd end point of linex0,
- y0, x1, y1 Upper left and lower right corner of rectangle
(inclusive).public static boolean isPolylineIntersectingRectangle(int[] x, int[] y, int x0, int y0, int x1, int y1)
x,
- y Polyline to check.x0,
- y0, x1, y1 Upper left and lower left corner of rectangle
(inclusive).public static boolean isPolygonIntersectingRectangle(int[] x, int[] y, int x0, int y0, int x1, int y1)
x
- X coordinates of polyline.y
- Y coordinates of polyline.x0
- X of upper left corner of rectangle.y0
- Y of upper left corner of rectangle.x1
- X of lower right corner of rectangle.y1
- Y of lower right corner of rectangle.public static double computePolygonArea(double[] x, double[] y)
x
- X coordinates of polygon.y
- Y coordinates of polygon.public static double computePolygonArea(double[] xy)
xy
- Geometry of polygon [x,y,...]public static double[] computePolygonCentroid(double[] x, double[] y)
x
- X coordinates of polygon.y
- Y coordinates of polygon.public static void findPolygonExtent(double[] x, double[] y, double[] z, double[] xExtent, double[] yExtent, double[] zExtent)
x
- X coordinates of polyline.y
- Y coordinates of polyline.z
- Z coordinates of polyline.
May be null if this is a 2D case.xExtent
- Will upon return contain [xMin,xMax].yExtent
- Will upon return contain [xMin,xMax].zExtent
- Will upon return contain [xMin,xMax]. Unused (may be
set to null) if z is null.public static void findPolygonExtent(int[] x, int[] y, int[] xExtent, int[] yExtent)
x
- X coordinates of polygon.y
- Y coordinates of polygon.xExtent
- Will upon return contain [xMin, xMax]yExtent
- Will upon return contain [yMin, yMax]public static int findLineSegmentIntersection(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double[] intersection)
x0
- X coordinate first end point first line segment.y0
- Y coordinate first end point first line segment.x1
- X coordinate second end point first line segment.y1
- Y coordinate second end point first line segment.x2
- X coordinate first end point second line segment.y2
- Y coordinate first end point second line segment.x3
- X coordinate second end point second line segment.y3
- Y coordinate second end point second line segment.intersection[2]
- Preallocated by caller to double[2]public static double[] findLinePolygonIntersections(double[] x, double[] y, double x0, double y0, double x1, double y1)
x
- X coordinates of polygon.y
- Y coordinates of polygon.x0
- X first end point of line.x0
- Y first end point of line.x0
- X second end point of line.x0
- Y second end point of line.public static int[] createEllipse(int[] x, int[] y)
x
- X array of four top points of ellipse.y
- Y array of four top points of ellipse.public static int[] createEllipse(int x0, int y0, int dx, int dy)
x0
- X center of ellipse.y0
- Y center of ellipse.dx
- X ellipse radius.dy
- Y ellipse radius.public static double[] createEllipse(double x0, double y0, double dx, double dy)
x0
- X center of ellipse.y0
- Y center of ellipse.dx
- X ellipse radius.dy
- Y ellipse radius.public static int[] createCircle(int x0, int y0, int radius)
x0
- X center of circle.y0
- Y center of circle.radius
- Radius of circle.public static double[] createCircle(double x0, double y0, double radius)
x0
- X center of circle.y0
- Y center of circle.radius
- Radius of circle.public static int[] createSector(int x0, int y0, int dx, int dy, double angle0, double angle1)
x0
- X coordinate of center of ellipse.y0
- Y coordinate of center of ellipse.dx
- X radius of ellipse.dy
- Y radius of ellipse.angle0
- First angle of sector (in radians).angle1
- Second angle of sector (in radians).public static int[] createSector(int x0, int y0, int radius, double angle0, double angle1)
x0
- X coordinate of center of ellipse.y0
- Y coordinate of center of ellipse.dx
- X radius of ellipse.dy
- Y radius of ellipse.angle0
- First angle of sector (in radians).angle1
- Second angle of sector (in radians).public static int[] createArrow(int[] x, int[] y, double length, double angle, double inset)
x
- X coordinates of polyline of where arrow is positioned
in the end. Must contain at least two points.y
- Y coordinates of polyline of where arrow is positioned
in the end.length
- Length along the main axis from point 1 to the
projection of point 0.angle
- Angle between the main axis and the line 1,0
(and 1,2) in radians.inset
- Specification of point 3 [0.0-1.0], 1.0 will put
point 3 at distance length from 1, 0.0 will put it
at point 1.public static int[] createArrow(int x0, int y0, int x1, int y1, double length, double angle, double inset)
x0
- X first end point of line.y0
- Y first end point of line.x1
- X second end point of line.y1
- Y second end point of line.length
- Length along the main axis from point 1 to the
projection of point 0.angle
- Angle between the main axis and the line 1,0
(and 1.2)inset
- Specification of point 3 [0.0-1.0], 1.0 will put
point 3 at distance length from 1, 0.0 will put it
at point 1.public static int[] createRectangle(int x0, int y0, int width, int height)
x0
- X corner of rectangle.y0
- Y corner of rectangle.width
- Width (may be negative to indicate leftwards direction)height
- Height (may be negative to indicaten upwards direction)public static double[] createRectangle(double x0, double y0, double width, double height)
x0
- X corner of rectangle.y0
- Y corner of rectangle.width
- Width (may be negative to indicate leftwards direction)height
- Height (may be negative to indicaten upwards direction)public static int[] createStar(int x0, int y0, int innerRadius, int outerRadius, int nArms)
x0
- X center of star.y0
- Y center of star.innerRadius
- Inner radis of arms.outerRadius
- Outer radius of arms.nArms
- Number of arms.public static double[] createStar(double x0, double y0, double innerRadius, double outerRadius, int nArms)
x0
- X center of star.y0
- Y center of star.innerRadius
- Inner radis of arms.outerRadius
- Outer radius of arms.nArms
- Number of arms.public static boolean findPolygonPosition(int[] x, int[] y, double length, int[] position)
x
- X coordinates of polyliney
- Y coordinates of polylinelength
- Requested positionposition
- Preallocated to int[2]Jas4pp 1.5 © Java Analysis Studio for Particle Physics