Struct Plane
A plane represented by a normal vector and a distance along the normal from the origin.
Inherited Members
Namespace: ProjectDawn.Geometry3D
Assembly: ProjectDawn.Geometry.dll
Syntax
[Serializable]
public struct Plane
Remarks
A plane splits the 3D space in half. The normal vector points to the positive half and the other half is considered negative.
Constructors
| Improve this Doc View SourcePlane(Single, Single, Single, Single)
Constructs a Plane from arbitrary coefficients A, B, C, D of the plane equation Ax + By + Cz + Dw = 0.
Declaration
public Plane(float coefficientA, float coefficientB, float coefficientC, float coefficientD)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | coefficientA | Coefficient A from plane equation. |
| System.Single | coefficientB | Coefficient B from plane equation. |
| System.Single | coefficientC | Coefficient C from plane equation. |
| System.Single | coefficientD | Coefficient D from plane equation. |
Remarks
The constructed plane will be the normalized form of the plane specified by the given coefficients.
Plane(float3, Single)
Constructs a plane with a normal vector and distance from the origin.
Declaration
public Plane(float3 normal, float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | normal | A non-zero vector that is perpendicular to the plane. It may be any length. |
| System.Single | distance | Distance from the origin along the normal. A negative value moves the plane in the same direction as the normal while a positive value moves it in the opposite direction. |
Remarks
The constructed plane will be the normalized form of the plane specified by the inputs.
Plane(float3, float3)
Constructs a plane with a normal vector and a point that lies in the plane.
Declaration
public Plane(float3 normal, float3 pointInPlane)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | normal | A non-zero vector that is perpendicular to the plane. It may be any length. |
| Unity.Mathematics.float3 | pointInPlane | A point that lies in the plane. |
Remarks
The constructed plane will be the normalized form of the plane specified by the inputs.
Plane(float3, float3, float3)
Constructs a plane with two vectors and a point that all lie in the plane.
Declaration
public Plane(float3 vector1InPlane, float3 vector2InPlane, float3 pointInPlane)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | vector1InPlane | A non-zero vector that lies in the plane. It may be any length. |
| Unity.Mathematics.float3 | vector2InPlane | A non-zero vector that lies in the plane. It may be any length and must not be a scalar multiple of |
| Unity.Mathematics.float3 | pointInPlane | A point that lies in the plane. |
Remarks
The constructed plane will be the normalized form of the plane specified by the inputs.
Fields
| Improve this Doc View SourceNormalAndDistance
A plane in the form Ax + By + Cz + Dw = 0.
Declaration
public float4 NormalAndDistance
Field Value
| Type | Description |
|---|---|
| Unity.Mathematics.float4 |
Remarks
Stores the plane coefficients A, B, C, D where (A, B, C) is a unit normal vector and D is the distance from the origin. A plane stored with a unit normal vector is called a normalized plane.
Properties
| Improve this Doc View SourceDistance
Get/set the distance of the plane from the origin. May be a negative value.
Declaration
public float Distance { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Remarks
It is assumed that the normal is unit length. If you set a new plane such that Ax + By + Cz + Dw = 0 but (A, B, C) is not unit length, then you must normalize the plane by calling Normalize(Plane).
Flipped
Flips the plane so the normal points in the opposite direction.
Declaration
public Plane Flipped { get; }
Property Value
| Type | Description |
|---|---|
| Plane |
Normal
Get/set the normal vector of the plane.
Declaration
public float3 Normal { get; set; }
Property Value
| Type | Description |
|---|---|
| Unity.Mathematics.float3 |
Remarks
It is assumed that the normal is unit length. If you set a new plane such that Ax + By + Cz + Dw = 0 but (A, B, C) is not unit length, then you must normalize the plane by calling Normalize(Plane).
Methods
| Improve this Doc View SourceCreateFromUnitNormalAndDistance(float3, Single)
Creates a normalized Plane directly without normalization cost.
Declaration
public static Plane CreateFromUnitNormalAndDistance(float3 unitNormal, float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | unitNormal | A non-zero vector that is perpendicular to the plane. It must be unit length. |
| System.Single | distance | Distance from the origin along the normal. A negative value moves the plane in the same direction as the normal while a positive value moves it in the opposite direction. |
Returns
| Type | Description |
|---|---|
| Plane | Normalized Plane constructed from given inputs. |
Remarks
If you have a unit length normal vector, you can create a Plane faster than using one of its constructors by calling this function.
CreateFromUnitNormalAndPointInPlane(float3, float3)
Creates a normalized Plane without normalization cost.
Declaration
public static Plane CreateFromUnitNormalAndPointInPlane(float3 unitNormal, float3 pointInPlane)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | unitNormal | A non-zero vector that is perpendicular to the plane. It must be unit length. |
| Unity.Mathematics.float3 | pointInPlane | A point that lies in the plane. |
Returns
| Type | Description |
|---|---|
| Plane | Normalized Plane constructed from given inputs. |
Remarks
If you have a unit length normal vector, you can create a Plane faster than using one of its constructors by calling this function.
Normalize(Plane)
Normalizes the given Plane.
Declaration
public static Plane Normalize(Plane plane)
Parameters
| Type | Name | Description |
|---|---|---|
| Plane | plane | Plane to normalize. |
Returns
| Type | Description |
|---|---|
| Plane | Normalized Plane. |
Normalize(float4)
Normalizes the plane represented by the given plane coefficients.
Declaration
public static float4 Normalize(float4 planeCoefficients)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float4 | planeCoefficients | Plane coefficients A, B, C, D stored in x, y, z, w (respectively). |
Returns
| Type | Description |
|---|---|
| Unity.Mathematics.float4 | Normalized plane coefficients. |
Remarks
The plane coefficients are A, B, C, D and stored in that order in the Unity.Mathematics.float4.
Projection(float3)
Projects the given point onto the plane.
Declaration
public float3 Projection(float3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | point | Point to project onto the plane. |
Returns
| Type | Description |
|---|---|
| Unity.Mathematics.float3 | Projected point that's inside the plane. |
Remarks
Plane must be normalized prior to calling this function. The result is the position closest to the point that still lies in the plane.
SignedDistanceToPoint(float3)
Get the signed distance from the point to the plane.
Declaration
public float SignedDistanceToPoint(float3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity.Mathematics.float3 | point | Point to find the signed distance with. |
Returns
| Type | Description |
|---|---|
| System.Single | Signed distance of the point from the plane. |
Remarks
Plane must be normalized prior to calling this function. Distance is positive if point is on side of the plane the normal points to, negative if on the opposite side and zero if the point lies in the plane. Avoid comparing equality with 0.0f when testing if a point lies exactly in the plane and use an approximate comparison instead.
Operators
| Improve this Doc View SourceImplicit(Plane to float4)
Implicitly converts a Plane to Unity.Mathematics.float4.
Declaration
public static implicit operator float4(Plane plane)
Parameters
| Type | Name | Description |
|---|---|---|
| Plane | plane | Plane to convert. |
Returns
| Type | Description |
|---|---|
| Unity.Mathematics.float4 | A Unity.Mathematics.float4 representing the plane. |