godot::builtin

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

Plane (stable)

Fields§

§normal: Vector3

Normal vector pointing away from the plane.

§d: f32

Distance between the plane and the origin point.

Implementations§

§

impl 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

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

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

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

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

Creates a new Plane with default values. This new Plane will be invalid.

Godot equivalent: Plane()

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

Finds the center point of the plane.

Godot equivalent: Plane.get_center()

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>

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>

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>

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

Returns true if the plane is finite by calling is_finite on normal and d.

pub fn is_point_over(self, point: Vector3) -> bool

Returns true if point is located above the 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.

pub fn project(self, point: Vector3) -> Vector3

Returns the orthogonal projection of point to the plane.

Trait Implementations§

§

impl ApproxEq for Plane

§

fn approx_eq(&self, other: &Plane) -> bool

Finds whether the two planes are approximately equal.

Returns if the two Planes 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 Clone for Plane

§

fn clone(&self) -> Plane

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Plane

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Display for Plane

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats Plane to match Godot’s string representation.

§Example
use godot::prelude::*;
let plane = Plane::new(Vector3::new(1.0, 0.0, 0.0), 1.0);
assert_eq!(format!("{}", plane), "[N: (1, 0, 0), D: 1]");
§

impl Export for Plane

§

fn export_hint() -> PropertyHintInfo

The export info to use for an exported field of this type, if no other export info is specified.
§

impl FromGodot for Plane

§

fn try_from_godot( via: <Plane as GodotConvert>::Via, ) -> Result<Plane, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
§

fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

Performs the conversion from a Variant, returning Err on failure.
§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a Variant. Read more
§

impl GodotConvert for Plane

§

type Via = Plane

The type through which Self is represented in Godot.
§

impl Mul<Plane> for Transform3D

§

type Output = Plane

The resulting type after applying the * operator.
§

fn mul(self, rhs: Plane) -> <Transform3D as Mul<Plane>>::Output

Performs the * operation. Read more
§

impl Neg for Plane

§

fn neg(self) -> <Plane as Neg>::Output

Returns the negative value of the plane by flipping both the normal and the distance value. Meaning it creates a plane that is in the same place, but facing the opposite direction.

§

type Output = Plane

The resulting type after applying the - operator.
§

impl ParamType for Plane

§

fn owned_to_arg<'v>(self) -> <Plane as ParamType>::Arg<'v>

Converts an owned value to the canonical argument type, which can be passed to impl AsArg<T>. Read more
§

impl PartialEq for Plane

§

fn eq(&self, other: &Plane) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl ToGodot for Plane

§

type ToVia<'v> = <Plane as GodotConvert>::Via

Target type of to_godot(), which can differ from Via for pass-by-reference types. Read more
§

fn to_godot(&self) -> <Plane as ToGodot>::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
§

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

Specific property hints, only override if they deviate from GodotType::property_info, e.g. for enums/newtypes.
§

impl ArrayElement for Plane

§

impl AsArg<Plane> for Plane

§

impl Copy for Plane

§

impl GodotType for Plane

§

impl StructuralPartialEq for Plane

Auto Trait Implementations§

§

impl Freeze for Plane

§

impl RefUnwindSafe for Plane

§

impl Send for Plane

§

impl Sync for Plane

§

impl Unpin for Plane

§

impl UnwindSafe for Plane

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.