#[repr(C)]pub struct Pose {
pub position: Vec3,
pub orientation: Quat,
}
Expand description
Pose represents a location and orientation in space, excluding scale! The default value of a Pose use Pose.Identity . https://stereokit.net/Pages/StereoKit/Pose.html
§Examples
use stereokit_rust::{ui::Ui, maths::{Vec3, Pose, Matrix}, model::Model };
let plane = Model::from_file("plane.glb", None).unwrap_or_default();
let bounds = plane.get_bounds();
let mut handle_pose = Pose::look_at(
[0.0, -5.5, -10.0], (Vec3::Z + Vec3::X) * 100.0);
let mut window_pose = Pose::new(
[0.0, 0.05, 0.90], Some([0.0, 200.0, 0.0].into()));
filename_scr = "screenshots/pose.jpeg";
test_screenshot!( // !!!! Get a proper main loop !!!!
Ui::handle_begin( "Model Handle", &mut handle_pose,
bounds, false, None, None);
plane.draw(token, Matrix::IDENTITY, None, None);
Ui::handle_end();
Ui::window_begin("My Window", &mut window_pose, None, None, None);
Ui::text("My Text", None, None, None, Some(0.14), None, None);
Ui::window_end();
);

Fields§
§position: Vec3
§orientation: Quat
Implementations§
Source§impl Pose
impl Pose
Sourcepub const IDENTITY: Pose
pub const IDENTITY: Pose
The default Pose: Origin with Quat::IDENTITY orientation. https://stereokit.net/Pages/StereoKit/Pose/Identity.html
Sourcepub const ZERO: Pose
pub const ZERO: Pose
Zero may be encountered when testing some crate::system::Input
crate::system::Pointer
and crate::system::Controller
Sourcepub fn new(position: impl Into<Vec3>, orientation: Option<Quat>) -> Self
pub fn new(position: impl Into<Vec3>, orientation: Option<Quat>) -> Self
Basic initialization constructor! Just copies in the provided values directly, and uses Identity for the orientation. https://stereokit.net/Pages/StereoKit/Pose/Pose.html
§Examples
use stereokit_rust::maths::{Vec3, Pose};
let mut handle_pose = Pose::new( [0.0, 0.05, 0.90], None);
let mut window_pose = Pose::new(
[0.0, 0.05, 0.90], Some([0.0, 180.0 * 4.0, 0.0].into()));
assert_eq!(handle_pose, window_pose);
Sourcepub fn lerp(a: impl Into<Pose>, b: impl Into<Pose>, percent: f32) -> Self
pub fn lerp(a: impl Into<Pose>, b: impl Into<Pose>, percent: f32) -> Self
Interpolates between two poses! It is unclamped, so values outside of (0,1) will extrapolate their position. https://stereokit.net/Pages/StereoKit/Pose/Lerp.html
§Examples
use stereokit_rust::maths::{Vec3, Pose};
let mut pose1 = Pose::new( Vec3::Y, None);
let mut pose2 = Pose::new( Vec3::Y, Some([0.0, 45.0, 0.0].into()));
let mut pose3 = Pose::new( Vec3::Y, Some([0.0, 90.0, 0.0].into()));
assert_eq!(Pose::lerp(pose1, pose3, 0.5), pose2);
Sourcepub fn look_at(from: impl Into<Vec3>, at: impl Into<Vec3>) -> Self
pub fn look_at(from: impl Into<Vec3>, at: impl Into<Vec3>) -> Self
Creates a Pose that looks from one location in the direction of another location. This leaves “Up” as the +Y axis. https://stereokit.net/Pages/StereoKit/Pose/LookAt.html
§Examples
use stereokit_rust::maths::{Vec3, Pose};
let mut pose1 = Pose::look_at(Vec3::ZERO, Vec3::NEG_Z );
assert_eq!(pose1, Pose::default());
Sourcepub fn to_matrix(&self, scale: Option<Vec3>) -> Matrix
pub fn to_matrix(&self, scale: Option<Vec3>) -> Matrix
Converts this pose into a transform matrix. https://stereokit.net/Pages/StereoKit/Pose/ToMatrix.html
- scale - Let you add a scale factor if needed.
§Examples
use stereokit_rust::maths::{Vec3, Matrix, Pose};
let pose1 = Pose::IDENTITY;
assert_eq!(pose1.to_matrix(None), Matrix::IDENTITY);
Sourcepub fn to_matrix_inv(&self, scale: Option<Vec3>) -> Matrix
pub fn to_matrix_inv(&self, scale: Option<Vec3>) -> Matrix
Converts this pose into the inverse of the Pose’s transform matrix. This can be used to transform points from the space represented by the Pose into world space. https://stereokit.net/Pages/StereoKit/Pose/ToMatrixInv.html
- scale - A scale vector! Vec3.One would be an identity scale.
§Examples
use stereokit_rust::maths::{Vec3, Matrix, Pose};
let pose1 = Pose::IDENTITY;
assert_eq!(pose1.to_matrix_inv(None), Matrix::IDENTITY);
assert_eq!(pose1.to_matrix_inv(Some(Vec3::new(0.5, 0.25, 0.125))),
[2.0, 0.0, 0.0, 0.0,
0.0, 4.0, 0.0, 0.0,
0.0, 0.0, 8.0, 0.0,
0.0, 0.0, 0.0, 1.0].into());
Sourcepub fn get_forward(&self) -> Vec3
pub fn get_forward(&self) -> Vec3
Calculates the forward direction from this pose. This is done by multiplying the orientation with Vec3::new(0, 0, -1). Remember that Forward points down the -Z axis! https://stereokit.net/Pages/StereoKit/Pose/Forward.html
§Examples
use stereokit_rust::maths::{Vec3, Pose};
let pose1 = Pose::default();
assert_eq!(pose1.get_forward(), Vec3::NEG_Z);
let pose2 = Pose::look_at(Vec3::new(1.0, 0.0, 0.0), Vec3::new(0.0, 0.0, 0.0));
assert_eq!(pose2.get_forward(), Vec3::NEG_X);
Sourcepub fn get_ray(&self) -> Ray
pub fn get_ray(&self) -> Ray
This creates a ray starting at the Pose’s position, and pointing in the ‘Forward’ direction. The Ray direction is a unit vector/normalized. https://stereokit.net/Pages/StereoKit/Pose/Ray.html
see also Ray
§Examples
use stereokit_rust::maths::{Vec3, Pose, Ray};
let pose1 = Pose::default();
let ray_forward = Ray::new( Vec3::ZERO, Vec3::NEG_Z);
assert_eq!(pose1.get_ray(), ray_forward);
let pose2 = Pose::look_at(Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 2.0, 0.0));
let ray_to_the_left = Ray::new(Vec3::X, Vec3::Y);
assert_eq!(pose2.get_ray(), ray_to_the_left);
Sourcepub fn get_right(&self) -> Vec3
pub fn get_right(&self) -> Vec3
Calculates the right (+X) direction from this pose. This is done by multiplying the orientation with Vec3.Right. https://stereokit.net/Pages/StereoKit/Pose/Right.html
§Examples
use stereokit_rust::maths::{Vec3, Pose, Ray};
let pose1 = Pose::default();
assert_eq!(pose1.get_right(), Vec3::X);
let pose2 = Pose::look_at(Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 2.0, 3.0));
assert_eq!(pose2.get_right(), Vec3::NEG_X);
Sourcepub fn get_up(&self) -> Vec3
pub fn get_up(&self) -> Vec3
Calculates the up (+Y) direction from this pose. This is done by multiplying the orientation with Vec3.Up. https://stereokit.net/Pages/StereoKit/Pose/Up.html
§Examples
use stereokit_rust::maths::{Vec3, Pose, Ray};
let pose1 = Pose::default();
assert_eq!(pose1.get_up(), Vec3::Y);
let pose2 = Pose::look_at(Vec3::new(1.0, 0.0, 0.0), Vec3::new(2.0, 0.0, 3.0));
assert_eq!(pose2.get_up(), Vec3::Y);
Trait Implementations§
Source§impl Default for Pose
impl Default for Pose
Source§fn default() -> Self
fn default() -> Self
Position is Vec3::ZERO, and orientation is Quat::IDENTITY (no rotation) https://stereokit.net/Pages/StereoKit/Pose/Identity.html
Source§impl Display for Pose
impl Display for Pose
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
A string representation of the Pose, in the format of “position, Forward”. Mostly for debug visualization. https://stereokit.net/Pages/StereoKit/Pose/ToString.html
§Examples
use stereokit_rust::maths::{Vec3, Pose};
let pose = Pose::new([1.1, 2.0, 3.0], Some([0.0, 90.0, 0.0].into()));
assert_eq!(format!("{}", pose),
"[position:[x:1.1, y:2, z:3] forward:[x:0, y:0.70710677, z:0, w:0.7071067]]");
Source§impl Mul<Matrix> for Pose
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting
properly for the Pose’s quaternion.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl Mul<Matrix> for Pose
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting properly for the Pose’s quaternion. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pose
Source§fn mul(self, rhs: Matrix) -> Self::Output
fn mul(self, rhs: Matrix) -> Self::Output
§Examples
use stereokit_rust::maths::{Pose, Vec3, Matrix};
let transform = Matrix::t([1.0, 2.0, 3.0]);
let pose = Pose::new([0.0, 0.0, 0.0], None);
let transformed_pose = pose * transform;
assert_eq!(transformed_pose, Pose::new([1.0, 2.0, 3.0], None));
Source§impl Mul<Pose> for Matrix
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting
properly for the Pose’s quaternion.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl Mul<Pose> for Matrix
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting properly for the Pose’s quaternion. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pose
Source§impl MulAssign<Matrix> for Pose
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting
properly for the Pose’s quaternion.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl MulAssign<Matrix> for Pose
Transforms a Pose by the Matrix! The position and orientation are both transformed by the matrix, accounting properly for the Pose’s quaternion. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pose
Source§fn mul_assign(&mut self, rhs: Matrix)
fn mul_assign(&mut self, rhs: Matrix)
§Examples
use stereokit_rust::maths::{Pose, Vec3, Matrix};
let mut pose = Pose::new([0.0, 0.0, 0.0], None);
let transform = Matrix::t([1.0, 2.0, 3.0]);
pose *= transform;
assert_eq!(pose, Pose::new([1.0, 2.0, 3.0], None));
impl Copy for Pose
impl StructuralPartialEq for Pose
Auto Trait Implementations§
impl Freeze for Pose
impl RefUnwindSafe for Pose
impl Send for Pose
impl Sync for Pose
impl Unpin for Pose
impl UnwindSafe for Pose
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.