Package com.badlogic.gdx.math
Class Plane
- java.lang.Object
-
- com.badlogic.gdx.math.Plane
-
- All Implemented Interfaces:
java.io.Serializable
public class Plane extends java.lang.Object implements java.io.SerializableA plane defined via a unit length normal and the distance from the origin, as you learned in your math class.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlane.PlaneSideEnum specifying on which side a point lies respective to the plane and it's normal.
-
Constructor Summary
Constructors Constructor Description Plane()Constructs a new plane with all values set to 0Plane(Vector3 normal, float d)Constructs a new plane based on the normal and distance to the origin.Plane(Vector3 normal, Vector3 point)Constructs a new plane based on the normal and a point on the plane.Plane(Vector3 point1, Vector3 point2, Vector3 point3)Constructs a new plane out of the three given points that are considered to be on the plane.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatdistance(Vector3 point)Calculates the shortest signed distance between the plane and the given point.floatgetD()Vector3getNormal()booleanisFrontFacing(Vector3 direction)Returns whether the plane is facing the direction vector.voidset(float nx, float ny, float nz, float d)Sets the plane normal and distancevoidset(float pointX, float pointY, float pointZ, float norX, float norY, float norZ)voidset(Plane plane)Sets this plane from the given planevoidset(Vector3 point, Vector3 normal)Sets the plane to the given point and normal.voidset(Vector3 point1, Vector3 point2, Vector3 point3)Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane.Plane.PlaneSidetestPoint(float x, float y, float z)Returns on which side the given point lies relative to the plane and its normal.Plane.PlaneSidetestPoint(Vector3 point)Returns on which side the given point lies relative to the plane and its normal.java.lang.StringtoString()
-
-
-
Field Detail
-
normal
public final Vector3 normal
-
d
public float d
-
-
Constructor Detail
-
Plane
public Plane()
Constructs a new plane with all values set to 0
-
Plane
public Plane(Vector3 normal, float d)
Constructs a new plane based on the normal and distance to the origin.- Parameters:
normal- The plane normald- The distance to the origin
-
Plane
public Plane(Vector3 normal, Vector3 point)
Constructs a new plane based on the normal and a point on the plane.- Parameters:
normal- The normalpoint- The point on the plane
-
Plane
public Plane(Vector3 point1, Vector3 point2, Vector3 point3)
Constructs a new plane out of the three given points that are considered to be on the plane. The normal is calculated via a cross product between (point1-point2)x(point2-point3)- Parameters:
point1- The first pointpoint2- The second pointpoint3- The third point
-
-
Method Detail
-
set
public void set(Vector3 point1, Vector3 point2, Vector3 point3)
Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane. The normal is calculated via a cross product between (point1-point2)x(point2-point3)- Parameters:
point1-point2-point3-
-
set
public void set(float nx, float ny, float nz, float d)Sets the plane normal and distance- Parameters:
nx- normal x-componentny- normal y-componentnz- normal z-componentd- distance to origin
-
distance
public float distance(Vector3 point)
Calculates the shortest signed distance between the plane and the given point.- Parameters:
point- The point- Returns:
- the shortest signed distance between the plane and the point
-
testPoint
public Plane.PlaneSide testPoint(Vector3 point)
Returns on which side the given point lies relative to the plane and its normal. PlaneSide.Front refers to the side the plane normal points to.- Parameters:
point- The point- Returns:
- The side the point lies relative to the plane
-
testPoint
public Plane.PlaneSide testPoint(float x, float y, float z)
Returns on which side the given point lies relative to the plane and its normal. PlaneSide.Front refers to the side the plane normal points to.- Parameters:
x-y-z-- Returns:
- The side the point lies relative to the plane
-
isFrontFacing
public boolean isFrontFacing(Vector3 direction)
Returns whether the plane is facing the direction vector. Think of the direction vector as the direction a camera looks in. This method will return true if the front side of the plane determined by its normal faces the camera.- Parameters:
direction- the direction- Returns:
- whether the plane is front facing
-
getNormal
public Vector3 getNormal()
- Returns:
- The normal
-
getD
public float getD()
- Returns:
- The distance to the origin
-
set
public void set(Vector3 point, Vector3 normal)
Sets the plane to the given point and normal.- Parameters:
point- the point on the planenormal- the normal of the plane
-
set
public void set(float pointX, float pointY, float pointZ, float norX, float norY, float norZ)
-
set
public void set(Plane plane)
Sets this plane from the given plane- Parameters:
plane- the plane
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-