Expand description
A 3-dimensional plane primitive.
Represented by a normal and the signed distance from the origin to the plane.
This representation can specify any possible plane in 3D space using 4 parameters (disregarding floating point precision). There are duplicate representations caused by negating both parameters, but that’s fine - you could view it as an oriented plane.
A point point is on the plane when plane.normal.dot(point) + plane.d = 0.
Fields
normal: Vec3Normal vector
d: f32Distance
Implementations
sourceimpl Plane3
impl Plane3
sourcepub fn from_normal_dist(normal: Vec3, d: f32) -> Plane3
pub fn from_normal_dist(normal: Vec3, d: f32) -> Plane3
From the plane normal and a distance d so that for all points on the plane:
normal.dot(point) + d = 0.
sourcepub fn from_normal_point(normal: Vec3, point: Vec3) -> Plane3
pub fn from_normal_point(normal: Vec3, point: Vec3) -> Plane3
From the plane normal and a point on the plane.
sourcepub fn normalized(&self) -> Plane3
pub fn normalized(&self) -> Plane3
Get normalized plane
sourcepub fn distance(&self, p: Vec3) -> f32
pub fn distance(&self, p: Vec3) -> f32
Computes the distance between the plane and the point p. The returned distance is only correct if the plane is normalized or the distance is zero.
sourcepub fn intersect_ray(&self, origin: Vec3, dir: Vec3) -> (bool, f32)
pub fn intersect_ray(&self, origin: Vec3, dir: Vec3) -> (bool, f32)
The bool is whether the plane was hit or not.
If false, the ray was either perpendicular to the plane, or the ray shot away from the plane.
The returned f32 is the t value so you can easily compute the intersection point through “origin + dir * t”.