Struct Plane
#[repr(C)]pub struct Plane {
pub normal: Vector3,
pub d: f32,
}
Expand description
3D plane in Hessian normal form.
The Hessian form defines all points point
which satisfy the equation
dot(normal, point) + d == 0
, where normal
is the normal vector and d
the distance from the origin.
Note: almost all methods on Plane
require that the normal
vector have
unit length and will panic if this invariant is violated. This is not separately
annotated for each method.
§Godot docs
Fields§
§normal: Vector3
Normal vector pointing away from the plane.
d: f32
Distance between the plane and the origin point.
Implementations§
§impl Plane
impl Plane
pub fn new(unit_normal: Vector3, d: f32) -> Plane
pub fn new(unit_normal: Vector3, d: f32) -> Plane
Creates a new Plane
from the normal
and the distance from the origin d
.
§Panics
In contrast to construction via Plane { normal, d }
, this verifies that normal
has unit length, and will
panic if this is not the case.
Godot equivalent: Plane(Vector3 normal, float d)
pub fn from_normal_at_origin(normal: Vector3) -> Plane
pub fn from_normal_at_origin(normal: Vector3) -> Plane
Create a new Plane
through the origin from a normal.
§Panics
See Self::new()
.
Godot equivalent: Plane(Vector3 normal)
pub fn from_point_normal(point: Vector3, normal: Vector3) -> Plane
pub fn from_point_normal(point: Vector3, normal: Vector3) -> Plane
Create a new Plane
from a normal and a point in the plane.
§Panics
See Self::new()
.
Godot equivalent: Plane(Vector3 normal, Vector3 point)
pub fn from_components(nx: f32, ny: f32, nz: f32, d: f32) -> Plane
pub fn from_components(nx: f32, ny: f32, nz: f32, d: f32) -> Plane
Creates a new Plane
from normal and origin distance.
nx
, ny
, nz
are used for the normal
vector.
d
is the distance from the origin.
§Panics
See Self::new()
.
Godot equivalent: Plane(float a, float b, float c, float d)
pub fn from_points(a: Vector3, b: Vector3, c: Vector3) -> Plane
pub fn from_points(a: Vector3, b: Vector3, c: Vector3) -> Plane
Creates a new Plane
from three points, given in clockwise order.
§Panics
Will panic if all three points are colinear.
Godot equivalent: Plane(Vector3 point1, Vector3 point2, Vector3 point3)
pub fn invalid() -> Plane
pub fn invalid() -> Plane
Creates a new Plane
with default values. This new Plane
will be invalid.
Godot equivalent: Plane()
pub fn distance_to(self, point: Vector3) -> f32
pub fn distance_to(self, point: Vector3) -> f32
Finds the shortest distance between the plane and a point.
The distance will be positive if point
is above the plane, and will be negative if
point
is below the plane.
pub fn center(self) -> Vector3
pub fn center(self) -> Vector3
Finds the center point of the plane.
Godot equivalent: Plane.get_center()
pub fn contains_point(self, point: Vector3, tolerance: Option<f32>) -> bool
pub fn contains_point(self, point: Vector3, tolerance: Option<f32>) -> bool
Finds whether a point is inside the plane or not.
A point is considered part of the plane if its distance to it is less or equal than
CMP_EPSILON
.
Godot equivalent: Plane.has_point(Vector3 point, float tolerance=1e-05)
pub fn intersect_3(self, b: Plane, c: Plane) -> Option<Vector3>
pub fn intersect_3(self, b: Plane, c: Plane) -> Option<Vector3>
Finds the intersection point of three planes.
If no intersection point is found, None
will be returned.
pub fn intersect_ray(self, from: Vector3, dir: Vector3) -> Option<Vector3>
pub fn intersect_ray(self, from: Vector3, dir: Vector3) -> Option<Vector3>
Finds the intersection point of the plane with a ray.
The ray starts at position from
and has direction vector dir
, i.e. it is unbounded in one direction.
If no intersection is found (the ray is parallel to the plane or points away from it), None
will be returned.
pub fn intersect_segment(self, from: Vector3, to: Vector3) -> Option<Vector3>
pub fn intersect_segment(self, from: Vector3, to: Vector3) -> Option<Vector3>
Finds the intersection point of the plane with a line segment.
The segment starts at position ‘from’ and ends at position ‘to’, i.e. it is bounded at two directions.
If no intersection is found (the segment is parallel to the plane or does not intersect it), None
will be returned.
pub fn is_finite(self) -> bool
pub fn is_finite(self) -> bool
Returns true
if the plane is finite by calling is_finite
on normal
and d
.
pub fn is_point_over(self, point: Vector3) -> bool
pub fn is_point_over(self, point: Vector3) -> bool
Returns true
if point
is located above the plane.
pub fn normalized(self) -> Plane
pub fn normalized(self) -> Plane
Returns a copy of the plane with its normal
and d
scaled to the unit length.
A normal
length of 0.0
would return a plane with its normal
and d
being Vector3::ZERO
and 0.0
respectively.
Trait Implementations§
§impl ApproxEq for Plane
impl ApproxEq for Plane
§fn approx_eq(&self, other: &Plane) -> bool
fn approx_eq(&self, other: &Plane) -> bool
Finds whether the two planes are approximately equal.
Returns if the two Plane
s are approximately equal, by comparing normal
and d
separately.
If one plane is a negation of the other (both normal
and d
have opposite signs), they are considered approximately equal.
§impl Export for Plane
impl Export for Plane
§fn export_hint() -> PropertyHintInfo
fn export_hint() -> PropertyHintInfo
§impl FromGodot for Plane
impl FromGodot for Plane
§fn try_from_godot(
via: <Plane as GodotConvert>::Via,
) -> Result<Plane, ConvertError>
fn try_from_godot( via: <Plane as GodotConvert>::Via, ) -> Result<Plane, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl Mul<Plane> for Transform3D
impl Mul<Plane> for Transform3D
§impl ParamType for Plane
impl ParamType for Plane
§fn owned_to_arg<'v>(self) -> <Plane as ParamType>::Arg<'v>
fn owned_to_arg<'v>(self) -> <Plane as ParamType>::Arg<'v>
impl AsArg<T>
. Read more§impl ToGodot for Plane
impl ToGodot for Plane
§impl Var for Plane
impl Var for Plane
fn get_property(&self) -> <Plane as GodotConvert>::Via
fn set_property(&mut self, value: <Plane as GodotConvert>::Via)
§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.