Struct Plane
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Plane represents a normalized plane equation. "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing.
public struct Plane : IEquatable<Plane>
- Implements
- Inherited Members
Constructors
Plane(Vector3)
Constructs a Plane from a normal
vector.
The plane will intersect the origin.
public Plane(Vector3 normal)
Parameters
normal
Vector3The normal of the plane, must be a unit vector.
Plane(Vector3, Vector3)
Constructs a Plane from a normal
vector and
a point
on the plane.
public Plane(Vector3 normal, Vector3 point)
Parameters
normal
Vector3The normal of the plane, must be a unit vector.
point
Vector3The point on the plane.
Plane(Vector3, Vector3, Vector3)
Constructs a Plane from the three points, given in clockwise order.
public Plane(Vector3 v1, Vector3 v2, Vector3 v3)
Parameters
Plane(Vector3, float)
Constructs a Plane from a normal
vector and
the plane's distance to the origin d
.
public Plane(Vector3 normal, float d)
Parameters
normal
Vector3The normal of the plane, must be a unit vector.
d
floatThe plane's distance from the origin. This value is typically non-negative.
Plane(float, float, float, float)
Constructs a Plane from four values.
a
, b
and c
become the
components of the resulting plane's Normal vector.
d
becomes the plane's distance from the origin.
public Plane(float a, float b, float c, float d)
Parameters
a
floatThe X component of the plane's normal vector.
b
floatThe Y component of the plane's normal vector.
c
floatThe Z component of the plane's normal vector.
d
floatThe plane's distance from the origin. This value is typically non-negative.
Properties
D
The distance from the origin to the plane (in the direction of
Normal). This value is typically non-negative.
In the scalar equation of the plane ax + by + cz = d
,
this is d
, while the (a, b, c)
coordinates are represented
by the Normal property.
public float D { readonly get; set; }
Property Value
- float
The plane's distance from the origin.
Normal
The normal of the plane, which must be a unit vector.
In the scalar equation of the plane ax + by + cz = d
, this is
the vector (a, b, c)
, where d
is the D property.
public Vector3 Normal { readonly get; set; }
Property Value
PlaneXY
A Plane that extends in the X and Y axes (normal vector points +Z).
public static Plane PlaneXY { get; }
Property Value
- Plane
Equivalent to
new Plane(0, 0, 1, 0)
.
PlaneXZ
A Plane that extends in the X and Z axes (normal vector points +Y).
public static Plane PlaneXZ { get; }
Property Value
- Plane
Equivalent to
new Plane(0, 1, 0, 0)
.
PlaneYZ
A Plane that extends in the Y and Z axes (normal vector points +X).
public static Plane PlaneYZ { get; }
Property Value
- Plane
Equivalent to
new Plane(1, 0, 0, 0)
.
X
The X component of the plane's normal vector.
public float X { readonly get; set; }
Property Value
Y
The Y component of the plane's normal vector.
public float Y { readonly get; set; }
Property Value
Z
The Z component of the plane's normal vector.
public float Z { readonly get; set; }
Property Value
Methods
DistanceTo(Vector3)
Returns the shortest distance from this plane to the position point
.
public readonly float DistanceTo(Vector3 point)
Parameters
point
Vector3The position to use for the calculation.
Returns
- float
The shortest distance.
Equals(Plane)
Returns true if this plane and other
are equal.
public readonly bool Equals(Plane other)
Parameters
other
PlaneThe other plane to compare.
Returns
- bool
Whether or not the planes are exactly equal.
Equals(object)
Returns true if this plane and obj
are equal.
public override readonly bool Equals(object obj)
Parameters
obj
objectThe other object to compare.
Returns
- bool
Whether or not the plane and the other object are exactly 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 Vector3 GetCenter()
Returns
GetHashCode()
Serves as the hash function for Plane.
public override readonly int GetHashCode()
Returns
- int
A hash code for this plane.
HasPoint(Vector3, float)
Returns true if point is inside the plane. Comparison uses a custom minimum tolerance threshold.
public readonly bool HasPoint(Vector3 point, float tolerance = 1E-06)
Parameters
Returns
Intersect3(Plane, Plane)
Returns the intersection point of the three planes: b
, c
,
and this plane. If no intersection is found, null is returned.
public readonly Vector3? Intersect3(Plane b, Plane c)
Parameters
b
PlaneOne of the three planes to use in the calculation.
c
PlaneOne of the three planes to use in the calculation.
Returns
IntersectsRay(Vector3, Vector3)
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 Vector3? IntersectsRay(Vector3 from, Vector3 dir)
Parameters
Returns
IntersectsSegment(Vector3, Vector3)
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 Vector3? IntersectsSegment(Vector3 begin, Vector3 end)
Parameters
Returns
IsEqualApprox(Plane)
Returns true if this plane and other
are
approximately equal, by running IsEqualApprox(float, float) on each component.
public readonly bool IsEqualApprox(Plane other)
Parameters
other
PlaneThe other plane to compare.
Returns
- bool
Whether or not the planes are approximately equal.
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(Vector3)
Returns true if point
is located above the plane.
public readonly bool IsPointOver(Vector3 point)
Parameters
point
Vector3The point to check.
Returns
Normalized()
Returns the plane scaled to unit length.
public readonly Plane Normalized()
Returns
- Plane
A normalized version of the plane.
Project(Vector3)
Returns the orthogonal projection of point
into the plane.
public readonly Vector3 Project(Vector3 point)
Parameters
point
Vector3The point to project.
Returns
- Vector3
The projected point.
ToString()
Converts this Plane to a string.
public override readonly string ToString()
Returns
- string
A string representation of this plane.
ToString(string)
Converts this Plane to a string with the given format
.
public readonly string ToString(string format)
Parameters
format
string
Returns
- string
A string representation of this plane.
Operators
operator ==(Plane, Plane)
Returns true if the Planes are exactly equal. Note: Due to floating-point precision errors, consider using IsEqualApprox(Plane) instead, which is more reliable.
public static bool operator ==(Plane left, Plane right)
Parameters
Returns
- bool
Whether or not the planes are exactly equal.
operator !=(Plane, Plane)
Returns true if the Planes are not equal. Note: Due to floating-point precision errors, consider using IsEqualApprox(Plane) instead, which is more reliable.
public static bool operator !=(Plane left, Plane right)
Parameters
Returns
- bool
Whether or not the planes are not equal.
operator -(Plane)
Returns the negative value of the Plane.
This is the same as writing new Plane(-p.Normal, -p.D)
.
This operation flips the direction of the normal vector and
also flips the distance value, resulting in a Plane that is
in the same place, but facing the opposite direction.
public static Plane operator -(Plane plane)
Parameters
plane
PlaneThe plane to negate/flip.
Returns
- Plane
The negated/flipped plane.