Package com.jme3.math
Class Line
java.lang.Object
com.jme3.math.Line
- All Implemented Interfaces:
Savable
,Serializable
,Cloneable
Line
defines a line. Where a line is defined as infinite along
two points. The two points of the line are defined as the origin and direction.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Create a copy of this line.float
Calculate the distance from this line to the specified point.float
distanceSquared
(Vector3f point) Calculate the squared distance from this line to the specified point.getDirection
returns the direction of the line.getOrigin
returns the origin of the line.void
orthogonalLineFit
(FloatBuffer points) Fit this line to the specified points.random()
random
determines a random point along the line.random
determines a random point along the line.void
read
(JmeImporter importer) De-serialize this line from the specified importer, for example when loading from a J3O file.void
setDirection
(Vector3f direction) setDirection
sets the direction of the line.void
setOrigin
sets the origin of the line.toString()
Returns a string representation of the Line, which is unaffected.void
write
(JmeExporter e) Serialize this line to the specified exporter, for example when saving to a J3O file.
-
Constructor Details
-
Line
public Line()Constructor instantiates a newLine
object. The origin and direction both default to (0,0,0). -
Line
Constructor instantiates a newLine
object. The origin and direction are set via the parameters.- Parameters:
origin
- the origin of the line.direction
- the direction of the line.
-
-
Method Details
-
getOrigin
getOrigin
returns the origin of the line.- Returns:
- the origin of the line.
-
setOrigin
setOrigin
sets the origin of the line.- Parameters:
origin
- the origin of the line.
-
getDirection
getDirection
returns the direction of the line.- Returns:
- the direction of the line.
-
setDirection
setDirection
sets the direction of the line.- Parameters:
direction
- the direction of the line.
-
distanceSquared
Calculate the squared distance from this line to the specified point.- Parameters:
point
- location vector of the input point (not null, unaffected)- Returns:
- the square of the minimum distance (≥0)
-
distance
Calculate the distance from this line to the specified point.- Parameters:
point
- location vector of the input point (not null, unaffected)- Returns:
- the minimum distance (≥0)
-
orthogonalLineFit
Fit this line to the specified points.- Parameters:
points
- a buffer containing location vectors, or null
-
random
random
determines a random point along the line.- Returns:
- a random point on the line.
-
random
random
determines a random point along the line.- Parameters:
result
- Vector to store result in- Returns:
- a random point on the line.
-
write
Serialize this line to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfaceSavable
- Parameters:
e
- (not null)- Throws:
IOException
- from the exporter
-
read
De-serialize this line from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfaceSavable
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
clone
Create a copy of this line. -
toString
Returns a string representation of the Line, which is unaffected. For example, a line with origin (1,0,0) and direction (0,1,0) is represented by:Line [Origin: (1.0, 0.0, 0.0) Direction: (0.0, 1.0, 0.0)]
-