Package jmri.util
Class MathUtil
java.lang.Object
jmri.util.MathUtil
Useful math methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Point2Dstatic final Rectangle2Dstatic final Point2Dstatic final Rectangle2Dstatic final Rectangle2D -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleabsDiffAngleDEG(double a, double b) Calculate the absolute difference (0-180) between two angles.static doubleabsDiffAngleRAD(double a, double b) Calculate the absolute difference (0-PI) between two angles.static Point2DAdd two points.static Point2DCalculate the center of the rectangle.static Rectangle2DCenter rectangle on point.static Rectangle2DCenter rectangle on rectangle.static doubleCompute the angle (direction in degrees) for a vector.static doublecomputeAngleDEG(Point2D p1, Point2D p2) Compute the angle (direction in degrees) from point 1 to point 2.static doubleCompute the angle (direction in radians) for a vector.static doublecomputeAngleRAD(Point2D p1, Point2D p2) Compute the angle (direction in radians) from point 1 to point 2.convexHull(List<Point2D> points) compute convex hull (outline of polygon)static doublediffAngleDEG(double a, double b) Calculate the relative difference (+/-180) between two angles.static doublediffAngleRAD(double a, double b) Calculate the relative difference (+/-PI) between two angles.static StringAn I18N string to represent a Dimension.static doubleCalculate the distance between two points.static doubleget (signed) distance p3 is from line segment defined by p1 and p2static Point2DDivide a point by a scalar.static Point2DDivide a point by two scalars.static doubleDot product of two points (vectors).static doubledrawBezier(Graphics2D g2, Point2D[] p) Draw a Bezier curve.static doubledrawBezier(Graphics2D g2, Point2D[] p, double displacement) Draw a Bezier curvestatic doubledrawBezier(Graphics2D g2, Point2D p0, Point2D p1, Point2D p2, Point2D p3) Draw a cubic Bezier curve.static booleanequals(double a, double b) static booleanequals(float a, float b) static booleanstatic booleanequals(Rectangle2D a, Rectangle2D b) static doublefillBezier(Graphics2D g2, Point2D[] p) Fill a Bezier curve.static doublefillBezier(Graphics2D g2, Point2D[] p, double displacement) Fill a Bezier curve.static intgcd(int a, int b) static Rectangle2DgetBezierBounds(Point2D[] p) computer the bounds of a Bezier curve.static GeneralPathgetBezierPath(Point2D[] p) Get the path for a Bezier curve.static GeneralPathgetBezierPath(Point2D[] p, double displacement) Get the path for a Bezier curve.static Point2DGet the origin (top left) of the rectangle.static DimensionGet the size of a rectangle.static doublegranulize(double v, double g) Round value to granular increment.static Point2DRound point to granular increment.static Point2DRound point to horizontal and vertical granular increments.static Rectangle2Dgranulize(Rectangle2D r, double g) Round Rectangle2D to granular increment.static Point2Dstatic Rectangle2Dstatic Rectangle2Dinset(Rectangle2D r, double i) Inset a rectangle by a single value.static Rectangle2Dinset(Rectangle2D r, double h, double v) Inset a rectangle by distinct x,y values.static Point2DFind intersection of two lines.static booleanisCounterClockWise(Point2D a, Point2D b, Point2D c) isCounterClockWisestatic booleanstatic booleanisPointInPolygon(Point2D pointT, List<Point2D> points) static doubleCalculate the length of a point (vector).static doubleCalculate the length squared of a point (vector).static doublelerp(double a, double b, double t) Calculate the linear interpolation between two doubles.static intlerp(int a, int b, double t) Calculate the linear interpolation between two integers.static Point2DCalculate the linear interpolation between two points.static DoubleCalculate the linear interpolation between two Doubles.static Point2DGet the maximum coordinates of two points.static Point2DCalculate the midpoint between two points.static Point2DCalculate the midpoint of the rectangle.static Point2Dreturn average point in pointsstatic Point2DGet the minimum coordinates of two points.static Point2DMultiply a scalar times a point.static Point2DMultiply a point times a scalar.static Point2DMultiply a point times two scalar.static Point2DMultiply a point times a point.static Point2DNormalize a point (vector).static Point2DNormalize a point (vector) to a length.static doublenormalizeAngleDEG(double a) Wrap an angle between 0 and 360.static Point2DOffset a point by two scalars.static Rectangle2Doffset(Rectangle2D r, double x, double y) Offset a rectangle by distinct x,y values.static Rectangle2Doffset(Rectangle2D r, Point2D o) Offset a rectangle by a single value.static Point2DoneFourthPoint(Point2D pA, Point2D pB) Calculate the point 1/4 of the way between two points.static Point2DoneThirdPoint(Point2D pA, Point2D pB) Calculate the point 1/3 of the way between two points.static Point2Dstatic doublepin(double inValue, double inMin, double inMax) Pin a value between min and max.static intpin(int inValue, int inMin, int inMax) Pin a value between min and max.static Point2DGet the coordinates of a point pinned between two other points.static Point2Dpin(Point2D pA, Rectangle2D pR) Get the coordinates of a point pinned in a rectanglestatic PointConvert Point2D to Point.static Point2DConvert Point to Point2D.static RectangleConvert Rectangle2D to Rectangle.static StringReturn an I18N string to represent a rectangle.static Rectangle2DrectangleAtPoint(Point2D p, Double width, Double height) Get rectangle at point.static Rectangle2DConvert Rectangle to Rectangle2D.static Point2DrotateDEG(double x, double y, double a) Rotate x and y coordinates (by degrees).static Point2DRotate a point (by degrees).static Point2DRotate a point around another point (by degrees).static Point2DrotateRAD(double x, double y, double a) Rotate x and y coordinates (by radians).static Point2DRotate a point (by radians).static Point2DRotate a point around another point (by radians).static Rectangle2Dscale(Rectangle2D r, double s) Scale a rectangle.static Rectangle2DsetOrigin(Rectangle2D r, Point2D origin) Set the origin (top left) of the rectangle.static Rectangle2DsetSize(Rectangle2D r, Dimension d) Set the size of a rectanglestatic Rectangle2DsetSize(Rectangle2D r, Point2D s) Set the size of a rectanglestatic Point2DSubtract two points.static Point2DthreeFourthsPoint(Point2D pA, Point2D pB) Calculate the point 3/4 of the way between two points.static Point2DtwoThirdsPoint(Point2D pA, Point2D pB) Calculate the point 2/3 of the way between two points.static Point2DvectorDEG(double dirDEG, double magnitude) Create a vector given a direction and a magnitude.static Point2DvectorRAD(double dirRAD, double magnitude) Create a vector given a direction and a magnitude.static doublewrap(double inValue, double inMin, double inMax) Wrap a double between two values (for example +/- 180 or 0-360 degrees).static intwrap(int inValue, int inMin, int inMax) Wrap an int between two values (for example +/- 180 or 0-360 degrees).static doublewrap360(double inValue) Wrap a value between 0 and 360.static doublewrapPM180(double inValue) Wrap a value between +/-180.static doublewrapPM360(double inValue) Wrap a value between +/-360.static Point2Dstatic Rectangle2Dstatic Rectangle2D
-
Field Details
-
zeroPoint2D
-
infinityPoint2D
-
zeroRectangle2D
-
zeroToInfinityRectangle2D
-
infinityRectangle2D
-
-
Method Details
-
zeroPoint2D
- Returns:
- the point {0, 0}
-
infinityPoint2D
- Returns:
- the point {POSITIVE_INFINITY, POSITIVE_INFINITY}
-
gcd
- Parameters:
a- the first numberb- the second number- Returns:
- the greatest common divisor of a and b
-
pointToPoint2D
Convert Point to Point2D.- Parameters:
p- the Point- Returns:
- the Point2D
-
point2DToPoint
Convert Point2D to Point.- Parameters:
p- the Point- Returns:
- the Point2D
-
equals
- Parameters:
a- the first floatb- the second float- Returns:
- true if a is equal to b
-
equals
- Parameters:
a- the first doubleb- the second double- Returns:
- true if a is equal to b
-
equals
- Parameters:
a- the first Rectangle2Db- the second Rectangle2D- Returns:
- true if a is equal to b
-
equals
- Parameters:
a- the first Point2Db- the second Point2D- Returns:
- true if a is equal to b
-
isEqualToZeroPoint2D
- Parameters:
p- the point- Returns:
- true if p1 is equal to zeroPoint2D
-
min
Get the minimum coordinates of two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the minimum coordinates
-
max
Get the maximum coordinates of two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the maximum coordinates
-
pin
@CheckReturnValue public static Point2D pin(@Nonnull Point2D pA, @Nonnull Point2D pB, @Nonnull Point2D pC) Get the coordinates of a point pinned between two other points.- Parameters:
pA- the first pointpB- the second pointpC- the third point- Returns:
- the coordinates of pA pined between pB and pC
-
pin
Get the coordinates of a point pinned in a rectangle- Parameters:
pA- the pointpR- the rectangle- Returns:
- the coordinates of point pA pined in rectangle pR
-
add
Add two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the sum of the two points
-
subtract
Subtract two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the difference of the two points
-
multiply
Multiply a point times a scalar.- Parameters:
p- the points- the scalar- Returns:
- the point multiplied by the scalar
-
multiply
Multiply a point times two scalar.- Parameters:
p- the pointx- the X scalary- the Y scalar- Returns:
- the point multiplied by the two scalars
-
multiply
Multiply a scalar times a point.- Parameters:
s- the scalarp- the point- Returns:
- the point multiplied by the scalar
-
multiply
Multiply a point times a point.- Parameters:
p1- the first pointp2- the second point- Returns:
- the first point multiplied by the second
-
divide
Divide a point by a scalar.- Parameters:
p- the points- the scalar- Returns:
- the point divided by the scalar
-
divide
Divide a point by two scalars.- Parameters:
p- the pointx- the X scalary- the Y scalar- Returns:
- the point divided by the scalar
-
offset
Offset a point by two scalars.- Parameters:
p- the pointx- the x scalary- the y scalar- Returns:
- the point offset by the scalars
-
rotateRAD
Rotate x and y coordinates (by radians).- Parameters:
x- the x coordinatey- the y coordinatea- the angle (in radians)- Returns:
- the point rotated by the angle
-
rotateDEG
Rotate x and y coordinates (by degrees).- Parameters:
x- the x coordinatey- the y coordinatea- the angle (in radians)- Returns:
- the point rotated by the angle
-
rotateRAD
Rotate a point (by radians).- Parameters:
p- the pointa- the angle (in radians)- Returns:
- the point rotated by the angle
-
rotateDEG
Rotate a point (by degrees).- Parameters:
p- the pointa- the angle (in radians)- Returns:
- the point rotated by the angle
-
rotateRAD
@CheckReturnValue public static Point2D rotateRAD(@Nonnull Point2D p, @Nonnull Point2D c, double aRAD) Rotate a point around another point (by radians).- Parameters:
p- the point being rotatedc- the point its being rotated aroundaRAD- the angle (in radians)- Returns:
- the point rotated by the angle
-
rotateDEG
@CheckReturnValue public static Point2D rotateDEG(@Nonnull Point2D p, @Nonnull Point2D c, double aDEG) Rotate a point around another point (by degrees).- Parameters:
p- the point being rotatedc- the point its being rotated aroundaDEG- the angle (in radians)- Returns:
- the point rotated by the angle
-
orthogonal
- Parameters:
p- the point- Returns:
- the point orthogonal to this one (relative to {0, 0})
-
vectorDEG
Create a vector given a direction and a magnitude.- Parameters:
dirDEG- the direction (in degrees)magnitude- the magnitude- Returns:
- the vector with the specified direction and magnitude
-
vectorRAD
Create a vector given a direction and a magnitude.- Parameters:
dirRAD- the direction (in radians)magnitude- the magnitude- Returns:
- the vector with the specified direction and magnitude
-
dot
Dot product of two points (vectors).- Parameters:
pA- the first pointpB- the second point- Returns:
- the dot product of the two points note: Arccos(x) (inverse cosine) of dot product is the angle between the vectors
-
lengthSquared
Calculate the length squared of a point (vector).- Parameters:
p- the point (vector)- Returns:
- the length squared of the point (vector)
-
length
Calculate the length of a point (vector).- Parameters:
p- the point (vector)- Returns:
- the length of the point (vector)
-
distance
Calculate the distance between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the distance between the two points
-
normalize
Normalize a point (vector) to a length.- Parameters:
p- the point (vector)length- the length to normalize to- Returns:
- the normalized point (vector)
-
normalize
Normalize a point (vector).- Parameters:
p- the point (vector)- Returns:
- the normalized point (vector)
-
computeAngleRAD
Compute the angle (direction in radians) for a vector.- Parameters:
p- the vector (point relative to zeroPoint2D)- Returns:
- the angle in radians
-
computeAngleDEG
Compute the angle (direction in degrees) for a vector.- Parameters:
p- the vector (point relative to zeroPoint2D)- Returns:
- the angle in degrees
-
computeAngleRAD
Compute the angle (direction in radians) from point 1 to point 2.Note: Goes CCW from south to east to north to west, etc. For JMRI subtract from PI/2 to get east, south, west, north
- Parameters:
p1- the first Point2Dp2- the second Point2D- Returns:
- the angle in radians
-
computeAngleDEG
Compute the angle (direction in degrees) from point 1 to point 2.Note: Goes CCW from south to east to north to west, etc. For JMRI subtract from 90.0 to get east, south, west, north
- Parameters:
p1- the first Point2Dp2- the second Point2D- Returns:
- the angle in degrees
-
lerp
Calculate the linear interpolation between two integers.- Parameters:
a- the first numberb- the second numbert- the fraction (between 0 and 1)- Returns:
- the linear interpolation between a and b for t
-
lerp
Calculate the linear interpolation between two doubles.- Parameters:
a- the first numberb- the second numbert- the fraction (between 0 and 1)- Returns:
- the linear interpolation between a and b for t
-
lerp
@CheckReturnValue public static Double lerp(@Nonnull Double a, @Nonnull Double b, @Nonnull Double t) Calculate the linear interpolation between two Doubles.- Parameters:
a- the first numberb- the second numbert- the fraction (between 0 and 1)- Returns:
- the linear interpolation between a and b for t
-
lerp
Calculate the linear interpolation between two points.- Parameters:
pA- the first pointpB- the second pointt- the fraction (between 0 and 1)- Returns:
- the linear interpolation between a and b for t
-
granulize
Round value to granular increment.- Parameters:
v- the value to granulizeg- the granularity- Returns:
- the value granulized to the granularity
-
granulize
Round point to horizontal and vertical granular increments.- Parameters:
p- the point to granulizegH- the horizontal granularitygV- the vertical granularity- Returns:
- the point granulized to the granularity
-
granulize
Round point to granular increment.- Parameters:
p- the point to granulizeg- the granularity- Returns:
- the point granulized to the granularity
-
granulize
Round Rectangle2D to granular increment.- Parameters:
r- the rectangle to granulizeg- the granularity- Returns:
- the rectangle granulized to the granularity
-
midPoint
Calculate the midpoint between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the midpoint between the two points
-
oneThirdPoint
Calculate the point 1/3 of the way between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the point one third of the way from pA to pB
-
twoThirdsPoint
Calculate the point 2/3 of the way between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the point two thirds of the way from pA to pB
-
oneFourthPoint
Calculate the point 1/4 of the way between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the point one fourth of the way from pA to pB
-
threeFourthsPoint
Calculate the point 3/4 of the way between two points.- Parameters:
pA- the first pointpB- the second point- Returns:
- the point three fourths of the way from pA to pB
-
wrap
Wrap an int between two values (for example +/- 180 or 0-360 degrees).- Parameters:
inValue- the valueinMin- the lowest valueinMax- the highest value- Returns:
- the value wrapped between the lowest and highest values Note: THIS IS NOT A PIN OR TRUNCATE; VALUES WRAP AROUND BETWEEN MIN AND MAX (And yes, this works correctly with negative numbers)
-
wrap
Wrap a double between two values (for example +/- 180 or 0-360 degrees).- Parameters:
inValue- the valueinMin- the lowest valueinMax- the highest value- Returns:
- the value wrapped between the lowest and highest values Note: THIS IS NOT A PIN OR TRUNCATE; VALUES WRAP AROUND BETWEEN MIN AND MAX (And yes, this works correctly with negative numbers)
-
wrapPM180
Wrap a value between +/-180.- Parameters:
inValue- the value- Returns:
- the value wrapped between -180 and +180
-
wrapPM360
Wrap a value between +/-360.- Parameters:
inValue- the value- Returns:
- the value wrapped between -360 and +360
-
wrap360
Wrap a value between 0 and 360.- Parameters:
inValue- the value- Returns:
- the value wrapped between -360 and +360
-
normalizeAngleDEG
Wrap an angle between 0 and 360.- Parameters:
a- the angle- Returns:
- the angle wrapped between 0 and 360
-
diffAngleDEG
Calculate the relative difference (+/-180) between two angles.- Parameters:
a- the first angleb- the second angle- Returns:
- the relative difference between the two angles (in degrees)
-
absDiffAngleDEG
Calculate the absolute difference (0-180) between two angles.- Parameters:
a- the first angleb- the second angle- Returns:
- the absolute difference between the two angles (in degrees)
-
diffAngleRAD
Calculate the relative difference (+/-PI) between two angles.- Parameters:
a- the first angleb- the second angle- Returns:
- the relative difference between the two angles (in radians)
-
absDiffAngleRAD
Calculate the absolute difference (0-PI) between two angles.- Parameters:
a- the first angleb- the second angle- Returns:
- the absolute difference between the two angles (in radians)
-
pin
Pin a value between min and max.- Parameters:
inValue- the valueinMin- the mininMax- the max- Returns:
- the value pinned between the min and max values
-
pin
Pin a value between min and max.- Parameters:
inValue- the valueinMin- the mininMax- the max- Returns:
- the value pinned between the min and max values
-
zeroRectangle2D
- Returns:
- a new rectangle {0.0, 0.0, 0.0, 0.0}
-
zeroToInfinityRectangle2D
- Returns:
- a new rectangle {0.0, 0.0, POSITIVE_INFINITY, POSITIVE_INFINITY}
-
infinityRectangle2D
- Returns:
- a new rectangle {NEGATIVE_INFINITY, NEGATIVE_INFINITY, POSITIVE_INFINITY, POSITIVE_INFINITY}
-
rectangle2DToString
Return an I18N string to represent a rectangle.- Parameters:
r- the rectangle2D- Returns:
- the string
-
rectangleToRectangle2D
Convert Rectangle to Rectangle2D.- Parameters:
r- the Rectangle- Returns:
- the Rectangle2D
-
rectangle2DToRectangle
Convert Rectangle2D to Rectangle.- Parameters:
r- the Rectangle- Returns:
- the Rectangle2D
-
getOrigin
Get the origin (top left) of the rectangle.- Parameters:
r- the rectangle- Returns:
- the origin of the rectangle
-
setOrigin
@CheckReturnValue public static Rectangle2D setOrigin(@Nonnull Rectangle2D r, @Nonnull Point2D origin) Set the origin (top left) of the rectangle.- Parameters:
r- the rectangleorigin- the origin- Returns:
- a new rectangle with the new origin
-
dimensionToString
An I18N string to represent a Dimension.- Parameters:
d- the Dimension- Returns:
- the string
-
getSize
Get the size of a rectangle.- Parameters:
r- the rectangle- Returns:
- the size of the rectangle
-
setSize
Set the size of a rectangle- Parameters:
r- the rectangled- the new size (as dimension)- Returns:
- a new rectangle with the new size
-
setSize
Set the size of a rectangle- Parameters:
r- the rectangles- the new size (as Point2D)- Returns:
- a new rectangle with the new size
-
center
Calculate the center of the rectangle.- Parameters:
r- the rectangle- Returns:
- the center of the rectangle
-
midPoint
Calculate the midpoint of the rectangle.- Parameters:
r- the rectangle- Returns:
- the midpoint of the rectangle
-
offset
Offset a rectangle by distinct x,y values.- Parameters:
r- the rectanglex- the horizontal offsety- the vertical offset- Returns:
- the offset rectangle
-
offset
Offset a rectangle by a single value.- Parameters:
r- the rectangleo- the offset- Returns:
- the offset rectangle
-
inset
Inset a rectangle by a single value.- Parameters:
r- the rectanglei- the inset (positive make it smaller, negative, bigger)- Returns:
- the inset rectangle
-
inset
Inset a rectangle by distinct x,y values.- Parameters:
r- the rectangleh- the horzontial inset (positive make it smaller, negative, bigger)v- the vertical inset (positive make it smaller, negative, bigger)- Returns:
- the inset rectangle
-
scale
Scale a rectangle.- Parameters:
r- the rectangles- the scale- Returns:
- the scaled rectangle
-
centerRectangleOnPoint
@CheckReturnValue public static Rectangle2D centerRectangleOnPoint(@Nonnull Rectangle2D r, @Nonnull Point2D p) Center rectangle on point.- Parameters:
r- the rectanglep- the point- Returns:
- the Point2D
-
centerRectangleOnRectangle
@CheckReturnValue public static Rectangle2D centerRectangleOnRectangle(@Nonnull Rectangle2D r1, @Nonnull Rectangle2D r2) Center rectangle on rectangle.- Parameters:
r1- the first rectangler2- the second rectangle- Returns:
- the first rectangle centered on the second
-
rectangleAtPoint
@CheckReturnValue public static Rectangle2D rectangleAtPoint(@Nonnull Point2D p, Double width, Double height) Get rectangle at point.- Parameters:
p- the pointwidth- the widthheight- the height- Returns:
- the rectangle
-
drawBezier
public static double drawBezier(@CheckForNull Graphics2D g2, @Nonnull Point2D p0, @Nonnull Point2D p1, @Nonnull Point2D p2, @Nonnull Point2D p3) Draw a cubic Bezier curve.- Parameters:
g2- the Graphics2D context to draw to (null if just want length)p0- origin control pointp1- first control pointp2- second control pointp3- terminating control point- Returns:
- the length of the Bezier curve
-
getBezierPath
Get the path for a Bezier curve.- Parameters:
p- control pointsdisplacement- right/left to draw a line parallel to the Bezier- Returns:
- the length of the Bezier curve
-
getBezierPath
Get the path for a Bezier curve.- Parameters:
p- control points- Returns:
- the length of the Bezier curve
-
drawBezier
public static double drawBezier(@CheckForNull Graphics2D g2, @Nonnull Point2D[] p, double displacement) Draw a Bezier curve- Parameters:
g2- the Graphics2D context to draw to (null to just return length)p- the control pointsdisplacement- right/left to draw a line parallel to the Bezier- Returns:
- the length of the Bezier curve
-
fillBezier
public static double fillBezier(@CheckForNull Graphics2D g2, @Nonnull Point2D[] p, double displacement) Fill a Bezier curve.- Parameters:
g2- the Graphics2D context to draw top- the control pointsdisplacement- right/left to draw a line parallel to the Bezier- Returns:
- the length of the Bezier curve
-
drawBezier
Draw a Bezier curve.- Parameters:
g2- the Graphics2D context to draw to (null to just return length)p- the control points- Returns:
- the length of the Bezier curve
-
fillBezier
Fill a Bezier curve.- Parameters:
g2- the Graphics2D context to draw to (null if just want length)p- the control points- Returns:
- the length of the Bezier curve
-
getBezierBounds
computer the bounds of a Bezier curve.- Parameters:
p- the control points- Returns:
- the bounds of the Bezier curve
-
intersect
@CheckReturnValue public static Point2D intersect(@Nonnull Point2D p1, @Nonnull Point2D p2, @Nonnull Point2D p3, @Nonnull Point2D p4) Find intersection of two lines.- Parameters:
p1- the first point on the first linep2- the second point on the first linep3- the first point on the second linep4- the second point on the second line- Returns:
- the intersection point of the two lines or null if one doesn't exist
-
distance
get (signed) distance p3 is from line segment defined by p1 and p2- Parameters:
p1- the first point on the line segmentp2- the second point on the line segmentp3- the point whose distance from the line segment you wish to calculate- Returns:
- the distance (note: plus/minus determines the (left/right) side of the line)
-
midPoint
return average point in points- Parameters:
points- to average- Returns:
- the average point
-
isPointInPolygon
- Parameters:
pointT- the pointpoints- the polygon- Returns:
- true if pointT is in the polygon made up of the points
-
convexHull
compute convex hull (outline of polygon)- Parameters:
points- of the polygon- Returns:
- points of the convex hull
-
isCounterClockWise
isCounterClockWise- Parameters:
a- the first pointb- the second pointc- the third point- Returns:
- true if the three points make a counter-clockwise turn
-