Class Plane
A plane in Hessian normal form.
Remarks
Represents a normalized plane equation. normal is the normal of the plane (a, b, c normalized), and d is the distance from the origin to the plane (in the direction of "normal"). "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing.
See Also
Constructors
Plane
Constructs a default-initialized Plane with all components set to 0
.
Plane Plane
Plane(Plane)
Constructs a Plane as a copy of the given Plane.
Plane Plane(Plane from)
Parameters
from
Plane
Plane(float, float, float, float)
Creates a plane from the four parameters. The three components of the resulting plane's normal are a
, b
and c
, and the plane has a distance of d
from the origin.
Plane Plane(float a, float b, float c, float d)
Parameters
Plane(Vector3)
Creates a plane from the normal vector. The plane will intersect the origin.
The normal
of the plane must be a unit vector.
Plane Plane(Vector3 normal)
Parameters
normal
Vector3
Plane(Vector3, float)
Creates a plane from the normal vector and the plane's distance from the origin.
The normal
of the plane must be a unit vector.
Plane Plane(Vector3 normal, float d)
Parameters
Plane(Vector3, Vector3)
Creates a plane from the normal vector and a point on the plane.
The normal
of the plane must be a unit vector.
Plane Plane(Vector3 normal, Vector3 point)
Parameters
Plane(Vector3, Vector3, Vector3)
Creates a plane from the three points, given in clockwise order.
Plane Plane(Vector3 point1, Vector3 point2, Vector3 point3)
Parameters
Fields
PLANE_YZ
A plane that extends in the Y and Z axes (normal vector points +X).
const PLANE_YZ = Plane(1, 0, 0, 0)
PLANE_XZ
A plane that extends in the X and Z axes (normal vector points +Y).
const PLANE_XZ = Plane(0, 1, 0, 0)
PLANE_XY
A plane that extends in the X and Y axes (normal vector points +Z).
const PLANE_XY = Plane(0, 0, 1, 0)
Properties
d
The distance from the origin to the plane, expressed in terms of normal (according to its direction and magnitude). Actual absolute distance from the origin to the plane can be calculated as abs(d) / normal.length()
(if normal has zero length then this Plane does not represent a valid plane).
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.
var d : float = 0.0
Property Value
normal
The normal of the plane, typically a unit vector. Shouldn't be a zero vector as Plane with such normal does not represent a valid plane.
In the scalar equation of the plane ax + by + cz = d
, this is the vector (a, b, c)
, where d
is the d property.
var normal : Vector3 = Vector3(0, 0, 0)
Property Value
x
The X component of the plane's normal vector.
var x : float = 0.0
Property Value
y
The Y component of the plane's normal vector.
var y : float = 0.0
Property Value
z
The Z component of the plane's normal vector.
var z : float = 0.0
Property Value
Methods
distance_to(Vector3)
Qualifiers: const
Returns the shortest distance from the plane to the position point
. If the point is above the plane, the distance will be positive. If below, the distance will be negative.
float distance_to(Vector3 point)
Parameters
point
Vector3
get_center
Qualifiers: const
Returns the center of the plane.
Vector3 get_center
has_point(Vector3, float)
Qualifiers: const
Returns true
if point
is inside the plane. Comparison uses a custom minimum tolerance
threshold.
bool has_point(Vector3 point, float tolerance)
Parameters
intersect_3(Plane, Plane)
Qualifiers: const
Returns the intersection point of the three planes b
, c
and this plane. If no intersection is found, null
is returned.
Variant intersect_3(Plane b, Plane c)
Parameters
intersects_ray(Vector3, Vector3)
Qualifiers: const
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.
Variant intersects_ray(Vector3 from, Vector3 dir)
Parameters
intersects_segment(Vector3, Vector3)
Qualifiers: const
Returns the intersection point of a segment from position from
to position to
with this plane. If no intersection is found, null
is returned.
Variant intersects_segment(Vector3 from, Vector3 to)
Parameters
is_equal_approx(Plane)
Qualifiers: const
Returns true
if this plane and to_plane
are approximately equal, by running @GlobalScope.is_equal_approx on each component.
bool is_equal_approx(Plane to_plane)
Parameters
to_plane
Plane
is_finite
Qualifiers: const
Returns true
if this plane is finite, by calling @GlobalScope.is_finite on each component.
bool is_finite
is_point_over(Vector3)
Qualifiers: const
Returns true
if point
is located above the plane.
bool is_point_over(Vector3 point)
Parameters
point
Vector3
normalized
Qualifiers: const
Returns a copy of the plane, with normalized normal (so it's a unit vector). Returns Plane(0, 0, 0, 0)
if normal can't be normalized (it has zero length).
Plane normalized
project(Vector3)
Qualifiers: const
Returns the orthogonal projection of point
into a point in the plane.
Vector3 project(Vector3 point)
Parameters
point
Vector3
Operators
!= (Plane)
Returns true
if the planes are not equal.
Note: Due to floating-point precision errors, consider using Plane.is_equal_approx instead, which is more reliable.
bool != (Plane right)
Parameters
right
Plane
* (Transform3D)
Inversely transforms (multiplies) the Plane by the given Transform3D transformation matrix.
plane * transform
is equivalent to transform.affine_inverse() * plane
. See affine_inverse.
Plane * (Transform3D right)
Parameters
right
Transform3D
== (Plane)
Returns true
if the planes are exactly equal.
Note: Due to floating-point precision errors, consider using Plane.is_equal_approx instead, which is more reliable.
bool == (Plane right)
Parameters
right
Plane
unary+
Returns the same value as if the +
was not there. Unary +
does nothing, but sometimes it can make your code more readable.
Plane unary+
unary-
Returns the negative value of the Plane. This is the same as writing 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.
Plane unary-