Struct graphene::Vec3

source ·
#[repr(transparent)]
pub struct Vec3 { /* private fields */ }
Expand description

A structure capable of holding a vector with three dimensions: x, y, and z.

The contents of the Vec3 structure are private and should never be accessed directly.

Implementations§

source§

impl Vec3

source

pub fn as_ptr(&self) -> *mut graphene_vec3_t

source§

impl Vec3

source

pub fn add(&self, b: &Vec3) -> Vec3

Adds each component of the two given vectors.

b

a Vec3

Returns
res

return location for the resulting vector

source

pub fn cross(&self, b: &Vec3) -> Vec3

Computes the cross product of the two given vectors.

b

a Vec3

Returns
res

return location for the resulting vector

source

pub fn divide(&self, b: &Vec3) -> Vec3

Divides each component of the first operand self by the corresponding component of the second operand b, and places the results into the vector res.

b

a Vec3

Returns
res

return location for the resulting vector

source

pub fn dot(&self, b: &Vec3) -> f32

Computes the dot product of the two given vectors.

b

a Vec3

Returns

the value of the dot product

source

pub fn x(&self) -> f32

Retrieves the first component of the given vector self.

Returns

the value of the first component of the vector

source

pub fn xy(&self) -> Vec2

Creates a Vec2 that contains the first and second components of the given Vec3.

Returns
res

return location for a Vec2

source

pub fn xy0(&self) -> Vec3

Creates a Vec3 that contains the first two components of the given Vec3, and the third component set to 0.

Returns
res

return location for a Vec3

source

pub fn xyz0(&self) -> Vec4

Converts a Vec3 in a Vec4 using 0.0 as the value for the fourth component of the resulting vector.

Returns
res

return location for the vector

source

pub fn xyz1(&self) -> Vec4

Converts a Vec3 in a Vec4 using 1.0 as the value for the fourth component of the resulting vector.

Returns
res

return location for the vector

source

pub fn xyzw(&self, w: f32) -> Vec4

Converts a Vec3 in a Vec4 using w as the value of the fourth component of the resulting vector.

w

the value of the W component

Returns
res

return location for the vector

source

pub fn y(&self) -> f32

Retrieves the second component of the given vector self.

Returns

the value of the second component of the vector

source

pub fn z(&self) -> f32

Retrieves the third component of the given vector self.

Returns

the value of the third component of the vector

source

pub fn interpolate(&self, v2: &Vec3, factor: f64) -> Vec3

Linearly interpolates self and v2 using the given factor.

v2

a Vec3

factor

the interpolation factor

Returns
res

the interpolated vector

source

pub fn length(&self) -> f32

Retrieves the length of the given vector self.

Returns

the value of the length of the vector

source

pub fn max(&self, b: &Vec3) -> Vec3

Compares each component of the two given vectors and creates a vector that contains the maximum values.

b

a Vec3

Returns
res

return location for the result vector

source

pub fn min(&self, b: &Vec3) -> Vec3

Compares each component of the two given vectors and creates a vector that contains the minimum values.

b

a Vec3

Returns
res

return location for the result vector

source

pub fn multiply(&self, b: &Vec3) -> Vec3

Multiplies each component of the two given vectors.

b

a Vec3

Returns
res

return location for the resulting vector

source

pub fn near(&self, v2: &Vec3, epsilon: f32) -> bool

Compares the two given Vec3 vectors and checks whether their values are within the given epsilon.

v2

a Vec3

epsilon

the threshold between the two vectors

Returns

true if the two vectors are near each other

source

pub fn negate(&self) -> Vec3

Negates the given Vec3.

Returns
res

return location for the result vector

source

pub fn normalize(&self) -> Vec3

Normalizes the given Vec3.

Returns
res

return location for the normalized vector

source

pub fn scale(&self, factor: f32) -> Vec3

Multiplies all components of the given vector with the given scalar factor.

factor

the scalar factor

Returns
res

return location for the result vector

source

pub fn subtract(&self, b: &Vec3) -> Vec3

Subtracts from each component of the first operand self the corresponding component of the second operand b and places each result into the components of res.

b

a Vec3

Returns
res

return location for the resulting vector

source

pub fn one() -> Vec3

Provides a constant pointer to a vector with three components, all sets to 1.

Returns

a constant vector

source

pub fn x_axis() -> Vec3

Provides a constant pointer to a vector with three components with values set to (1, 0, 0).

Returns

a constant vector

source

pub fn y_axis() -> Vec3

Provides a constant pointer to a vector with three components with values set to (0, 1, 0).

Returns

a constant vector

source

pub fn z_axis() -> Vec3

Provides a constant pointer to a vector with three components with values set to (0, 0, 1).

Returns

a constant vector

source

pub fn zero() -> Vec3

Provides a constant pointer to a vector with three components, all sets to 0.

Returns

a constant vector

source§

impl Vec3

source

pub fn new(x: f32, y: f32, z: f32) -> Self

Initializes a Vec3 using the given values.

This function can be called multiple times.

x

the X field of the vector

y

the Y field of the vector

z

the Z field of the vector

Returns

a pointer to the initialized vector

source

pub fn from_float(src: [f32; 3]) -> Self

Initializes a Vec3 with the values from an array.

src

an array of 3 floating point values

Returns

the initialized vector

source

pub fn to_float(&self) -> [f32; 3]

Copies the components of a Vec3 into the given array.

Returns
dest

return location for an array of floating point values

Trait Implementations§

source§

impl Clone for Vec3

source§

fn clone(&self) -> Self

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 Vec3

source§

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

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

impl PartialEq<Vec3> for Vec3

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StaticType for Vec3

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Copy for Vec3

source§

impl Eq for Vec3

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticTypeExt for Twhere T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToClosureReturnValue for Twhere T: ToValue,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSendValue for Twhere T: Send + ToValue + ?Sized,

source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T> TryFromClosureReturnValue for Twhere T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<'a, T, C, E> FromValueOptional<'a> for Twhere T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,