Struct PlaneD

Namespace
Elegy.Common.Maths
Assembly
Elegy.Common.dll

Represents a plane in three-dimensional space.

public struct PlaneD : IEquatable<PlaneD>
Implements
Inherited Members
Extension Methods

Remarks

[!INCLUDE[vectors-are-rows-paragraph](~/includes/system-numerics-vectors-are-rows.md)]

Constructors

PlaneD(Vector3D, double)

Creates a PlaneD object from a specified normal and the distance along the normal from the origin.

public PlaneD(Vector3D normal, double d)

Parameters

normal Vector3D

The plane's normal vector.

d double

The plane's distance from the origin along its normal vector.

PlaneD(double, double, double, double)

Creates a PlaneD object from the X, Y, and Z components of its normal, and its distance from the origin on that normal.

public PlaneD(double x, double y, double z, double d)

Parameters

x double

The X component of the normal.

y double

The Y component of the normal.

z double

The Z component of the normal.

d double

The distance of the plane along its normal from the origin.

PlaneD(Vector4)

Creates a PlaneD object from a specified four-dimensional vector.

public PlaneD(Vector4 value)

Parameters

value Vector4

A vector whose first three elements describe the normal vector, and whose W defines the distance along that normal from the origin.

Fields

D

The distance of the plane along its normal from the origin.

public double D

Field Value

double

Normal

The normal vector of the plane.

public Vector3D Normal

Field Value

Vector3D

Methods

CreateFromVertices(Vector3D, Vector3D, Vector3D)

Creates a PlaneD object that contains three specified points.

public static PlaneD CreateFromVertices(Vector3D point1, Vector3D point2, Vector3D point3)

Parameters

point1 Vector3D

The first point defining the plane.

point2 Vector3D

The second point defining the plane.

point3 Vector3D

The third point defining the plane.

Returns

PlaneD

The plane containing the three points.

DistanceTo(Vector3D)

Returns the shortest distance from this plane to the position point.

public readonly double DistanceTo(Vector3D point)

Parameters

point Vector3D

The position to use for the calculation.

Returns

double

The shortest distance.

Dot(PlaneD, Vector4)

Calculates the dot product of a plane and a 4-dimensional vector.

public static double Dot(PlaneD plane, Vector4 value)

Parameters

plane PlaneD

The plane.

value Vector4

The four-dimensional vector.

Returns

double

The dot product.

Dot(Vector4)

public double Dot(Vector4 with)

Parameters

with Vector4

Returns

double

DotCoordinate(PlaneD, Vector3D)

Returns the dot product of a specified three-dimensional vector and the normal vector of this plane plus the distance (D) value of the plane.

public static double DotCoordinate(PlaneD plane, Vector3D value)

Parameters

plane PlaneD

The plane.

value Vector3D

The 3-dimensional vector.

Returns

double

The dot product.

DotNormal(PlaneD, Vector3D)

Returns the dot product of a specified three-dimensional vector and the Normal vector of this plane.

public static double DotNormal(PlaneD plane, Vector3D value)

Parameters

plane PlaneD

The plane.

value Vector3D

The three-dimensional vector.

Returns

double

The dot product.

Equals(PlaneD)

Returns a value that indicates whether this instance and another plane object are equal.

public readonly bool Equals(PlaneD other)

Parameters

other PlaneD

The other plane.

Returns

bool

true if the two planes are equal; otherwise, false.

Remarks

Two PlaneD objects are equal if their Normal and D fields are equal.

Equals(object?)

Returns a value that indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if the current instance and obj are equal; otherwise, false. If obj is null, the method returns false.

Remarks

The current instance and obj are equal if obj is a PlaneD object and their Normal and D fields are equal.

GetCenter()

Returns the center of the plane, the point on the plane closest to the origin. The point where the normal line going through the origin intersects the plane.

public readonly Vector3D GetCenter()

Returns

Vector3D

Equivalent to Normal multiplied by D.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

The hash code.

HasPoint(Vector3D, double)

Returns true if point is inside the plane. Comparison uses a custom minimum tolerance threshold.

public readonly bool HasPoint(Vector3D point, double tolerance = 5E-324)

Parameters

point Vector3D

The point to check.

tolerance double

The tolerance threshold.

Returns

bool

A bool for whether or not the plane has the point.

Intersect3(PlaneD, PlaneD)

Returns the intersection point of the three planes: b, c, and this plane. If no intersection is found, null is returned.

public readonly Vector3D? Intersect3(PlaneD b, PlaneD c)

Parameters

b PlaneD

One of the three planes to use in the calculation.

c PlaneD

One of the three planes to use in the calculation.

Returns

Vector3D?

The intersection, or null if none is found.

IntersectsRay(Vector3D, Vector3D)

Returns the intersection point of a ray consisting of the position from and the direction normal dir with this plane. If no intersection is found, null is returned.

public readonly Vector3D? IntersectsRay(Vector3D from, Vector3D dir)

Parameters

from Vector3D

The start of the ray.

dir Vector3D

The direction of the ray, normalized.

Returns

Vector3D?

The intersection, or null if none is found.

IntersectsSegment(Vector3D, Vector3D)

Returns the intersection point of a line segment from position begin to position end with this plane. If no intersection is found, null is returned.

public readonly Vector3D? IntersectsSegment(Vector3D begin, Vector3D end)

Parameters

begin Vector3D

The start of the line segment.

end Vector3D

The end of the line segment.

Returns

Vector3D?

The intersection, or null if none is found.

IsFinite()

Returns true if this plane is finite, by calling IsFinite(float) on each component.

public readonly bool IsFinite()

Returns

bool

Whether this vector is finite or not.

IsPointOver(Vector3D)

Returns true if point is located above the plane.

public readonly bool IsPointOver(Vector3D point)

Parameters

point Vector3D

The point to check.

Returns

bool

A bool for whether or not the point is above the plane.

Normalize(PlaneD)

Creates a new PlaneD object whose normal vector is the source plane's normal vector normalized.

public static PlaneD Normalize(PlaneD value)

Parameters

value PlaneD

The source plane.

Returns

PlaneD

The normalized plane.

Normalized()

Returns the plane scaled to unit length.

public readonly PlaneD Normalized()

Returns

PlaneD

A normalized version of the plane.

Project(Vector3D)

Returns the orthogonal projection of point into the plane.

public readonly Vector3D Project(Vector3D point)

Parameters

point Vector3D

The point to project.

Returns

Vector3D

The projected point.

ToString()

Returns the string representation of this plane object.

public override readonly string ToString()

Returns

string

A string that represents this PlaneD object.

Remarks

The string representation of a PlaneD object use the formatting conventions of the current culture to format the numeric values in the returned string. For example, a PlaneD object whose string representation is formatted by using the conventions of the en-US culture might appear as {Normal:<1.1, 2.2, 3.3> D:4.4}.

Transform(PlaneD, Matrix4x4)

Transforms a normalized plane by a 4x4 matrix.

public static PlaneD Transform(PlaneD plane, Matrix4x4 matrix)

Parameters

plane PlaneD

The normalized plane to transform.

matrix Matrix4x4

The transformation matrix to apply to plane.

Returns

PlaneD

The transformed plane.

Remarks

plane must already be normalized so that its Normal vector is of unit length before this method is called.

Transform(PlaneD, Quaternion)

Transforms a normalized plane by a Quaternion rotation.

public static PlaneD Transform(PlaneD plane, Quaternion rotation)

Parameters

plane PlaneD

The normalized plane to transform.

rotation Quaternion

The Quaternion rotation to apply to the plane.

Returns

PlaneD

A new plane that results from applying the Quaternion rotation.

Remarks

plane must already be normalized so that its Normal vector is of unit length before this method is called.

Operators

operator ==(PlaneD, PlaneD)

Returns a value that indicates whether two planes are equal.

public static bool operator ==(PlaneD value1, PlaneD value2)

Parameters

value1 PlaneD

The first plane to compare.

value2 PlaneD

The second plane to compare.

Returns

bool

true if value1 and value2 are equal; otherwise, false.

Remarks

Two PlaneD objects are equal if their Normal and D fields are equal. The operator ==(PlaneD, PlaneD) method defines the operation of the equality operator for PlaneD objects.

operator !=(PlaneD, PlaneD)

Returns a value that indicates whether two planes are not equal.

public static bool operator !=(PlaneD value1, PlaneD value2)

Parameters

value1 PlaneD

The first plane to compare.

value2 PlaneD

The second plane to compare.

Returns

bool

true if value1 and value2 are not equal; otherwise, false.

Remarks

The operator !=(PlaneD, PlaneD) method defines the operation of the inequality operator for PlaneD objects.