rapier3d::geometry

Type Alias Segment

Source
pub type Segment = Segment;
Expand description

A segment shape.

Aliased Type§

struct Segment {
    pub a: OPoint<f32, Const<3>>,
    pub b: OPoint<f32, Const<3>>,
}

Fields§

§a: OPoint<f32, Const<3>>

The segment first point.

§b: OPoint<f32, Const<3>>

The segment second point.

Implementations

Source§

impl Segment

Source

pub fn aabb(&self, pos: &Isometry<f32, Unit<Quaternion<f32>>, 3>) -> Aabb

Computes the world-space Aabb of this segment, transformed by pos.

Source

pub fn local_aabb(&self) -> Aabb

Computes the local-space Aabb of this segment.

Source§

impl Segment

Source

pub fn bounding_sphere( &self, pos: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ) -> BoundingSphere

Computes the world-space bounding sphere of this segment, transformed by pos.

Source

pub fn local_bounding_sphere(&self) -> BoundingSphere

Computes the local-space bounding sphere of this segment.

Source§

impl Segment

Source

pub fn canonical_split( &self, axis: usize, bias: f32, epsilon: f32, ) -> SplitResult<Segment>

Splits this segment along the given canonical axis.

This will split the segment by a plane with a normal with it’s axis-th component set to 1. The splitting plane is shifted wrt. the origin by the bias (i.e. it passes through the point equal to normal * bias).

§Result

Returns the result of the split. The first shape returned is the piece lying on the negative half-space delimited by the splitting plane. The second shape returned is the piece lying on the positive half-space delimited by the splitting plane.

Source

pub fn local_split( &self, local_axis: &Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>, bias: f32, epsilon: f32, ) -> SplitResult<Segment>

Splits this segment by a plane identified by its normal local_axis and the bias (i.e. the plane passes through the point equal to normal * bias).

Source

pub fn local_split_and_get_intersection( &self, local_axis: &Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>, bias: f32, epsilon: f32, ) -> (SplitResult<Segment>, Option<(OPoint<f32, Const<3>>, f32)>)

Split a segment with a plane.

This returns the result of the splitting operation, as well as the intersection point (and barycentric coordinate of this point) with the plane. The intersection point is None if the plane is parallel or near-parallel to the segment.

Source§

impl Segment

Source

pub fn new(a: OPoint<f32, Const<3>>, b: OPoint<f32, Const<3>>) -> Segment

Creates a new segment from two points.

Source

pub fn from_array(arr: &[OPoint<f32, Const<3>>; 2]) -> &Segment

Creates the reference to a segment from the reference to an array of two points.

Source

pub fn scaled( self, scale: &Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>, ) -> Segment

Computes a scaled version of this segment.

Source

pub fn scaled_direction( &self, ) -> Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>

The direction of this segment scaled by its length.

Points from self.a toward self.b.

Source

pub fn length(&self) -> f32

The length of this segment.

Source

pub fn swap(&mut self)

Swaps the two vertices of this segment.

Source

pub fn direction( &self, ) -> Option<Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>>

The unit direction of this segment.

Points from self.a() toward self.b(). Returns None is both points are equal.

Source

pub fn scaled_planar_normal( &self, plane_axis: u8, ) -> Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>

The not-normalized counterclockwise normal of this segment, assuming it lies on the plane with the normal collinear to the given axis (0 = X, 1 = Y, 2 = Z).

Source

pub fn normal( &self, ) -> Option<Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>>

Returns None. Exists only for API similarity with the 2D parry.

Source

pub fn planar_normal( &self, plane_axis: u8, ) -> Option<Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>>

The normalized counterclockwise normal of this segment, assuming it lies on the plane with the normal collinear to the given axis (0 = X, 1 = Y, 2 = Z).

Source

pub fn transformed( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ) -> Segment

Applies the isometry m to the vertices of this segment and returns the resulting segment.

Source

pub fn point_at(&self, location: &SegmentPointLocation) -> OPoint<f32, Const<3>>

Computes the point at the given location.

Source

pub fn feature_normal( &self, feature: FeatureId, ) -> Option<Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>>

The normal of the given feature of this shape.

Trait Implementations

Source§

impl Clone for Segment

Source§

fn clone(&self) -> Segment

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
Source§

impl Debug for Segment

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<[OPoint<f32, Const<3>>; 2]> for Segment

Source§

fn from(arr: [OPoint<f32, Const<3>>; 2]) -> Segment

Converts to this type from the input type.
Source§

impl PartialEq for Segment

Source§

fn eq(&self, other: &Segment) -> 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.
Source§

impl PointQuery for Segment

Source§

fn project_local_point( &self, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> PointProjection

Projects a point on self. Read more
Source§

fn project_local_point_and_get_feature( &self, pt: &OPoint<f32, Const<3>>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self and returns the id of the feature the point was projected on.
Source§

fn project_local_point_with_max_dist( &self, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<PointProjection>

Projects a point on self, unless the projection lies further than the given max distance. Read more
Source§

fn project_point_with_max_dist( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<PointProjection>

Projects a point on self transformed by m, unless the projection lies further than the given max distance.
Source§

fn distance_to_local_point( &self, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32

Computes the minimal distance between a point and self.
Source§

fn contains_local_point(&self, pt: &OPoint<f32, Const<3>>) -> bool

Tests if the given point is inside of self.
Source§

fn project_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> PointProjection

Projects a point on self transformed by m.
Source§

fn distance_to_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> f32

Computes the minimal distance between a point and self transformed by m.
Source§

fn project_point_and_get_feature( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, ) -> (PointProjection, FeatureId)

Projects a point on the boundary of self transformed by m and returns the id of the feature the point was projected on.
Source§

fn contains_point( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, ) -> bool

Tests if the given point is inside of self transformed by m.
Source§

impl PointQueryWithLocation for Segment

Source§

type Location = SegmentPointLocation

Additional shape-specific projection information Read more
Source§

fn project_local_point_and_get_location( &self, pt: &OPoint<f32, Const<3>>, _: bool, ) -> (PointProjection, <Segment as PointQueryWithLocation>::Location)

Projects a point on self.
Source§

fn project_point_and_get_location( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, ) -> (PointProjection, Self::Location)

Projects a point on self transformed by m.
Source§

fn project_local_point_and_get_location_with_max_dist( &self, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>

Projects a point on self, with a maximum projection distance.
Source§

fn project_point_and_get_location_with_max_dist( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, pt: &OPoint<f32, Const<3>>, solid: bool, max_dist: f32, ) -> Option<(PointProjection, Self::Location)>

Projects a point on self transformed by m, with a maximum projection distance.
Source§

impl PolygonalFeatureMap for Segment

Source§

fn local_support_feature( &self, _: &Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>, out_feature: &mut PolygonalFeature, )

Compute the support polygonal face of self towards the dir.
Source§

fn is_convex_polyhedron(&self) -> bool

Is this shape a ConvexPolyhedron?
Source§

impl RayCast for Segment

Source§

fn cast_local_ray_and_get_normal( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn cast_local_ray( &self, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn intersects_local_ray(&self, ray: &Ray, max_time_of_impact: f32) -> bool

Tests whether a ray intersects this transformed shape.
Source§

fn cast_ray( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<f32>

Computes the time of impact between this transform shape and a ray.
Source§

fn cast_ray_and_get_normal( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, solid: bool, ) -> Option<RayIntersection>

Computes the time of impact, and normal between this transformed shape and a ray.
Source§

fn intersects_ray( &self, m: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ray: &Ray, max_time_of_impact: f32, ) -> bool

Tests whether a ray intersects this transformed shape.
Source§

impl Shape for Segment

Source§

fn clone_dyn(&self) -> Box<dyn Shape>

Clones this shape into a boxed trait-object. Read more
Source§

fn scale_dyn( &self, scale: &Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>, _num_subdivisions: u32, ) -> Option<Box<dyn Shape>>

Scales this shape by scale into a boxed trait-object. Read more
Source§

fn compute_local_aabb(&self) -> Aabb

Computes the Aabb of this shape.
Source§

fn compute_local_bounding_sphere(&self) -> BoundingSphere

Computes the bounding-sphere of this shape.
Source§

fn compute_aabb( &self, position: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ) -> Aabb

Computes the Aabb of this shape with the given position.
Source§

fn mass_properties(&self, _density: f32) -> MassProperties

Compute the mass-properties of this shape given its uniform density.
Source§

fn is_convex(&self) -> bool

Is this shape known to be convex? Read more
Source§

fn ccd_thickness(&self) -> f32

Source§

fn ccd_angular_thickness(&self) -> f32

Source§

fn shape_type(&self) -> ShapeType

Gets the type tag of this shape.
Source§

fn as_typed_shape(&self) -> TypedShape<'_>

Gets the underlying shape as an enum.
Source§

fn as_support_map(&self) -> Option<&dyn SupportMap>

Converts this shape into its support mapping, if it has one.
Source§

fn as_polygonal_feature_map(&self) -> Option<(&dyn PolygonalFeatureMap, f32)>

Converts this shape to a polygonal feature-map, if it is one.
Source§

fn feature_normal_at_point( &self, feature: FeatureId, _point: &OPoint<f32, Const<3>>, ) -> Option<Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>>

The shape’s normal at the given point located on a specific feature.
Source§

fn clone_box(&self) -> Box<dyn Shape>

👎Deprecated: renamed to clone_dyn
Clones this shape into a boxed trait-object. Read more
Source§

fn compute_bounding_sphere( &self, position: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ) -> BoundingSphere

Computes the bounding-sphere of this shape with the given position.
Source§

fn as_composite_shape(&self) -> Option<&dyn SimdCompositeShape>

Source§

fn compute_swept_aabb( &self, start_pos: &Isometry<f32, Unit<Quaternion<f32>>, 3>, end_pos: &Isometry<f32, Unit<Quaternion<f32>>, 3>, ) -> Aabb

Computes the swept Aabb of this shape, i.e., the space it would occupy by moving from the given start position to the given end position.
Source§

impl SupportMap for Segment

Source§

fn local_support_point( &self, dir: &Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>, ) -> OPoint<f32, Const<3>>

Source§

fn local_support_point_toward( &self, dir: &Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>, ) -> OPoint<f32, Const<3>>

Same as self.local_support_point except that dir is normalized.
Source§

fn support_point( &self, transform: &Isometry<f32, Unit<Quaternion<f32>>, 3>, dir: &Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>, ) -> OPoint<f32, Const<3>>

Source§

fn support_point_toward( &self, transform: &Isometry<f32, Unit<Quaternion<f32>>, 3>, dir: &Unit<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>, ) -> OPoint<f32, Const<3>>

Same as self.support_point except that dir is normalized.
Source§

impl Copy for Segment

Source§

impl StructuralPartialEq for Segment