Package cnuphys.adaptiveSwim.geometry
Class Line
java.lang.Object
cnuphys.adaptiveSwim.geometry.Line
3D line of the form p(t) = po + t*dp where p(t) is a point on the line, po is
one point and dp = (p1-po) where p1 is another point. If this is an infinite
line, the t = [-infinity, infinity]. If this is a directed segment, t = [0,
1]
- Author:
- heddle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
distance
(double x, double y, double z) Get the shortest distance between this line (as an infinite line) and a pointdouble
Get the shortest distance between this line (as an infinite line) and a pointGet the center of the linegetDelP()
Get the p1-po "dP" segmentgetEndpoint
(int end) Get one of the endpointsgetP
(double t) Get a point on the linevoid
Get a point on the line (in place)getP0()
Get the po "start" point.getP1()
Get the p1 "end" point.static void
boolean
pointOnLine
(Point p) Decide whether a point is on the line using the constant TINY as the max distanceboolean
pointOnLine
(Point p, double maxDistance) Decide whether a point is on the linetoString()
Get a String representation
-
Constructor Details
-
Line
Create a line from two points on the line. If this is a directed line segment, the line will go from po to p1.- Parameters:
po
- one pointp1
- the other point
-
Line
public Line(double[] p1, double[] p2) Create a line from two ponts passed as arrays- Parameters:
p1
- one point as an xyz arrayp2
- another point as an xyz array
-
Line
Copy constructor- Parameters:
line
- the line to copy
-
Line
Create a line from the origing in the direction of a vector- Parameters:
v
- the vector
-
-
Method Details
-
getP0
Get the po "start" point. This is just an arbitrary point on an infinite line, but the starting point if this is a directed line segment- Returns:
- the "starting" point.
-
getDelP
Get the p1-po "dP" segment- Returns:
- dP = p1 - po
-
getEndpoint
Get one of the endpoints- Parameters:
end
- one of the Constants START or END- Returns:
- the requested endpoint
-
getP1
Get the p1 "end" point. This is just an arbitrary point on an infinite line, but the end point if this is a directed line segment- Returns:
- the "end" point.
-
getP
Get a point on the line- Parameters:
t
- the t parameter. If this is a directed line segment, t should be restricted to [0, 1]- Returns:
- a point on the line
-
getP
Get a point on the line (in place)- Parameters:
t
- the t parameter. If this is a directed line segment, t should be restricted to [0, 1]p
- upon return, a point on the line
-
distance
Get the shortest distance between this line (as an infinite line) and a point- Parameters:
p
- a point- Returns:
- the perpendicular distance
-
distance
public double distance(double x, double y, double z) Get the shortest distance between this line (as an infinite line) and a point- Parameters:
x
- the x coordinatey
- the y coordinatez
- the z coordinate- Returns:
- the perpendicular distance
-
pointOnLine
Decide whether a point is on the line- Parameters:
p
- the pointmaxDistance
- the max distance it can be off the line and still considered on the line- Returns:
true
if the point is considered on the line
-
pointOnLine
Decide whether a point is on the line using the constant TINY as the max distance- Parameters:
p
- the point- Returns:
true
if the point is considered on the line
-
toString
Get a String representation -
getCenter
Get the center of the line- Returns:
- the center of the line
-
main
-