Rect3D
struct · ferroui-media3d · v0.5.0
struct Rect3D
An axis-aligned box in 3D space: a location (its corner of least coordinates) and a size, with
double-precision values (WPF's System.Windows.Media.Media3D.Rect3D). The bounds of the 3D
scene model are boxes.
Rect3D::EMPTY is the box of nothing: its location is positive infinity and its size is
Size3D::EMPTY. It contains nothing, intersects nothing, and is the identity of
union. The members that WPF guards with exceptions return a Size3DError.
Members
EMPTYnewfrom_location_sizeis_emptyxyzsize_xsize_ysize_zlocationsizeset_xset_yset_zset_size_xset_size_yset_size_zset_locationset_sizecontainscontains_xyzcontains_rectintersects_withintersectintersect_rectsunionunion_pointunion_rectsunion_rect_pointoffsetoffset_xyzoffset_rectparse
EMPTY
const EMPTY: Rect3D
The box of nothing (WPF's Rect3D.Empty).
new
fn new(x: f64, y: f64, z: f64, size_x: f64, size_y: f64, size_z: f64) -> Result<Self, Size3DError>
A box with the given location and size; Size3DError::NegativeDimension when a size is
negative.
from_location_size
fn from_location_size(location: Point3D, size: Size3D) -> Self
A box at the location with the size; Rect3D::EMPTY when the size is empty.
is_empty
fn is_empty(self: &Self) -> bool
Whether this is Rect3D::EMPTY.
x
fn x(self: &Self) -> f64
The X coordinate of the location.
y
fn y(self: &Self) -> f64
The Y coordinate of the location.
z
fn z(self: &Self) -> f64
The Z coordinate of the location.
size_x
fn size_x(self: &Self) -> f64
The extent along the X axis.
size_y
fn size_y(self: &Self) -> f64
The extent along the Y axis.
size_z
fn size_z(self: &Self) -> f64
The extent along the Z axis.
location
fn location(self: &Self) -> Point3D
The corner of least coordinates.
size
fn size(self: &Self) -> Size3D
The size; Size3D::EMPTY for the empty box.
set_x
fn set_x(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the X coordinate of the location; the empty box cannot be moved.
set_y
fn set_y(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the Y coordinate of the location; the empty box cannot be moved.
set_z
fn set_z(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the Z coordinate of the location; the empty box cannot be moved.
set_size_x
fn set_size_x(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the extent along the X axis; the empty box cannot be changed, and a size is not negative.
set_size_y
fn set_size_y(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the extent along the Y axis; the empty box cannot be changed, and a size is not negative.
set_size_z
fn set_size_z(self: &mut Self, value: f64) -> Result<(), Size3DError>
Sets the extent along the Z axis; the empty box cannot be changed, and a size is not negative.
set_location
fn set_location(self: &mut Self, location: Point3D) -> Result<(), Size3DError>
Sets the location; the empty box cannot be moved.
set_size
fn set_size(self: &mut Self, size: Size3D) -> Result<(), Size3DError>
Sets the size: the empty size makes this the empty box; another size cannot be given to the empty box.
contains
fn contains(self: &Self, point: Point3D) -> bool
Whether the point is in the box or on its faces; never for the empty box.
contains_xyz
fn contains_xyz(self: &Self, x: f64, y: f64, z: f64) -> bool
Whether the point with the coordinates is in the box or on its faces; never for the empty box.
contains_rect
fn contains_rect(self: &Self, rect: Rect3D) -> bool
Whether the box is inside this one (faces may touch); never when either is empty.
intersects_with
fn intersects_with(self: &Self, rect: Rect3D) -> bool
Whether the boxes share a point (touching faces count); never when either is empty.
intersect
fn intersect(self: &mut Self, rect: Rect3D)
Makes this box the intersection of the two: Rect3D::EMPTY when they do not intersect.
intersect_rects
fn intersect_rects(rect1: Rect3D, rect2: Rect3D) -> Rect3D
The intersection of two boxes (WPF's static Rect3D.Intersect).
union
fn union(self: &mut Self, rect: Rect3D)
Makes this box the smallest box that contains both. The empty box adds nothing.
union_point
fn union_point(self: &mut Self, point: Point3D)
Makes this box the smallest box that contains it and the point.
union_rects
fn union_rects(rect1: Rect3D, rect2: Rect3D) -> Rect3D
The smallest box that contains both boxes (WPF's static Rect3D.Union).
union_rect_point
fn union_rect_point(rect: Rect3D, point: Point3D) -> Rect3D
The smallest box that contains the box and the point (WPF's static Rect3D.Union of a
box and a point).
offset
fn offset(self: &mut Self, offset: Vector3D) -> Result<(), Size3DError>
Moves the box by the vector; the empty box cannot be moved.
offset_xyz
fn offset_xyz(self: &mut Self, offset_x: f64, offset_y: f64, offset_z: f64) -> Result<(), Size3DError>
Moves the box by the given amounts; the empty box cannot be moved.
offset_rect
fn offset_rect(rect: Rect3D, offset: Vector3D) -> Result<Rect3D, Size3DError>
The box moved by the vector (WPF's static Rect3D.Offset); the empty box cannot be moved.
parse
fn parse(text: &str) -> Result<Self, FormatError>
Parses the text form: "Empty", or "x,y,z,sizeX,sizeY,sizeZ" (commas, white space or
both between the numbers) in the invariant culture, with no negative size.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherMarkupTypedCloneCopyDebugStructuralPartialEqPartialEqDefaultFromStrDisplay
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.