Plane
A plane Normal.Dot(point) = D with an oriented normal.
Metric DistanceTo and correct Project require a unit normal. Plane(normal,d) does not normalize input automatically; Normalized rescales both Normal and D. A zero normal does not define a geometric plane.
Keep an operation in one coordinate space. IntersectsRay/IntersectsSegment return a nullable point; check for a result. These calculations do not query world colliders or layers. Three-point constructor order affects normal orientation.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors5
Plane5 overloads
public Plane(Vector3 normal);Stores normal and sets D = 0: with a nonzero normal the plane passes through the origin. Does not normalize automatically; a zero normal does not define a plane.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
normalNonzero normal in the chosen coordinate system; use a unit vector for metric methods.
public Plane(Vector3 normal, Vector3 point);Stores normal and computes D = normal.Dot(point). Does not normalize the normal automatically. For metric distances and orthogonal projection, supply a unit normal or call Normalized() on the result.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
point | Vector3 | — |
normalNonzero normal in the chosen coordinate system; use a unit vector for metric methods.
pointPoint on the plane in the same coordinate system.
public Plane(Vector3 v1, Vector3 v2, Vector3 v3);Builds Normal = Normalize((v1 - v3).Cross(v1 - v2)) and D = Normal.Dot(v1). Point order determines normal orientation; swapping two points flips it. Coincident or collinear points produce a zero normal, not a valid geometric plane.
| Name | Type | Default |
|---|---|---|
v1 | Vector3 | — |
v2 | Vector3 | — |
v3 | Vector3 | — |
v1First of three noncollinear points.
v2Second point in the same coordinate system.
v3Third point; ordering affects normal orientation.
public Plane(Vector3 normal, float d);Stores the coefficients of Normal.Dot(x) = D without normalization. For example, Normal = (0, 1, 0), D = 2 means y = 2. D can be negative. Metric operations require a unit normal.
| Name | Type | Default |
|---|---|---|
normal | Vector3 | — |
d | float | — |
normalNonzero normal in the chosen coordinate system; use a unit vector for metric methods.
dRight-hand side of Normal.Dot(x) = D; a signed offset along the normal when it is a unit vector.
public Plane(float a, float b, float c, float d);Stores the coefficients of Normal.Dot(x) = D without normalization. For example, Normal = (0, 1, 0), D = 2 means y = 2. D can be negative. Metric operations require a unit normal.
| Name | Type | Default |
|---|---|---|
a | float | — |
b | float | — |
c | float | — |
d | float | — |
aNormal X component.
bNormal Y component.
cNormal Z component.
dRight-hand side of Normal.Dot(x) = D; a signed offset along the normal when it is a unit vector.
Properties8
DProperty
public float D { get; set; }Right-hand side of Normal.Dot(x) = D. With a unit normal, it is the signed offset from the origin along Normal; negative values are valid. Assignment changes only D. With a nonunit normal, D alone is not a distance.
NormalProperty
public Vector3 Normal { get; set; }Coefficients (a, b, c) of ax + by + cz = D. Assignment neither normalizes the vector nor changes D. To edit a component, use X, Y, Z or assign the whole Normal vector. Changing the normal while preserving D can change the geometric plane.
PlaneXYProperty
public static Plane PlaneXY { get; }Coordinate plane z = 0 with Normal = (0, 0, 1) and D = 0. Its normal points along +Z. Returns a Plane value: editing a copy stored in a variable does not modify this static plane.
PlaneXZProperty
public static Plane PlaneXZ { get; }Coordinate plane y = 0 with Normal = (0, 1, 0) and D = 0. Its normal points along +Y. Returns a Plane value: editing a copy stored in a variable does not modify this static plane.
PlaneYZProperty
public static Plane PlaneYZ { get; }Coordinate plane x = 0 with Normal = (1, 0, 0) and D = 0. Its normal points along +X. Returns a Plane value: editing a copy stored in a variable does not modify this static plane.
XProperty
public float X { get; set; }Alias for Normal.X. Assignment changes only this normal component without normalization or recalculating D.
YProperty
public float Y { get; set; }Alias for Normal.Y. Assignment changes only this normal component without normalization or recalculating D.
ZProperty
public float Z { get; set; }Alias for Normal.Z. Assignment changes only this normal component without normalization or recalculating D.
Methods20
DistanceTofloat
public float DistanceTo(Vector3 point);Returns Normal.Dot(point) − D. It is signed geometric distance only for a unit normal in a matching coordinate space.
| Name | Type | Default |
|---|---|---|
point | Vector3 | — |
pointPoint in the plane coordinate system.
floatNormal.Dot(point) - D: positive on the Normal side and negative on the other side. A metric distance only with a unit normal.
Equals2 overloads
public bool Equals(Plane other);Compares Normal and D exactly without normalization or equating opposite normals. p, -p and Plane(p.Normal * 2, p.D * 2) can describe the same point set but have unequal coefficients.
| Name | Type | Default |
|---|---|---|
other | Plane | — |
otherOther plane for exact coefficient comparison.
booltrue for exactly equal coefficients.
public override bool Equals(object? obj);Compares Normal and D exactly without normalization or equating opposite normals. p, -p and Plane(p.Normal * 2, p.D * 2) can describe the same point set but have unequal coefficients. For obj, accepts only a boxed Plane; null and other types return false.
| Name | Type | Default |
|---|---|---|
obj | object | — |
objObject to compare; null is allowed.
booltrue for exactly equal coefficients.
GetCenterVector3
public Vector3 GetCenter();Returns Normal * D. This is the closest plane point to the origin only for a unit normal. Does not divide by squared normal length or normalize input. For example, Plane((0, 2, 0), 4) gives (0, 8, 0), although the equation means y = 2; call Normalized() first.
Vector3Normal * D. An infinite plane has no bounded intrinsic center.
GetHashCodeint
public override int GetHashCode();Returns HashCode.Combine(Normal, D). Exactly equal coefficients have equal hashes, but a matching hash does not prove equality. By default, Dictionary<Plane, T> uses exact Equals(), not geometric coincidence. Do not persist the hash as an identifier across runs.
intThe hash of Normal and D coefficients.
HasPointbool
public bool HasPoint(Vector3 point, float tolerance = 1E-06f);Tests abs(Normal.Dot(point) - D) <= tolerance, including the tolerance boundary. Tolerance measures the equation residual and corresponds to distance only for a unit normal. A negative tolerance rejects even zero residual. A zero normal with D = 0 can accept any finite point and is not a valid plane.
| Name | Type | Default |
|---|---|---|
point | Vector3 | — |
tolerance | float | 1E-06f |
pointFinite point in the plane coordinate system.
toleranceNonnegative equation-residual tolerance; defaults to 0.000001 in the current float SDK.
booltrue when the absolute residual is at most tolerance.
Intersect3Vector3?
public Vector3? Intersect3(Plane b, Plane c);Finds the unique common point of this plane, b and c. The denominator is Normal.Cross(b.Normal).Dot(c.Normal); returns null when Mathf.IsZeroApprox treats it as zero. Both no intersection and no unique point use this result. The threshold is absolute: small coefficient scale can yield null even for independent normals. Use finite normalized planes for geometric calculations.
| Name | Type | Default |
|---|---|---|
b | Plane | — |
c | Plane | — |
bSecond plane in the same coordinate system.
cThird plane in the same coordinate system.
Vector3?The unique common point, or null for an approximately zero determinant.
IntersectsRayVector3?
public Vector3? IntersectsRay(Vector3 from, Vector3 dir);Returns Vector3? for the ray from + dir × t intersecting the plane, or null. An approximately parallel ray returns null, including a coplanar ray. Hits behind the origin are rejected with a Mathf.Epsilon tolerance in parameter t.
| Name | Type | Default |
|---|---|---|
from | Vector3 | — |
dir | Vector3 | — |
fromRay origin in the plane coordinate space.
dirNonzero direction; use a unit vector so the parameter tolerance corresponds to distance.
Vector3?Intersection point or null; check HasValue before Value. The operation does not query colliders.
IntersectsSegmentVector3?
public Vector3? IntersectsSegment(Vector3 begin, Vector3 end);Finds the intersection of the finite begin–end segment with the mathematical plane. Returns null for approximately zero Normal.Dot(begin - end), including coplanar or zero-length segments. For a nonparallel segment, accepts parameter t from -Mathf.Epsilon through 1 + Mathf.Epsilon. This tolerance is a fraction of segment length; the result is not clamped to endpoints and can lie slightly beyond them. Check HasValue before Value. This calculation does not query colliders.
using Reckfell;
public static class PlaneExamples
{
public static bool Validate()
{
var floor = new Plane(Vector3.Up, 2); // y = 2
Vector3? hit = floor.IntersectsRay(new Vector3(0, 10, 0), Vector3.Down);
Vector3? segmentHit = floor.IntersectsSegment(new Vector3(0, 5, 0), Vector3.Zero);
Vector3 projected = floor.Project(new Vector3(3, 9, 4));
return hit.HasValue && hit.Value.IsEqualApprox(new Vector3(0, 2, 0))
&& segmentHit.HasValue && segmentHit.Value.IsEqualApprox(new Vector3(0, 2, 0))
&& projected.IsEqualApprox(new Vector3(3, 2, 4));
}
}| Name | Type | Default |
|---|---|---|
begin | Vector3 | — |
end | Vector3 | — |
beginSegment start in the plane coordinate system.
endSegment endpoint, not a direction.
Vector3?The intersection point, or null under the denominator and parameter-range rules.
IsEqualApproxbool
public bool IsEqualApprox(Plane other);Compares Normal and D componentwise using Mathf.IsEqualApprox(). Does not normalize coefficients or treat opposite normals as equal. In the current float SDK, exact equality succeeds immediately; otherwise abs(a - b) < max(0.000001, 0.000001 * abs(a)) is required, with a from this plane. This is not geometric plane equality; it is nontransitive and can depend on operand order at the tolerance boundary.
| Name | Type | Default |
|---|---|---|
other | Plane | — |
otherPlane whose coefficients are compared without prior normalization.
booltrue when all four approximate comparisons pass.
IsFinitebool
public bool IsFinite();Checks Normal and D for NaN and infinities. Does not validate normal length: default(Plane) has finite zero coefficients but does not define a geometric plane. Metric operations additionally require a nonzero unit normal.
booltrue when all four coefficients are finite.
IsPointOverbool
public bool IsPointOver(Vector3 point);Tests the strict comparison Normal.Dot(point) > D. For a valid plane, true means the side toward which the normal points. A point on the plane returns false; no tolerance is applied. This refers to normal orientation, not necessarily world +Y.
| Name | Type | Default |
|---|---|---|
point | Vector3 | — |
pointFinite point in the same coordinate system.
booltrue for a positive equation residual.
NormalizedPlane
public Plane Normalized();Divides both Normal and D by nonzero normal length, preserving the plane. Normalizing only Normal would change its position.
PlaneFor a nonzero normal, divides Normal and D by its length. A zero normal returns a Plane with zero Normal and D; this is not a geometric plane.
ProjectVector3
public Vector3 Project(Vector3 point);Projects onto a known plane with a unit normal. Does not query physics; point and plane must share a space.
| Name | Type | Default |
|---|---|---|
point | Vector3 | — |
pointFinite point in the plane coordinate system; normalize the plane first.
Vector3point - Normal * DistanceTo(point). An orthogonal projection onto the plane when the normal is unit length.
ToString2 overloads
public override string ToString();Builds Normal.ToString(format) + ", " + D.ToString(format, InvariantCulture). For example, F2 gives (0.00, 1.00, 0.00), 2.00. The format applies to all four coefficients. This is diagnostic text, not a save format. Equivalent to ToString(null).
stringText containing the normal and D with culture-independent numeric formatting.
public string ToString(string? format);Builds Normal.ToString(format) + ", " + D.ToString(format, InvariantCulture). For example, F2 gives (0.00, 1.00, 0.00), 2.00. The format applies to all four coefficients. This is diagnostic text, not a save format. An invalid numeric format can throw FormatException.
| Name | Type | Default |
|---|---|---|
format | string | — |
formatA .NET numeric format such as "F2"; null selects the default format.
stringText containing the normal and D with culture-independent numeric formatting.
op_Equalitybool
public static bool operator ==(Plane left, Plane right);Compares Normal and D exactly without normalization or equating opposite normals. p, -p and Plane(p.Normal * 2, p.D * 2) can describe the same point set but have unequal coefficients.
| Name | Type | Default |
|---|---|---|
left | Plane | — |
right | Plane | — |
leftLeft plane.
rightRight plane.
booltrue for exactly equal coefficients.
op_Inequalitybool
public static bool operator !=(Plane left, Plane right);Compares Normal and D exactly without normalization or equating opposite normals. p, -p and Plane(p.Normal * 2, p.D * 2) can describe the same point set but have unequal coefficients. Operator != negates exact equality.
| Name | Type | Default |
|---|---|---|
left | Plane | — |
right | Plane | — |
leftLeft plane.
rightRight plane.
booltrue for unequal coefficients.
op_UnaryNegationPlane
public static Plane operator -(Plane plane);Returns Plane(-Normal, -D): preserves geometric location while reversing normal orientation and DistanceTo signs. Negating only Normal while preserving D is a different transformation.
| Name | Type | Default |
|---|---|---|
plane | Plane | — |
planeInput plane.
PlaneA value copy with negated Normal and D.
op_UnaryPlusPlane
public static Plane operator +(Plane plane);Returns the unchanged Plane value. Does not normalize coefficients or change their signs.
| Name | Type | Default |
|---|---|---|
plane | Plane | — |
planeInput plane.
PlaneA value copy with unchanged coefficients.