#[repr(C)]pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
Expand description
A vector with 3 components: x, y, z. This can represent a point in space, a directional vector, or any other sort of value with 3 dimensions to it!
StereoKit uses a right-handed coordinate system, where +x is to the right, +y is upwards, and -z is forward. https://stereokit.net/Pages/StereoKit/Vec3.html
see also glam::Vec3
§Examples
use stereokit_rust::maths::Vec3;
let vec3 = Vec3::new(1.0, 2.0, 3.0);
let vec3a = Vec3 { x: 1.0, y: 2.0, z:3.0 };
let vec3b = Vec3::X + Vec3::Y * 2.0;
let vec3c: Vec3 = [1.0, 2.0, 3.0].into();
assert_eq!(vec3, vec3a);
assert_eq!(vec3a + vec3b, Vec3 { x: 2.0, y: 4.0, z: 3.0 });
assert_eq!(vec3c, Vec3 { x: 1.0, y: 2.0, z: 3.0 });
assert_eq!(vec3a.length_sq(), 14.0);
assert_eq!(vec3a.magnitude(), (14.0f32).sqrt());
assert! (vec3a.get_normalized().length() - 1.0 < f32::EPSILON);
assert_eq!(Vec3::angle_between(Vec3::X, Vec3::Y), 90.0);
assert_eq!(Vec3::dot(Vec3::X, Vec3::Y), 0.0);
Fields§
§x: f32
§y: f32
§z: f32
Implementations§
Source§impl Vec3
impl Vec3
Sourcepub const FORWARD: Self = Self::NEG_Z
pub const FORWARD: Self = Self::NEG_Z
StereoKit uses a right-handed coordinate system, which means that forward is looking down the -Z axis! This value is the same as new Vec3(0,0,-1). This is NOT the same as UnitZ! https://stereokit.net/Pages/StereoKit/Vec3/Forward.html
Sourcepub const ONE: Self
pub const ONE: Self
Shorthand for a vector where all values are 1! Same as new Vec3(1,1,1). https://stereokit.net/Pages/StereoKit/Vec3/One.html
Sourcepub const NEG_ONE: Self
pub const NEG_ONE: Self
Shorthand for a vector where all values are -1! Same as new Vec3(-1,-1,-1).
Sourcepub const RIGHT: Self = Self::X
pub const RIGHT: Self = Self::X
When looking forward, this is the direction to the right! In StereoKit, this is the same as new Vec3(1,0,0) https://stereokit.net/Pages/StereoKit/Vec3/Right.html
Sourcepub const X: Self
pub const X: Self
A normalized Vector that points down the X axis, this is the same as new Vec3(1,0,0). https://stereokit.net/Pages/StereoKit/Vec3/UnitX.html
Sourcepub const Y: Self
pub const Y: Self
A normalized Vector that points down the Y axis, this is the same as new Vec3(0,1,0). https://stereokit.net/Pages/StereoKit/Vec3/UnitY.html
Sourcepub const Z: Self
pub const Z: Self
A normalized Vector that points down the Z axis, this is the same as new Vec3(0,0,1). This is NOT the same as Forward! https://stereokit.net/Pages/StereoKit/Vec3/UnitZ.html
Sourcepub const NEG_X: Self
pub const NEG_X: Self
A normalized Vector that points up the Z axis, this is the same as new Vec3(0,0,-1).
Sourcepub const NEG_Y: Self
pub const NEG_Y: Self
A normalized Vector that points up the Y axis, this is the same as new Vec3(0,-1,0).
Sourcepub const NEG_Z: Self
pub const NEG_Z: Self
A normalized Vector that points up the Z axis, this is the same as new Vec3(0,0,-1). This is the same as Forward!
Sourcepub const UP: Self = Self::Y
pub const UP: Self = Self::Y
A vector representing the up axis. In StereoKit, this is the same as new Vec3(0,1,0). https://stereokit.net/Pages/StereoKit/Vec3/Up.html
Sourcepub const ZERO: Vec3
pub const ZERO: Vec3
Shorthand for a vector where all values are 0! Same as new Vec3(0,0,0). https://stereokit.net/Pages/StereoKit/Vec3/Zero.html
Sourcepub const fn new(x: f32, y: f32, z: f32) -> Self
pub const fn new(x: f32, y: f32, z: f32) -> Self
Creates a vector from x, y, and z values! StereoKit uses a right-handed metric coordinate system, where +x is to the right, +y is upwards, and -z is forward. https://stereokit.net/Pages/StereoKit/Vec3/Vec3.html
Sourcepub fn in_radius(&self, point: Self, radius: f32) -> bool
pub fn in_radius(&self, point: Self, radius: f32) -> bool
Checks if a point is within a certain radius of this one. This is an easily readable shorthand of the squared distance check. https://stereokit.net/Pages/StereoKit/Vec3/InRadius.html
point
- The point to check against.radius
- The radius to check within.
Returns true if the points are within radius of each other, false not.
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
let vec3_b = Vec3::new(2.0, 4.0, 6.0);
assert_eq!(vec3_a.in_radius(vec3_b, 5.0), true);
assert_eq!(vec3_a.in_radius(vec3_b, 2.0), false);
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Turns this vector into a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero. Vec3::get_normalized is faster. https://stereokit.net/Pages/StereoKit/Vec3/Normalize.html
§Examples
use stereokit_rust::maths::Vec3;
let mut vec3_a = Vec3::new(1.0, 2.0, 3.0);
vec3_a.normalize();
assert_eq!(vec3_a, Vec3::new(0.26726124, 0.5345225, 0.8017837));
Sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
This is the length, or magnitude of the vector! The distance from the origin to this point. Uses f32::sqrt, so it’s not dirt cheap or anything. https://stereokit.net/Pages/StereoKit/Vec3/Length.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.length(), 3.7416575);
Sourcepub fn length_sq(&self) -> f32
pub fn length_sq(&self) -> f32
This is the squared length of the vector! It skips the Sqrt call, and just gives you the squared version for speedy calculations that can work with it squared. https://stereokit.net/Pages/StereoKit/Vec3/LengthSq.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.length_sq(), 14.0);
Sourcepub fn magnitude(&self) -> f32
pub fn magnitude(&self) -> f32
Magnitude is the length of the vector! The distance from the origin to this point. Uses f32::sqrt, so it’s not dirt cheap or anything. https://stereokit.net/Pages/StereoKit/Vec3/Magnitude.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.length(), 3.7416575);
Sourcepub fn magnitude_squared(&self) -> f32
pub fn magnitude_squared(&self) -> f32
This is the squared magnitude of the vector! It skips the Sqrt call, and just gives you the squared version for speedy calculations that can work with it squared. https://stereokit.net/Pages/StereoKit/Vec3/MagnitudeSq.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.magnitude_squared(), 14.0);
Sourcepub fn get_normalized(&self) -> Self
pub fn get_normalized(&self) -> Self
Creates a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero. https://stereokit.net/Pages/StereoKit/Vec3/Normalized.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.get_normalized(), Vec3::new(0.26726124, 0.5345225, 0.8017837));
Sourcepub fn x0z(&self) -> Self
pub fn x0z(&self) -> Self
This returns a Vec3 that has been flattened to 0 on the Y axis. No other changes are made. https://stereokit.net/Pages/StereoKit/Vec3/X0Z.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.x0z(), Vec3::new(1.0, 0.0, 3.0));
Sourcepub fn xy0(&self) -> Self
pub fn xy0(&self) -> Self
This returns a Vec3 that has been flattened to 0 on the Z axis. No other changes are made. https://stereokit.net/Pages/StereoKit/Vec3/XY0.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.xy0(), Vec3::new(1.0, 2.0, 0.0));
Sourcepub fn xy1(&self) -> Self
pub fn xy1(&self) -> Self
This returns a Vec3 that has been set to 1 on the Z axis. No other changes are made https://stereokit.net/Pages/StereoKit/Vec3/XY1.html
§Examples
use stereokit_rust::maths::Vec3;
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.xy1(), Vec3::new(1.0, 2.0, 1.0));
Sourcepub fn xy(&self) -> Vec2
pub fn xy(&self) -> Vec2
This extracts the Vec2 from the X and Y axes. https://stereokit.net/Pages/StereoKit/Vec3.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.xy(), Vec2::new(1.0, 2.0));
Sourcepub fn yz(&self) -> Vec2
pub fn yz(&self) -> Vec2
This extracts the Vec2 from the Y and Z axes. https://stereokit.net/Pages/StereoKit/Vec3/YZ.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.yz(), Vec2::new(2.0, 3.0));
Sourcepub fn xz(&self) -> Vec2
pub fn xz(&self) -> Vec2
This extracts the Vec2 from the X and Z axes. https://stereokit.net/Pages/StereoKit/Vec3.html
§Examples
use stereokit_rust::maths::{Vec2, Vec3};
let vec3_a = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(vec3_a.xz(), Vec2::new(1.0, 3.0));
Sourcepub fn angle_between(a: Self, b: Self) -> f32
pub fn angle_between(a: Self, b: Self) -> f32
Calculates the angle between two vectors in degrees! Vectors do not need to be normalized, and the result will always be positive. https://stereokit.net/Pages/StereoKit/Vec3/AngleBetween.html
a
- The first, initial vector, A. Does not need to be normalized.b
- The second vector, B, that we’re finding the angle to. Does not need to be normalized.
Returns a positive angle between two vectors in degrees!
§Examples
use stereokit_rust::maths::Vec3;
let vec3_b = Vec3::new(0.0, 1.0, 0.0);
assert_eq!(Vec3::angle_between(Vec3::X, vec3_b), 90.0);
let vec3_c = Vec3::new(-1.0, 0.0, 0.0);
assert_eq!(Vec3::angle_between(Vec3::X, vec3_c), 180.0);
let vec3_d = Vec3::new(1.0, 0.0, 1.0);
assert_eq!(Vec3::angle_between(Vec3::X, vec3_d), 45.0);
Sourcepub fn angle_xy(angle_deg: f32, z: f32) -> Vec3
pub fn angle_xy(angle_deg: f32, z: f32) -> Vec3
Creates a vector that points out at the given 2D angle! This creates the vector on the XY plane, and allows you to specify a constant z value. https://stereokit.net/Pages/StereoKit/Vec3/AngleXY.html
angle_deg
- The angle in degrees, starting from the (1,0) at 0, and continuing to (0,1) at 90, etc.z
- The constant Z value for this vector.
Returns a vector pointing at the given angle! If z is zero, this will be a normalized vector (vector with a length of 1).
§Examples
use stereokit_rust::maths::Vec3;
let angle = 45.0;
let z = 0.0;
let vector = Vec3::angle_xy(angle, z);
assert_eq!(vector, Vec3::new(0.70710677, 0.70710677, 0.0));
Sourcepub fn angle_xz(angle_deg: f32, y: f32) -> Self
pub fn angle_xz(angle_deg: f32, y: f32) -> Self
Creates a vector that points out at the given 2D angle! This creates the vector on the XZ plane, and allows you to specify a constant y value. https://stereokit.net/Pages/StereoKit/Vec3/AngleXZ.html
angle_deg
- The angle in degrees, starting from the (1,0) at 0, and continuing to (0,1) at 90, etc.y
- The constant Y value for this vector.
Returns A Vector pointing at the given angle! If y is zero, this will be a normalized vector (vector with a length of 1).
§Examples
use stereokit_rust::maths::Vec3;
let vec = Vec3::angle_xz(90.0, 0.0);
assert_eq!(vec, Vec3::new(0.0, 0.0, 1.0));
Sourcepub fn cross(a: Self, b: Self) -> Self
pub fn cross(a: Self, b: Self) -> Self
The cross product of two vectors! https://stereokit.net/Pages/StereoKit/Vec3/Cross.html
a
- The first vector.b
- The second vector.
Returns is not a unit vector, even if both ‘a’ and ‘b’ are unit vectors.
see also vec3_cross
§Examples
use stereokit_rust::maths::Vec3;
// Test case 1: Basic cross product
let a = Vec3::new(1.0, 0.0, 0.0);
let b = Vec3::new(0.0, 1.0, 0.0);
let result = Vec3::cross(a, b);
assert_eq!(result, Vec3::new(0.0, 0.0, 1.0));
// Test case 2: Cross product in different direction
let a = Vec3::new(0.0, 1.0, 0.0);
let b = Vec3::new(1.0, 0.0, 0.0);
let result = Vec3::cross(a, b);
assert_eq!(result, Vec3::new(0.0, 0.0, -1.0));
// Test case 3: Cross product with non-unit vectors
let a = Vec3::new(2.0, 0.0, 0.0);
let b = Vec3::new(0.0, 3.0, 0.0);
let result = Vec3::cross(a, b);
assert_eq!(result, Vec3::new(0.0, 0.0, 6.0));
// Test case 4: Cross product of parallel vectors
let a = Vec3::new(1.0, 0.0, 0.0);
let b = Vec3::new(2.0, 0.0, 0.0);
let result = Vec3::cross(a, b);
assert_eq!(result, Vec3::ZERO);
// Test case 5: cross product of orthogonal vector
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
let result = Vec3::cross(a,b);
assert_eq!(result, Vec3::new(-3.0, 6.0, -3.0));
// Test case 6: cross product of orthogonal vector
let a = Vec3::new(4.0, 5.0, 6.0);
let b = Vec3::new(1.0, 2.0, 3.0);
let result = Vec3::cross(a,b);
assert_eq!(result, Vec3::new(3.0, -6.0, 3.0));
Sourcepub fn direction(to: Self, from: Self) -> Self
pub fn direction(to: Self, from: Self) -> Self
Creates a normalized delta vector that points out from an origin point to a target point! https://stereokit.net/Pages/StereoKit/Vec3/Direction.html
to
- The target point.from
- The origin point.
Returns direction from one point to another.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
let direction = Vec3::direction(a, b);
assert_eq!(direction, Vec3 { x: -0.57735026, y: -0.57735026, z: -0.57735026 });
Sourcepub fn distance(a: Self, b: Self) -> f32
pub fn distance(a: Self, b: Self) -> f32
Calculates the distance between two points in space! Make sure they’re in the same coordinate space! Uses a Sqrt, so it’s not blazing fast, prefer DistanceSq when possible. https://stereokit.net/Pages/StereoKit/Vec3/Distance.html
a
- The first point.b
- The second point.
Returns the distance between the two points.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3 { x: 1.0, y: 2.0, z: 3.0 };
let b = Vec3 { x: 4.0, y: 5.0, z: 6.0 };
let distance = Vec3::distance(a, b);
assert_eq!(distance, 5.196152);
Sourcepub fn distance_sq(a: Self, b: Self) -> f32
pub fn distance_sq(a: Self, b: Self) -> f32
Calculates the distance between two points in space, but leaves them squared! Make sure they’re in the same coordinate space! This is a fast function :) https://stereokit.net/Pages/StereoKit/Vec3/DistanceSq.html
a
- The first point.b
- The second point.
Returns the distance between the two points, but squared.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
let distance = Vec3::distance_sq(a, b);
assert_eq!(distance, 27.0);
Sourcepub fn dot(a: Self, b: Self) -> f32
pub fn dot(a: Self, b: Self) -> f32
The dot product is an extremely useful operation! One major use is to determine how similar two vectors are. If the vectors are Unit vectors (magnitude/length of 1), then the result will be 1 if the vectors are the same, -1 if they’re opposite, and a gradient in-between with 0 being perpendicular. See Freya Holmer’s excellent visualization of this concept https://stereokit.net/Pages/StereoKit/Vec3/Dot.html
a
- The first vector.b
- The second vector.
Returns the dot product of the two vectors.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 0.0, 1.0);
let b = Vec3::new(1.0, 1.0, 0.0);
let dot_product = Vec3::dot(a, b);
assert_eq!(dot_product, 1.0);
Sourcepub fn lerp(a: Self, b: Self, blend: f32) -> Self
pub fn lerp(a: Self, b: Self, blend: f32) -> Self
Blends (Linear Interpolation) between two vectors, based on a ‘blend’ value, where 0 is a, and 1 is b. Doesn’t clamp percent for you. https://stereokit.net/Pages/StereoKit/Vec3/Lerp.html
a
- First item in the blend, or ‘0.0’ blend.b
- Second item in the blend, or ‘1.0’ blend.blend
- The blend value between 0 and 1. Can be outside this range, it’ll just interpolate outside of the a, b range.
Returns a blend value between 0 and 1. Can be outside this range, it’ll just interpolate outside of the a, b range.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
let blend = 0.25;
let result = Vec3::lerp(a, b, blend);
assert_eq!(result, Vec3::new(1.75, 2.75, 3.75));
Sourcepub fn max(a: Self, b: Self) -> Self
pub fn max(a: Self, b: Self) -> Self
Returns a vector where each element is the maximum value for each corresponding pair. https://stereokit.net/Pages/StereoKit/Vec3/Max.html
a
- Order isn’t important here.b
- Order isn’t important here.
Returns the maximum value for each corresponding vector pair.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 6.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
let result = Vec3::max(a, b);
assert_eq!(result, Vec3::new(4.0, 6.0, 6.0));
Sourcepub fn min(a: Self, b: Self) -> Self
pub fn min(a: Self, b: Self) -> Self
Returns a vector where each element is the minimum value for each corresponding pair. https://stereokit.net/Pages/StereoKit/Vec3/Min.html
a
- Order isn’t important here.b
- Order isn’t important here.
Returns the minimum value for each corresponding vector pair.
§Examples
use stereokit_rust::maths::Vec3;
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 1.0, 6.0);
let result = Vec3::min(a, b);
assert_eq!(result, Vec3::new(1.0, 1.0, 3.0));
Sourcepub fn perpendicular_right(forward: Self, up: Self) -> Self
pub fn perpendicular_right(forward: Self, up: Self) -> Self
Exactly the same as Vec3.Cross, but has some naming mnemonics for getting the order right when trying to find a perpendicular vector using the cross product. This’ll also make it more obvious to read if that’s what you’re actually going for when crossing vectors! If you consider a forward vector and an up vector, then the direction to the right is pretty trivial to imagine in relation to those vectors! https://stereokit.net/Pages/StereoKit/Vec3/PerpendicularRight.html
forward
- What way are you facing?up
- Which direction is up?
Returns your direction to the right! Result is -not- a unit vector, even if both ‘forward’ and ‘up’ are unit vectors.
§Examples
use stereokit_rust::maths::Vec3;
let forward = Vec3::new(0.0, 0.0, -1.0);
let up = Vec3::new(0.0, 1.0, 0.0);
let right = Vec3::perpendicular_right(forward, up);
assert_eq!(right, Vec3::new(1.0, 0.0, 0.0));
// The same with constants:
let forward = Vec3::FORWARD;
let up = Vec3::UP;
let right = Vec3::perpendicular_right(forward, up);
assert_eq!(right, Vec3::RIGHT);
Sourcepub fn abs(&self) -> Self
pub fn abs(&self) -> Self
Returns a vector where each element is the absolute value of the corresponding element. https://stereokit.net/Pages/StereoKit/Vec3/Abs.html
§Examples
use stereokit_rust::maths::Vec3;
let v = Vec3::new(-1.0, 2.0, -3.0);
assert_eq!(v.abs(), Vec3::new(1.0, 2.0, 3.0));
Trait Implementations§
Source§impl Add for Vec3
Adds matching components together. Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Addition.html
impl Add for Vec3
Adds matching components together. Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Addition.html
Source§impl AddAssign for Vec3
Adds matching components together. Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Addition.html
impl AddAssign for Vec3
Adds matching components together. Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Addition.html
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec3;
let mut a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
a += b;
assert_eq!(a, Vec3::new(5.0, 7.0, 9.0));
Source§impl Display for Vec3
impl Display for Vec3
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Mostly for debug purposes, this is a decent way to log or inspect the vector in debug mode. Looks like “[x, y, z]” https://stereokit.net/Pages/StereoKit/Vec3/ToString.html
§Examples
use stereokit_rust::maths::Vec3;
let v = Vec3::new(1.0, 2.0, 3.0);
assert_eq!(v.to_string(), "[x:1, y:2, z:3]");
Source§impl Div<Vec3> for f32
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
impl Div<Vec3> for f32
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
Source§impl Div<f32> for Vec3
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
impl Div<f32> for Vec3
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
Source§impl Div for Vec3
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
impl Div for Vec3
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
Source§impl DivAssign<f32> for Vec3
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
impl DivAssign<f32> for Vec3
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
§Examples
use stereokit_rust::maths::Vec3;
let mut v = Vec3::new(1.0, 2.0, 3.0);
v /= 2.0;
assert_eq!(v, Vec3::new(0.5, 1.0, 1.5));
Source§impl DivAssign for Vec3
A component-wise vector division.
https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
impl DivAssign for Vec3
A component-wise vector division. https://stereokit.net/Pages/StereoKit/Vec3/op_Division.html
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec3;
let mut v = Vec3::new(1.0, 2.0, 3.0);
v /= Vec3::new(2.0, 2.0, 2.0);
assert_eq!(v, Vec3::new(0.5, 1.0, 1.5));
Source§impl Mul<Matrix> for Vec3
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’
for the 4th element, so the result will also include translation! To exclude translation,
use Matrix.transform_normal.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl Mul<Matrix> for Vec3
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’ for the 4th element, so the result will also include translation! To exclude translation, use Matrix.transform_normal. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pt
Source§impl Mul<Vec3> for Bounds
This operator will create a new Bounds that has been properly scaled up by the Vec3. This does affect the center
position of the Bounds.
https://stereokit.net/Pages/StereoKit/Bounds/op_Multiply.html
impl Mul<Vec3> for Bounds
This operator will create a new Bounds that has been properly scaled up by the Vec3. This does affect the center position of the Bounds. https://stereokit.net/Pages/StereoKit/Bounds/op_Multiply.html
Source§fn mul(self, rhs: Vec3) -> Self::Output
fn mul(self, rhs: Vec3) -> Self::Output
§Examples
use stereokit_rust::maths::{Vec3, Bounds};
let bounds = Bounds::from_corners( Vec3::ZERO, Vec3::ONE);
let bounds_scaled = bounds * Vec3::new(1.0, 2.0, 3.0);
assert_eq!(bounds_scaled.center, Vec3::new(0.5, 1.0, 1.5));
assert_eq!(bounds_scaled.dimensions, Vec3::new(1.0, 2.0, 3.0));
Source§impl Mul<Vec3> for Matrix
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’
for the 4th element, so the result will also include translation! To exclude translation,
use Matrix.transform_normal.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl Mul<Vec3> for Matrix
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’ for the 4th element, so the result will also include translation! To exclude translation, use Matrix.transform_normal. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pt
Source§impl Mul<Vec3> for Quat
This rotates a point around the origin by the Quat.
https://stereokit.net/Pages/StereoKit/Quat/op_Multiply.html
impl Mul<Vec3> for Quat
This rotates a point around the origin by the Quat. https://stereokit.net/Pages/StereoKit/Quat/op_Multiply.html
see also quat_mul_vec
Source§impl Mul<Vec3> for f32
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
impl Mul<Vec3> for f32
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
Source§impl Mul<f32> for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
impl Mul<f32> for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
Source§impl Mul for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
impl Mul for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
Source§impl MulAssign<Matrix> for Vec3
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’
for the 4th element, so the result will also include translation! To exclude translation,
use Matrix.transform_normal.
https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
impl MulAssign<Matrix> for Vec3
Multiplies the vector by the Matrix! Since only a 1x4 vector can be multiplied against a 4x4 matrix, this uses ‘1’ for the 4th element, so the result will also include translation! To exclude translation, use Matrix.transform_normal. https://stereokit.net/Pages/StereoKit/Matrix/op_Multiply.html
see also matrix_transform_pt
Source§fn mul_assign(&mut self, rhs: Matrix)
fn mul_assign(&mut self, rhs: Matrix)
§Examples
use stereokit_rust::maths::{Vec3, Matrix};
let mut point = Vec3::new(1.0, 1.0, 1.0);
let transform = Matrix::t([1.0, 2.0, 3.0]);
point *= transform;
assert_eq!(point, Vec3::new(2.0, 3.0, 4.0));
Source§impl MulAssign<Vec3> for Bounds
This operator will create a new Bounds that has been properly scaled up by the Vec3. This does affect the center
position of the Bounds.
https://stereokit.net/Pages/StereoKit/Bounds/op_Multiply.html
impl MulAssign<Vec3> for Bounds
This operator will create a new Bounds that has been properly scaled up by the Vec3. This does affect the center position of the Bounds. https://stereokit.net/Pages/StereoKit/Bounds/op_Multiply.html
Source§fn mul_assign(&mut self, rhs: Vec3)
fn mul_assign(&mut self, rhs: Vec3)
§Examples
use stereokit_rust::maths::{Vec3, Bounds};
let mut bounds = Bounds::from_corners( Vec3::ZERO, Vec3::ONE);
bounds *= Vec3::new(1.0, 2.0, 3.0);
assert_eq!(bounds.center, Vec3::new(0.5, 1.0, 1.5));
assert_eq!(bounds.dimensions, Vec3::new(1.0, 2.0, 3.0));
Source§impl MulAssign<f32> for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
impl MulAssign<f32> for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
§Examples
use stereokit_rust::maths::Vec3;
let mut a = Vec3::new(1.0, 2.0, 3.0);
a *= 2.0;
assert_eq!(a, Vec3::new(2.0, 4.0, 6.0));
Source§impl MulAssign for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
impl MulAssign for Vec3
A component-wise vector multiplication, same thing as a non-uniform scale. NOT a dot or cross product! Commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Multiply.html
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
§Examples
use stereokit_rust::maths::Vec3;
let mut a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
a *= b;
assert_eq!(a, Vec3::new(4.0, 10.0, 18.0));
Source§impl Neg for Vec3
Vector negation, returns a vector where each component has been negated.
https://stereokit.net/Pages/StereoKit/Vec3/op_UnaryNegation.html
impl Neg for Vec3
Vector negation, returns a vector where each component has been negated. https://stereokit.net/Pages/StereoKit/Vec3/op_UnaryNegation.html
Source§impl PartialEq for Vec3
Warning: Equality with a precision of 0.1 millimeter
impl PartialEq for Vec3
Warning: Equality with a precision of 0.1 millimeter
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Warning: Equality with a precision of 0.1 millimeter
§Example
use stereokit_rust::maths::Vec3;
assert_eq!(
Vec3 { x: 0.045863353, y: 0.030000005, z: 0.0 } ,
Vec3 { x: 0.045863353, y: 0.030000005, z: 0.0 } );
use stereokit_rust::maths::Vec3;
assert_ne!(
Vec3 { x: 10.045863353, y: 0.030000005, z: 0.0 } ,
Vec3 { x: 0.045863353, y: 0.030000005, z: 0.0 } );
Source§impl SubAssign for Vec3
Subtracts matching components from eachother. Not commutative.
https://stereokit.net/Pages/StereoKit/Vec3/op_Subtraction.html
impl SubAssign for Vec3
Subtracts matching components from eachother. Not commutative. https://stereokit.net/Pages/StereoKit/Vec3/op_Subtraction.html
Source§fn sub_assign(&mut self, rhs: Vec3)
fn sub_assign(&mut self, rhs: Vec3)
§Examples
use stereokit_rust::maths::Vec3;
let mut a = Vec3::new(1.0, 3.0, 1.0);
let b = Vec3::new(0.5, 0.5, 0.5);
a -= b;
assert_eq!(a, Vec3::new(0.5, 2.5, 0.5));
impl Copy for Vec3
Auto Trait Implementations§
impl Freeze for Vec3
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
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.