public final class Rectangle extends java.lang.Object implements Savable, java.lang.Cloneable, java.io.Serializable
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.
Constructor and Description |
---|
Rectangle()
Constructor creates a new
Rectangle with no defined corners. |
Rectangle(Vector3f a,
Vector3f b,
Vector3f c)
Constructor creates a new
Rectangle with defined A, B, and C
points that define the area of the rectangle. |
Modifier and Type | Method and Description |
---|---|
Vector3f |
calculateD()
Returns the coordinates of the 4th corner, calculated by the formula
D = (B + C) - A .
|
Vector3f |
calculateNormal(Vector3f normal)
Returns a normal vector, calculated by the formula
|
Rectangle |
clone()
Create a copy of this rectangle.
|
Vector3f |
getA()
getA returns the first point of the rectangle. |
Vector3f |
getB()
getB returns the second point of the rectangle. |
Vector3f |
getC()
getC returns the third point of the rectangle. |
Vector3f |
random()
random returns a random point within the plane defined by:
A, B, C, and (B + C) - A. |
Vector3f |
random(Vector3f result)
random returns a random point within the plane defined by:
A, B, C, and (B + C) - A. |
void |
read(JmeImporter e)
De-serialize this rectangle from the specified importer, for example
when loading from a J3O file.
|
void |
setA(Vector3f a)
setA sets the first point of the rectangle. |
void |
setB(Vector3f b)
setB sets the second point of the rectangle. |
void |
setC(Vector3f c)
setC sets the third point of the rectangle. |
void |
write(JmeExporter e)
Serialize this rectangle to the specified exporter, for example when
saving to a J3O file.
|
public Rectangle()
Rectangle
with no defined corners.
A, B, and C must be set to define a valid rectangle.public Vector3f getA()
getA
returns the first point of the rectangle.public void setA(Vector3f a)
setA
sets the first point of the rectangle.a
- the first point of the rectangle.public Vector3f getB()
getB
returns the second point of the rectangle.public void setB(Vector3f b)
setB
sets the second point of the rectangle.b
- the second point of the rectangle.public Vector3f getC()
getC
returns the third point of the rectangle.public void setC(Vector3f c)
setC
sets the third point of the rectangle.c
- the third point of the rectangle.public Vector3f calculateD()
public Vector3f calculateNormal(Vector3f normal)
(C - B) x (B - A) N = ------------------- |(C - B) x (B - A)|
normal
- storage for the normal, or null for a new Vector3fnormal
or a new Vector3f)public Vector3f random()
random
returns a random point within the plane defined by:
A, B, C, and (B + C) - A.public Vector3f random(Vector3f result)
random
returns a random point within the plane defined by:
A, B, C, and (B + C) - A.result
- Vector to store result inpublic void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public Rectangle clone()
clone
in class java.lang.Object