public class LineSegment extends java.lang.Object implements java.lang.Cloneable, Savable, java.io.Serializable
LineSegment represents a segment in the space. This is a portion of a Line that has a limited start and end points.
A LineSegment is defined by an origin, a direction and an extent (or length). Direction should be a normalized vector. It is not internally normalized.
This class provides methods to calculate distances between LineSegments, Rays and Vectors.
It is also possible to retrieve both end points of the segment getPositiveEnd(Vector3f)
and getNegativeEnd(Vector3f)
. There are also methods to check whether
a point is within the segment bounds.
Ray
,
Serialized FormConstructor and Description |
---|
LineSegment() |
LineSegment(LineSegment ls) |
LineSegment(Vector3f start,
Vector3f end)
Creates a new LineSegment with a given origin and end.
|
LineSegment(Vector3f origin,
Vector3f direction,
float extent)
Creates a new LineSegment with the given origin, direction and extent.
|
Modifier and Type | Method and Description |
---|---|
LineSegment |
clone() |
float |
distance(LineSegment ls) |
float |
distance(Ray r) |
float |
distance(Vector3f point) |
float |
distanceSquared(LineSegment test) |
float |
distanceSquared(Ray r) |
float |
distanceSquared(Vector3f point) |
Vector3f |
getDirection() |
float |
getExtent() |
Vector3f |
getNegativeEnd(Vector3f store) |
Vector3f |
getOrigin() |
Vector3f |
getPositiveEnd(Vector3f store) |
boolean |
isPointInsideBounds(Vector3f point)
Evaluates whether a given point is contained within the axis aligned bounding box
that contains this LineSegment.
|
boolean |
isPointInsideBounds(Vector3f point,
float error)
Evaluates whether a given point is contained within the axis aligned bounding box
that contains this LineSegment.
|
void |
read(JmeImporter e) |
void |
set(LineSegment ls) |
void |
setDirection(Vector3f direction) |
void |
setExtent(float extent) |
void |
setOrigin(Vector3f origin) |
void |
write(JmeExporter e) |
public LineSegment()
public LineSegment(LineSegment ls)
public LineSegment(Vector3f origin, Vector3f direction, float extent)
Creates a new LineSegment with the given origin, direction and extent.
Note that the origin is not one of the ends of the LineSegment, but its center.
public void set(LineSegment ls)
public float distance(Vector3f point)
public float distance(LineSegment ls)
public float distance(Ray r)
public float distanceSquared(Vector3f point)
public float distanceSquared(LineSegment test)
public float distanceSquared(Ray r)
public Vector3f getDirection()
public void setDirection(Vector3f direction)
public float getExtent()
public void setExtent(float extent)
public Vector3f getOrigin()
public void setOrigin(Vector3f origin)
public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public LineSegment clone()
clone
in class java.lang.Object
public boolean isPointInsideBounds(Vector3f point)
Evaluates whether a given point is contained within the axis aligned bounding box that contains this LineSegment.
This function is float error aware.
public boolean isPointInsideBounds(Vector3f point, float error)
Evaluates whether a given point is contained within the axis aligned bounding box that contains this LineSegment.
This function accepts an error parameter, which is added to the extent of the bounding box.