Struct graphene::Vec4

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

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

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

Implementations§

source§

impl Vec4

source

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

source

pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const graphene_vec4_t) -> &'a Self

Borrows the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut graphene_vec4_t ) -> &'a mut Self

Borrows the underlying C value mutably.

source§

impl Vec4

source

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

Adds each component of the two given vectors.

b

a Vec4

Returns
res

return location for the resulting vector

source

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

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 Vec4

Returns
res

return location for the resulting vector

source

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

Computes the dot product of the two given vectors.

b

a Vec4

Returns

the value of the dot product

source

pub fn w(&self) -> f32

Retrieves the value of the fourth component of the given Vec4.

Returns

the value of the fourth component

source

pub fn x(&self) -> f32

Retrieves the value of the first component of the given Vec4.

Returns

the value of the first component

source

pub fn xy(&self) -> Vec2

Creates a Vec2 that contains the first two components of the given Vec4.

Returns
res

return location for a Vec2

source

pub fn xyz(&self) -> Vec3

Creates a Vec3 that contains the first three components of the given Vec4.

Returns
res

return location for a graphene_vec3_t

source

pub fn y(&self) -> f32

Retrieves the value of the second component of the given Vec4.

Returns

the value of the second component

source

pub fn z(&self) -> f32

Retrieves the value of the third component of the given Vec4.

Returns

the value of the third component

source

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

Linearly interpolates self and v2 using the given factor.

v2

a Vec4

factor

the interpolation factor

Returns
res

the interpolated vector

source

pub fn length(&self) -> f32

Computes the length of the given Vec4.

Returns

the length of the vector

source

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

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

b

a Vec4

Returns
res

return location for the result vector

source

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

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

b

a Vec4

Returns
res

return location for the result vector

source

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

Multiplies each component of the two given vectors.

b

a Vec4

Returns
res

return location for the resulting vector

source

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

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

v2

a Vec4

epsilon

the threshold between the two vectors

Returns

true if the two vectors are near each other

source

pub fn negate(&self) -> Vec4

Negates the given Vec4.

Returns
res

return location for the result vector

source

pub fn normalize(&self) -> Vec4

Normalizes the given Vec4.

Returns
res

return location for the normalized vector

source

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

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: &Vec4) -> Vec4

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 Vec4

Returns
res

return location for the resulting vector

source

pub fn one() -> Vec4

Retrieves a pointer to a Vec4 with all its components set to 1.

Returns

a constant vector

source

pub fn w_axis() -> Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 0, 0, 1).

Returns

a constant vector

source

pub fn x_axis() -> Vec4

Retrieves a pointer to a Vec4 with its components set to (1, 0, 0, 0).

Returns

a constant vector

source

pub fn y_axis() -> Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 1, 0, 0).

Returns

a constant vector

source

pub fn z_axis() -> Vec4

Retrieves a pointer to a Vec4 with its components set to (0, 0, 1, 0).

Returns

a constant vector

source

pub fn zero() -> Vec4

Retrieves a pointer to a Vec4 with all its components set to 0.

Returns

a constant vector

source§

impl Vec4

source

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

Initializes a Vec4 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

w

the W field of the vector

Returns

a pointer to the initialized vector

source

pub fn from_vec2(src: &Vec2, z: f32, w: f32) -> Self

Initializes a Vec4 using the components of a Vec2 and the values of z and w.

src

a Vec2

z

the value for the third component of self

w

the value for the fourth component of self

Returns

the initialized vector

source

pub fn from_vec3(src: &Vec3, w: f32) -> Self

Initializes a Vec4 using the components of a Vec3 and the value of w.

src

a Vec3

w

the value for the fourth component of self

Returns

the initialized vector

source

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

Initializes a Vec4 with the values inside the given array.

src

an array of four floating point values

Returns

the initialized vector

source

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

Stores the components of the given Vec4 into an array of floating point values.

Returns
dest

return location for an array of floating point values

Trait Implementations§

source§

impl Clone for Vec4

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 Vec4

source§

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

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

impl Default for Vec4

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl HasParamSpec for Vec4

§

type ParamSpec = ParamSpecBoxed

§

type SetValue = Vec4

Preferred value to be used as setter for the associated ParamSpec.
§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, Vec4>

source§

fn param_spec_builder() -> Self::BuilderFn

source§

impl PartialEq<Vec4> for Vec4

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 Vec4

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Copy for Vec4

source§

impl Eq for Vec4

Auto Trait Implementations§

§

impl RefUnwindSafe for Vec4

§

impl Send for Vec4

§

impl Sync for Vec4

§

impl Unpin for Vec4

§

impl UnwindSafe for Vec4

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> IntoClosureReturnValue for Twhere T: Into<Value>,

source§

impl<T> Property for Twhere T: HasParamSpec,

§

type Value = T

source§

impl<T> PropertyGet for Twhere T: HasParamSpec,

§

type Value = T

source§

fn get<R, F>(&self, f: F) -> Rwhere F: Fn(&<T as PropertyGet>::Value) -> R,

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> 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,