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
Constructors -
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()getAreturns the first point of the rectangle.getB()getBreturns the second point of the rectangle.getC()getCreturns the third point of the rectangle.random()randomreturns a random point within the plane defined by: A, B, C, and (B + C) - A.randomreturns a random point within the plane defined by: A, B, C, and (B + C) - A.voidread(JmeImporter importer) De-serialize this rectangle from the specified importer, for example when loading from a J3O file.voidsetAsets the first point of the rectangle.voidsetBsets the second point of the rectangle.voidsetCsets the third point of the rectangle.toString()Returns a string representation of the Recatangle, which is unaffected.voidwrite(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 newRectanglewith no defined corners. A, B, and C must be set to define a valid rectangle. -
Rectangle
Constructor creates a newRectanglewith 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
getAreturns the first point of the rectangle.- Returns:
- the first point of the rectangle.
-
setA
setAsets the first point of the rectangle.- Parameters:
a- the first point of the rectangle.
-
getB
getBreturns the second point of the rectangle.- Returns:
- the second point of the rectangle.
-
setB
setBsets the second point of the rectangle.- Parameters:
b- the second point of the rectangle.
-
getC
getCreturns the third point of the rectangle.- Returns:
- the third point of the rectangle.
-
setC
setCsets 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
normalor a new Vector3f)
-
random
randomreturns a random point within the plane defined by: A, B, C, and (B + C) - A.- Returns:
- a random point within the rectangle.
-
random
randomreturns 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:
writein 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:
readin 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)]
-