Package com.ardor3d.math
Class LineSegment3
java.lang.Object
com.ardor3d.math.Line3Base
com.ardor3d.math.LineSegment3
- All Implemented Interfaces:
Poolable
,ReadOnlyLine3Base
,ReadOnlyLineSegment3
,Savable
,Externalizable
,Serializable
LineSegment describes a line with a discrete length with an "origin" in the center, extending in the given
"direction" and it's opposite by an "extent" amount.
- See Also:
-
Field Summary
Fields inherited from class com.ardor3d.math.Line3Base
_direction, _origin
-
Constructor Summary
ConstructorDescriptionConstructs a new segment segment with an origin at (0,0,0) a direction of (0,0,1) and an extent of 0.5.LineSegment3
(ReadOnlyLineSegment3 source) Copy constructor.LineSegment3
(ReadOnlyVector3 start, ReadOnlyVector3 end) Constructs a new segment segment using the supplied start and end pointsLineSegment3
(ReadOnlyVector3 origin, ReadOnlyVector3 direction, double extent) Constructs a new segment segment using the supplied origin point, unit length direction vector and extent -
Method Summary
Modifier and TypeMethodDescriptionclone()
double
distanceSquared
(ReadOnlyVector3 point, Vector3 store) boolean
static final LineSegment3
double
getNegativeEnd
(Vector3 store) getPositiveEnd
(Vector3 store) int
hashCode()
static boolean
isValid
(ReadOnlyLineSegment3 segment) Check a segment... if it is null or the values of its origin or direction or extent are NaN or infinite, return false.void
read
(InputCapsule capsule) void
Used with serialization.static final void
releaseTempInstance
(LineSegment3 segment) Releases a LineSegment3 back to be used by a future call to fetchTempInstance.set
(ReadOnlyLineSegment3 source) Copies the values of the given source segment into this segment.void
setExtent
(double extent) Sets the segment's extent to the provided value.toString()
void
write
(OutputCapsule capsule) void
Used with serialization.Methods inherited from class com.ardor3d.math.Line3Base
getClassTag, getDirection, getOrigin, setDirection, setOrigin
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.ardor3d.math.type.ReadOnlyLine3Base
getDirection, getOrigin
-
Field Details
-
_extent
protected double _extent
-
-
Constructor Details
-
LineSegment3
public LineSegment3()Constructs a new segment segment with an origin at (0,0,0) a direction of (0,0,1) and an extent of 0.5. -
LineSegment3
Copy constructor.- Parameters:
source
- the line segment to copy from.
-
LineSegment3
Constructs a new segment segment using the supplied origin point, unit length direction vector and extent- Parameters:
origin
- the origindirection
- the direction vector - unit lengthextent
- the extent
-
LineSegment3
Constructs a new segment segment using the supplied start and end points- Parameters:
start
- the start pointend
- the end point
-
-
Method Details
-
set
Copies the values of the given source segment into this segment.- Parameters:
source
- the line segment to copy from- Returns:
- this segment for chaining
- Throws:
NullPointerException
- if source is null.
-
getExtent
public double getExtent()- Specified by:
getExtent
in interfaceReadOnlyLineSegment3
- Returns:
- this segment's extent value
-
setExtent
public void setExtent(double extent) Sets the segment's extent to the provided value.- Parameters:
extent
- the extent
-
getPositiveEnd
-
getNegativeEnd
-
distanceSquared
- Specified by:
distanceSquared
in interfaceReadOnlyLine3Base
- Parameters:
point
- the pointstore
- if not null, the closest point is stored in this param- Returns:
- the squared distance from this segment to the given point.
- Throws:
NullPointerException
- if the point is null.
-
random
- Parameters:
store
- the object to store the result if not null- Returns:
- a random position lying somewhere on this line segment.
-
isValid
Check a segment... if it is null or the values of its origin or direction or extent are NaN or infinite, return false. Else return true.- Parameters:
segment
- the segment to check- Returns:
- true or false as stated above.
-
toString
-
equals
-
hashCode
public int hashCode() -
clone
- Specified by:
clone
in interfaceReadOnlyLineSegment3
- Overrides:
clone
in classObject
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classLine3Base
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classLine3Base
- Throws:
IOException
-
readExternal
Used with serialization. Not to be called manually.- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classLine3Base
- Parameters:
in
- ObjectInput- Throws:
IOException
- if something wrong occurs while readingClassNotFoundException
- if a class is not found
-
writeExternal
Used with serialization. Not to be called manually.- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classLine3Base
- Parameters:
out
- ObjectOutput- Throws:
IOException
- if something wrong occurs while writing
-
fetchTempInstance
- Returns:
- An instance of LineSegment3 that is intended for temporary use in calculations and so forth. Multiple calls to the method should return instances of this class that are not currently in use.
-
releaseTempInstance
Releases a LineSegment3 back to be used by a future call to fetchTempInstance. TAKE CARE: this LineSegment3 object should no longer have other classes referencing it or "Bad Things" will happen.- Parameters:
segment
- the LineSegment3 to release.
-