java.lang.Object
org.jhotdraw8.geom.Lines
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublearcLength(double[] coords, int offset) static doublearcLength(double x1, double y1, double x2, double y2) Gets the distance between to pointsstatic doublearcLength(double x1, double y1, double x2, double y2, double t) Gets the arc length s at the given time t.static doubledistanceFromLine(double xa, double ya, double xb, double yb, double xc, double yc) compute distance of point from line segment, or Double.MAX_VALUE if perpendicular projection is outside segment; or If pts on line are same, return distance from pointstatic PointAndDerivativeeval(double[] a, int offset, double t) static PointAndDerivativeeval(double x0, double y0, double x1, double y1, double t) Evaluates the given curve at the specified time.static doubleinvArcLength(double[] p, int offset, double s) Computes time t at the given arc length s.static doubleinvArcLength(double x1, double y1, double x2, double y2, double s) Computes time t at the given arc length s.static booleanisCollinear(double a, double b, double m, double n, double x, double y) Returns true if the three points are collinear.static booleanisCollinear(double a, double b, double m, double n, double x, double y, double tolerance) static Point2D.Doublelerp(double[] a, int offset, double t) static doublelerp(double a, double b, double t) Linear interpolation fromatobatt.static Point2D.Doublelerp(double x0, double y0, double x1, double y1, double t) static Point2D.DoubleComputes the linear interpolation/extrapolation between two points.static voidsplit(double[] p, int o, double t, double @Nullable [] first, int offsetFirst, double @Nullable [] second, int offsetSecond) Splits the provided line into two parts.static voidsplit(double x0, double y0, double x1, double y1, double t, @Nullable DoubleConsumer2 first, @Nullable DoubleConsumer2 second) Splits the provided line into two parts.static doublesquaredDistanceFromLine(double xa, double ya, double xb, double yb, double xc, double yc) static voidsubLine(double[] p, int o, double t0, double t1, double[] first, int offsetFirst) Extracts a sub-line.
-
Constructor Details
-
Lines
public Lines()
-
-
Method Details
-
eval
Evaluates the given curve at the specified time.- Parameters:
x0- point P0 of the curvey0- point P0 of the curvex1- point P1 of the curvey1- point P1 of the curvet- the time- Returns:
- the point at time t
-
isCollinear
public static boolean isCollinear(double a, double b, double m, double n, double x, double y) Returns true if the three points are collinear.- Parameters:
a- x-coordinate of point 0b- y-coordinate of point 0m- x-coordinate of point 1n- y-coordinate of point 1x- x-coordinate of point 2y- y-coordinate of point 2- Returns:
- true if collinear
-
isCollinear
public static boolean isCollinear(double a, double b, double m, double n, double x, double y, double tolerance) -
distanceFromLine
public static double distanceFromLine(double xa, double ya, double xb, double yb, double xc, double yc) compute distance of point from line segment, or Double.MAX_VALUE if perpendicular projection is outside segment; or If pts on line are same, return distance from point- Parameters:
xa- the x-coordinate of point a on the lineya- the y-coordinate of point a on the linexb- the x-coordinate of point b on the lineyb- the y-coordinate of point b on the linexc- the x-coordinate of the point cyc- the y-coordinate of the point c- Returns:
- the distance from the line
-
squaredDistanceFromLine
public static double squaredDistanceFromLine(double xa, double ya, double xb, double yb, double xc, double yc) -
lerp
public static double lerp(double a, double b, double t) Linear interpolation fromatobatt.- Parameters:
a- ab- bt- a value in the range [0, 1]- Returns:
- the interpolated value
-
arcLength
public static double arcLength(double x1, double y1, double x2, double y2) Gets the distance between to points- Parameters:
x1- the x coordinate of point 1y1- the y coordinate of point 1x2- the x coordinate of point 2y2- the y coordinate of point 2- Returns:
- the distance between the two points
-
arcLength
public static double arcLength(double[] coords, int offset) -
arcLength
public static double arcLength(double x1, double y1, double x2, double y2, double t) Gets the arc length s at the given time t.- Parameters:
x1- the x coordinate of point 1y1- the y coordinate of point 1x2- the x coordinate of point 2y2- the y coordinate of point 2t- the time- Returns:
- arc length s at time t
-
invArcLength
public static double invArcLength(double x1, double y1, double x2, double y2, double s) Computes time t at the given arc length s.- Parameters:
x1- the x coordinate of point 1y1- the y coordinate of point 1x2- the x coordinate of point 2y2- the y coordinate of point 2s- arc length- Returns:
- t at s
-
invArcLength
public static double invArcLength(double[] p, int offset, double s) Computes time t at the given arc length s.- Parameters:
p- points of the lineoffset- index of the first point in arrayas- arc length- Returns:
- t at s
-
split
public static void split(double x0, double y0, double x1, double y1, double t, @Nullable DoubleConsumer2 first, @Nullable DoubleConsumer2 second) Splits the provided line into two parts.- Parameters:
x0- point 1 of the liney0- point 1 of the linex1- point 2 of the liney1- point 2 of the linet- where to splitfirst- if not null, accepts the curve from x1,y1 to t1second- if not null, accepts the curve from t1 to x2,y2
-
split
public static void split(double[] p, int o, double t, double @Nullable [] first, int offsetFirst, double @Nullable [] second, int offsetSecond) Splits the provided line into two parts. -
subLine
public static void subLine(double[] p, int o, double t0, double t1, double[] first, int offsetFirst) Extracts a sub-line. -
lerp
-
lerp
-
eval
-
lerp
Computes the linear interpolation/extrapolation between two points.- Parameters:
start- point aend- point bt- a value between [0, 1] defines the interpolation between a and b. Values outside this range yield an extrapolation.- Returns:
- the interpolated or extrapolated value
-