Struct Plane
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a plane in three dimensional space.
[DataContract]
public struct Plane : IEquatable<Plane>, ISpanFormattable, IFormattable, IIntersectableWithRay
- Implements
Constructors
Plane(Vector3, Vector3)
Initializes a new instance of the Plane struct.
public Plane(Vector3 point, Vector3 normal)
Parameters
Plane(Vector3, Vector3, Vector3)
Initializes a new instance of the Plane struct.
public Plane(Vector3 point1, Vector3 point2, Vector3 point3)
Parameters
point1Vector3First point of a triangle defining the plane.
point2Vector3Second point of a triangle defining the plane.
point3Vector3Third point of a triangle defining the plane.
Plane(Vector3, float)
Initializes a new instance of the Plane struct.
public Plane(Vector3 value, float d)
Parameters
valueVector3The normal of the plane.
dfloatThe distance of the plane along its normal from the origin
Plane(float)
Initializes a new instance of the Plane struct.
public Plane(float value)
Parameters
valuefloatThe value that will be assigned to all components.
Plane(float, float, float, float)
Initializes a new instance of the Plane struct.
public Plane(float a, float b, float c, float d)
Parameters
afloatThe X component of the normal.
bfloatThe Y component of the normal.
cfloatThe Z component of the normal.
dfloatThe distance of the plane along its normal from the origin.
Plane(float[])
Initializes a new instance of the Plane struct.
public Plane(float[] values)
Parameters
valuesfloat[]The values to assign to the A, B, C, and D components of the plane. This must be an array with four elements.
Exceptions
- ArgumentNullException
Thrown when
valuesisnull.- ArgumentOutOfRangeException
Thrown when
valuescontains more or less than four elements.
Fields
D
The distance of the plane along its normal from the origin.
public float D
Field Value
Normal
The normal vector of the plane.
public Vector3 Normal
Field Value
Properties
this[int]
Gets or sets the component at the specified index.
public float this[int index] { get; set; }
Parameters
indexintThe index of the component to access. Use 0 for the A component, 1 for the B component, 2 for the C component, and 3 for the D component.
Property Value
- float
The value of the A, B, C, or D component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
indexis out of the range [0, 3].
Methods
Dot(Plane, Vector4)
Calculates the dot product of the specified vector and plane.
public static float Dot(Plane left, Vector4 right)
Parameters
Returns
- float
The dot product of the specified plane and vector.
Dot(ref readonly Plane, ref readonly Vector4, out float)
Calculates the dot product of the specified vector and plane.
public static void Dot(ref readonly Plane left, ref readonly Vector4 right, out float result)
Parameters
leftPlaneThe source plane.
rightVector4The source vector.
resultfloatWhen the method completes, contains the dot product of the specified plane and vector.
DotCoordinate(Plane, Vector3)
Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane.
public static float DotCoordinate(Plane left, Vector3 right)
Parameters
Returns
- float
The dot product of a specified vector and the normal of the Plane plus the distance value of the plane.
DotCoordinate(ref readonly Plane, ref readonly Vector3, out float)
Calculates the dot product of a specified vector and the normal of the plane plus the distance value of the plane.
public static void DotCoordinate(ref readonly Plane left, ref readonly Vector3 right, out float result)
Parameters
leftPlaneThe source plane.
rightVector3The source vector.
resultfloatWhen the method completes, contains the dot product of a specified vector and the normal of the Plane plus the distance value of the plane.
DotNormal(Plane, Vector3)
Calculates the dot product of the specified vector and the normal of the plane.
public static float DotNormal(Plane left, Vector3 right)
Parameters
Returns
- float
The dot product of the specified vector and the normal of the plane.
DotNormal(ref readonly Plane, ref readonly Vector3, out float)
Calculates the dot product of the specified vector and the normal of the plane.
public static void DotNormal(ref readonly Plane left, ref readonly Vector3 right, out float result)
Parameters
leftPlaneThe source plane.
rightVector3The source vector.
resultfloatWhen the method completes, contains the dot product of the specified vector and the normal of the plane.
Equals(Plane)
Determines whether the specified Vector4 is equal to this instance.
public readonly bool Equals(Plane value)
Parameters
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? value)
Parameters
valueobjectThe object to compare with this instance.
Returns
- bool
trueif the specified object is equal to this instance; otherwise,false.
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Intersects(ref readonly BoundingBox)
Determines if there is an intersection between the current object and a BoundingBox.
public PlaneIntersectionType Intersects(ref readonly BoundingBox box)
Parameters
boxBoundingBoxThe box to test.
Returns
- PlaneIntersectionType
Whether the two objects intersected.
Intersects(ref readonly BoundingSphere)
Determines if there is an intersection between the current object and a BoundingSphere.
public PlaneIntersectionType Intersects(ref readonly BoundingSphere sphere)
Parameters
sphereBoundingSphereThe sphere to test.
Returns
- PlaneIntersectionType
Whether the two objects intersected.
Intersects(ref readonly Plane)
Determines if there is an intersection between the current object and a Plane.
public bool Intersects(ref readonly Plane plane)
Parameters
planePlaneThe plane to test.
Returns
- bool
Whether the two objects intersected.
Intersects(ref readonly Plane, out Ray)
Determines if there is an intersection between the current object and a Plane.
public bool Intersects(ref readonly Plane plane, out Ray line)
Parameters
planePlaneThe plane to test.
lineRayWhen the method completes, contains the line of intersection as a Ray, or a zero ray if there was no intersection.
Returns
- bool
Whether the two objects intersected.
Intersects(ref readonly Ray)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray)
Parameters
rayRayThe ray to test.
Returns
- bool
Whether the two objects intersected.
Intersects(ref readonly Ray, out Vector3)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray, out Vector3 point)
Parameters
rayRayThe ray to test.
pointVector3When the method completes, contains the point of intersection, or Zero if there was no intersection.
Returns
- bool
Whether the two objects intersected.
Intersects(ref readonly Ray, out float)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray, out float distance)
Parameters
rayRayThe ray to test.
distancefloatWhen the method completes, contains the distance of the intersection, or 0 if there was no intersection.
Returns
- bool
Whether the two objects intersected.
Intersects(ref readonly Vector3)
Determines if there is an intersection between the current object and a point.
public PlaneIntersectionType Intersects(ref readonly Vector3 point)
Parameters
pointVector3The point to test.
Returns
- PlaneIntersectionType
Whether the two objects intersected.
Intersects(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3)
Determines if there is an intersection between the current object and a triangle.
public PlaneIntersectionType Intersects(ref readonly Vector3 vertex1, ref readonly Vector3 vertex2, ref readonly Vector3 vertex3)
Parameters
vertex1Vector3The first vertex of the triangle to test.
vertex2Vector3The second vertex of the triagnle to test.
vertex3Vector3The third vertex of the triangle to test.
Returns
- PlaneIntersectionType
Whether the two objects intersected.
Multiply(Plane, float)
Scales the plane by the given scaling factor.
public static Plane Multiply(Plane value, float scale)
Parameters
Returns
- Plane
The scaled plane.
Multiply(ref readonly Plane, float, out Plane)
Scales the plane by the given scaling factor.
public static void Multiply(ref readonly Plane value, float scale, out Plane result)
Parameters
valuePlaneThe plane to scale.
scalefloatThe amount by which to scale the plane.
resultPlaneWhen the method completes, contains the scaled plane.
Negate()
Negates a plane by negating all its coefficients, which result in a plane in opposite direction.
public void Negate()
Negate(Plane)
Negates a plane by negating all its coefficients, which result in a plane in opposite direction.
public static Plane Negate(Plane plane)
Parameters
planePlaneThe source plane.
Returns
- Plane
The flipped plane.
Negate(ref readonly Plane, out Plane)
Negates a plane by negating all its coefficients, which result in a plane in opposite direction.
public static void Negate(ref readonly Plane plane, out Plane result)
Parameters
Normalize()
Changes the coefficients of the normal vector of the plane to make it of unit length.
public void Normalize()
Normalize(Plane)
Changes the coefficients of the normal vector of the plane to make it of unit length.
public static Plane Normalize(Plane plane)
Parameters
planePlaneThe source plane.
Returns
- Plane
The normalized plane.
Normalize(ref readonly Plane, out Plane)
Changes the coefficients of the normal vector of the plane to make it of unit length.
public static void Normalize(ref readonly Plane plane, out Plane result)
Parameters
planePlaneThe source plane.
resultPlaneWhen the method completes, contains the normalized plane.
Normalize(float, float, float, float, out Plane)
Creates a plane of unit length.
public static void Normalize(float normalX, float normalY, float normalZ, float planeD, out Plane result)
Parameters
normalXfloatThe X component of the normal.
normalYfloatThe Y component of the normal.
normalZfloatThe Z component of the normal.
planeDfloatThe distance of the plane along its normal from the origin.
resultPlaneWhen the method completes, contains the normalized plane.
Project(Plane, Vector3)
Projects a point onto a plane.
public static Vector3 Project(Plane plane, Vector3 point)
Parameters
Returns
- Vector3
The projected point.
Project(ref readonly Plane, ref readonly Vector3, out Vector3)
Projects a point onto a plane.
public static void Project(ref readonly Plane plane, ref readonly Vector3 point, out Vector3 result)
Parameters
planePlaneThe plane to project the point to.
pointVector3The point to project.
resultVector3The projected point.
ToArray()
Creates an array containing the elements of the plane.
public float[] ToArray()
Returns
- float[]
A four-element array containing the components of the plane.
ToString()
Returns a string that represents this instance.
public override readonly string ToString()
Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format.
formatProviderIFormatProviderThe format provider.
Returns
Transform(Plane, Matrix)
Transforms a normalized plane by a matrix.
public static Plane Transform(Plane plane, Matrix transformation)
Parameters
Returns
- Plane
When the method completes, contains the transformed plane.
Transform(Plane, Quaternion)
Transforms a normalized plane by a quaternion rotation.
public static Plane Transform(Plane plane, Quaternion rotation)
Parameters
planePlaneThe normalized source plane.
rotationQuaternionThe quaternion rotation.
Returns
- Plane
The transformed plane.
Transform(ref readonly Plane, ref readonly Matrix, out Plane)
Transforms a normalized plane by a matrix.
public static void Transform(ref readonly Plane plane, ref readonly Matrix transformation, out Plane result)
Parameters
planePlaneThe normalized source plane.
transformationMatrixThe transformation matrix.
resultPlaneWhen the method completes, contains the transformed plane.
Transform(ref readonly Plane, ref readonly Quaternion, out Plane)
Transforms a normalized plane by a quaternion rotation.
public static void Transform(ref readonly Plane plane, ref readonly Quaternion rotation, out Plane result)
Parameters
planePlaneThe normalized source plane.
rotationQuaternionThe quaternion rotation.
resultPlaneWhen the method completes, contains the transformed plane.
Transform(Plane[], ref readonly Matrix)
Transforms an array of normalized planes by a matrix.
public static void Transform(Plane[] planes, ref readonly Matrix transformation)
Parameters
planesPlane[]The array of normalized planes to transform.
transformationMatrixThe transformation matrix.
Exceptions
- ArgumentNullException
Thrown when
planesisnull.
Transform(Plane[], ref readonly Quaternion)
Transforms an array of normalized planes by a quaternion rotation.
public static void Transform(Plane[] planes, ref readonly Quaternion rotation)
Parameters
planesPlane[]The array of normalized planes to transform.
rotationQuaternionThe quaternion rotation.
Exceptions
- ArgumentNullException
Thrown when
planesisnull.
Operators
operator ==(Plane, Plane)
Tests for equality between two objects.
public static bool operator ==(Plane left, Plane right)
Parameters
Returns
- bool
trueiflefthas the same value asright; otherwise,false.
operator !=(Plane, Plane)
Tests for inequality between two objects.
public static bool operator !=(Plane left, Plane right)
Parameters
Returns
- bool
trueiflefthas a different value thanright; otherwise,false.
operator *(Plane, float)
Scales a plane by the given value.
public static Plane operator *(Plane plane, float scale)
Parameters
Returns
- Plane
The scaled plane.
operator *(float, Plane)
Scales a plane by the given value.
public static Plane operator *(float scale, Plane plane)
Parameters
Returns
- Plane
The scaled plane.
operator -(Plane)
Negates a plane by negating all its coefficients, which result in a plane in opposite direction.
public static Plane operator -(Plane plane)
Parameters
planePlane
Returns
- Plane
The negated plane.