Contents
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
-
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
-
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
-
getCenter
-
main
-