Package com.jme3.math
Class Rectangle
java.lang.Object
com.jme3.math.Rectangle
- All Implemented Interfaces:
Savable
,Serializable
,Cloneable
Rectangle
defines a finite plane within three-dimensional space
that is specified via three points (A, B, C). These three points define a
triangle with the fourth point defining the rectangle (B + C) - A.
The corner points are named as follows:
C +---+ D | | | | | | | | A +---+ B
If angle BAC isn't exactly 90 degrees, then the resulting shape is actually parallelogram, not a rectangle.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the coordinates of the 4th corner, calculated by the formula D = (B + C) - A .calculateNormal
(Vector3f normal) Returns a normal vector, calculated by the formulaclone()
Create a copy of this rectangle.getA()
getA
returns the first point of the rectangle.getB()
getB
returns the second point of the rectangle.getC()
getC
returns the third point of the rectangle.random()
random
returns a random point within the plane defined by: A, B, C, and (B + C) - A.random
returns a random point within the plane defined by: A, B, C, and (B + C) - A.void
read
(JmeImporter importer) De-serialize this rectangle from the specified importer, for example when loading from a J3O file.void
setA
sets the first point of the rectangle.void
setB
sets the second point of the rectangle.void
setC
sets the third point of the rectangle.toString()
Returns a string representation of the Recatangle, which is unaffected.void
write
(JmeExporter e) Serialize this rectangle to the specified exporter, for example when saving to a J3O file.
-
Constructor Details
-
Rectangle
public Rectangle()Constructor creates a newRectangle
with no defined corners. A, B, and C must be set to define a valid rectangle. -
Rectangle
Constructor creates a newRectangle
with defined A, B, and C points that define the area of the rectangle.- Parameters:
a
- the first corner of the rectangle.b
- the second corner of the rectangle.c
- the third corner of the rectangle.
-
-
Method Details
-
getA
getA
returns the first point of the rectangle.- Returns:
- the first point of the rectangle.
-
setA
setA
sets the first point of the rectangle.- Parameters:
a
- the first point of the rectangle.
-
getB
getB
returns the second point of the rectangle.- Returns:
- the second point of the rectangle.
-
setB
setB
sets the second point of the rectangle.- Parameters:
b
- the second point of the rectangle.
-
getC
getC
returns the third point of the rectangle.- Returns:
- the third point of the rectangle.
-
setC
setC
sets the third point of the rectangle.- Parameters:
c
- the third point of the rectangle.
-
calculateD
Returns the coordinates of the 4th corner, calculated by the formula D = (B + C) - A .- Returns:
- the corner location (a new Vector3f)
-
calculateNormal
Returns a normal vector, calculated by the formula(C - B) x (B - A) N = ------------------- |(C - B) x (B - A)|
- Parameters:
normal
- storage for the normal, or null for a new Vector3f- Returns:
- the normal direction (either
normal
or a new Vector3f)
-
random
random
returns a random point within the plane defined by: A, B, C, and (B + C) - A.- Returns:
- a random point within the rectangle.
-
random
random
returns a random point within the plane defined by: A, B, C, and (B + C) - A.- Parameters:
result
- Vector to store result in- Returns:
- a random point within the rectangle.
-
write
Serialize this rectangle 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 rectangle 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 rectangle. -
toString
Returns a string representation of the Recatangle, which is unaffected. For example, a rectangle with vertices at (1,0,0), (2,0,0), (1,2,0), and (2,2,0) is represented by:Rectangle [A: (1.0, 0.0, 0.0) B: (2.0, 0.0, 0.0) C: (1.0, 2.0, 0.0)]
-