Package org.joml
Class Planef
- java.lang.Object
-
- org.joml.Planef
-
- All Implemented Interfaces:
Externalizable,Serializable
public class Planef extends Object implements Externalizable
Represents a 3D plane using single-precision floating-point numbers.- Author:
- Kai Burjack
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description floataThe factorain the plane equationa*x + b*y + c*z + d = 0.floatbThe factorbin the plane equationa*x + b*y + c*z + d = 0.floatcThe factorcin the plane equationa*x + b*y + c*z + d = 0.floatdThe constantdin the plane equationa*x + b*y + c*z + d = 0.
-
Constructor Summary
Constructors Constructor Description Planef()Create a new undefinedPlanef.Planef(float a, float b, float c, float d)Create a newPlanefwith the plane equationa*x + b*y + c*z + d = 0.Planef(Planef source)Create a newPlanefas a copy of the givensource.Planef(Vector3fc point, Vector3fc normal)Planef(Vector3fc pointA, Vector3fc pointB, Vector3fc pointC)Create a newPlaneffrom the given three points lying on the plane.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatdistance(float x, float y, float z)Compute the signed distance between this plane and the given point.booleanequals(Object obj)static Vector4fequationFromPoints(float v0X, float v0Y, float v0Z, float v1X, float v1Y, float v1Z, float v2X, float v2Y, float v2Z, Vector4f dest)Compute the factorsa,b,canddin the plane equationa*x + b*y + c*z + d = 0from the three points(v0X, v0Y, v0Z),(v1X, v1Y, v1Z)and(v2X, v2Y, v2Z)on the plane, and write the values to thex,y,zandwcomponents, respectively, of the givendestvector.static Vector4fequationFromPoints(Vector3f v0, Vector3f v1, Vector3f v2, Vector4f dest)Compute the factorsa,b,canddin the plane equationa*x + b*y + c*z + d = 0from the given three points on the plane, and write the values to thex,y,zandwcomponents, respectively, of the givendestvector.inthashCode()Planefnormalize()Normalize this plane.Planefnormalize(Planef dest)Normalize this plane and store the result indest.voidreadExternal(ObjectInput in)Planefset(float a, float b, float c, float d)Set the components of this plane.StringtoString()Return a string representation of this plane.StringtoString(NumberFormat formatter)Return a string representation of this plane by formatting the components with the givenNumberFormat.voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
a
public float a
The factorain the plane equationa*x + b*y + c*z + d = 0.
-
b
public float b
The factorbin the plane equationa*x + b*y + c*z + d = 0.
-
c
public float c
The factorcin the plane equationa*x + b*y + c*z + d = 0.
-
d
public float d
The constantdin the plane equationa*x + b*y + c*z + d = 0.
-
-
Constructor Detail
-
Planef
public Planef()
Create a new undefinedPlanef.
-
Planef
public Planef(Planef source)
Create a newPlanefas a copy of the givensource.- Parameters:
source- thePlanefto copy from
-
Planef
public Planef(Vector3fc point, Vector3fc normal)
- Parameters:
point- any point lying on the planenormal- the normal of the plane
-
Planef
public Planef(Vector3fc pointA, Vector3fc pointB, Vector3fc pointC)
Create a newPlaneffrom the given three points lying on the plane.The resulting plane is not necessarily
normalized.- Parameters:
pointA- the first pointpointB- the second pointpointC- the third point
-
Planef
public Planef(float a, float b, float c, float d)Create a newPlanefwith the plane equationa*x + b*y + c*z + d = 0.- Parameters:
a- the x factor in the plane equationb- the y factor in the plane equationc- the z factor in the plane equationd- the constant in the plane equation
-
-
Method Detail
-
set
public Planef set(float a, float b, float c, float d)
Set the components of this plane.- Parameters:
a- the x factor in the plane equationb- the y factor in the plane equationc- the z factor in the plane equationd- the constant in the plane equation- Returns:
- this
-
normalize
public Planef normalize()
Normalize this plane.- Returns:
- this
-
normalize
public Planef normalize(Planef dest)
Normalize this plane and store the result indest.- Parameters:
dest- will hold the result- Returns:
- dest
-
distance
public float distance(float x, float y, float z)Compute the signed distance between this plane and the given point.- Parameters:
x- the x coordinate of the pointy- the y coordinate of the pointz- the z coordinate of the point- Returns:
- the signed distance between this plane and the point
-
equationFromPoints
public static Vector4f equationFromPoints(Vector3f v0, Vector3f v1, Vector3f v2, Vector4f dest)
Compute the factorsa,b,canddin the plane equationa*x + b*y + c*z + d = 0from the given three points on the plane, and write the values to thex,y,zandwcomponents, respectively, of the givendestvector.- Parameters:
v0- the first point on the planev1- the second point on the planev2- the third point on the planedest- will hold the result- Returns:
- dest
-
equationFromPoints
public static Vector4f equationFromPoints(float v0X, float v0Y, float v0Z, float v1X, float v1Y, float v1Z, float v2X, float v2Y, float v2Z, Vector4f dest)
Compute the factorsa,b,canddin the plane equationa*x + b*y + c*z + d = 0from the three points(v0X, v0Y, v0Z),(v1X, v1Y, v1Z)and(v2X, v2Y, v2Z)on the plane, and write the values to thex,y,zandwcomponents, respectively, of the givendestvector.- Parameters:
v0X- the x coordinate of the first point on the planev0Y- the y coordinate of the first point on the planev0Z- the z coordinate of the first point on the planev1X- the x coordinate of the second point on the planev1Y- the y coordinate of the second point on the planev1Z- the z coordinate of the second point on the planev2X- the x coordinate of the third point on the planev2Y- the y coordinate of the third point on the planev2Z- the z coordinate of the third point on the planedest- will hold the result- Returns:
- dest
-
toString
public String toString()
Return a string representation of this plane.This method creates a new
DecimalFormaton every invocation with the format string "0.000E0;-".
-
toString
public String toString(NumberFormat formatter)
Return a string representation of this plane by formatting the components with the givenNumberFormat.- Parameters:
formatter- theNumberFormatused to format the components with- Returns:
- the string representation
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-