Struct Vec4

Source
#[repr(C)]
pub struct Vec4<T> { pub x: T, pub y: T, pub z: T, pub w: T, }
Expand description

4 dimensional vector.

Fields§

§x: T

x coordinate of the vector

§y: T

y coordinate of the vector

§z: T

z coordinate of the vector

§w: T

w coordinate of the vector

Implementations§

Source§

impl<T> Vec4<T>

Source

pub fn xy(self) -> Vec2<T>

Source

pub fn xyz(self) -> Vec3<T>

Source

pub fn map<U, F>(self, f: F) -> Vec4<U>
where F: Fn(T) -> U,

Source§

impl<T> Vec4<T>
where T: Copy + Num,

Source

pub fn dot(a: Vec4<T>, b: Vec4<T>) -> T

Calculate dot product of two vectors.

§Examples
use batbox::*;
assert_eq!(Vec4::dot(vec4(1, 2, 3, 4), vec4(3, 4, 5, 6)), 50);

Trait Implementations§

Source§

impl<T> Add for Vec4<T>
where T: Add<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vec4<T>) -> Vec4<T>

Performs the + operation. Read more
Source§

impl<T> AddAssign for Vec4<T>
where T: AddAssign,

Source§

fn add_assign(&mut self, rhs: Vec4<T>)

Performs the += operation. Read more
Source§

impl<U> AsUniform for Vec4<U>
where [U; 4]: Uniform,

Source§

impl<T> Clone for Vec4<T>
where T: Clone,

Source§

fn clone(&self) -> Vec4<T>

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<T> Debug for Vec4<T>
where T: Debug,

Source§

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

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

impl<T> Deref for Vec4<T>

Source§

type Target = [T; 4]

The resulting type after dereferencing.
Source§

fn deref(&self) -> &[T; 4]

Dereferences the value.
Source§

impl<T> DerefMut for Vec4<T>

Source§

fn deref_mut(&mut self) -> &mut [T; 4]

Mutably dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for Vec4<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Vec4<T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for Vec4<T>
where T: Display,

Source§

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

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

impl<T> Div<T> for Vec4<T>
where T: Copy + Div<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Vec4<T>

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for Vec4<T>
where T: Copy + DivAssign,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T> From<[T; 4]> for Vec4<T>

Source§

fn from(arr: [T; 4]) -> Vec4<T>

Converts to this type from the input type.
Source§

impl<T> Hash for Vec4<T>
where T: Hash,

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Mul<T> for Vec4<T>
where T: Copy + Mul<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Vec4<T>

Performs the * operation. Read more
Source§

impl<T> Mul<Vec4<T>> for Mat4<T>
where T: Num + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<T>) -> Vec4<T>

Performs the * operation. Read more
Source§

impl Mul<Vec4<f32>> for f32

Source§

type Output = Vec4<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<f32>) -> Vec4<f32>

Performs the * operation. Read more
Source§

impl Mul<Vec4<f64>> for f64

Source§

type Output = Vec4<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<f64>) -> Vec4<f64>

Performs the * operation. Read more
Source§

impl Mul<Vec4<i16>> for i16

Source§

type Output = Vec4<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<i16>) -> Vec4<i16>

Performs the * operation. Read more
Source§

impl Mul<Vec4<i32>> for i32

Source§

type Output = Vec4<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<i32>) -> Vec4<i32>

Performs the * operation. Read more
Source§

impl Mul<Vec4<i64>> for i64

Source§

type Output = Vec4<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<i64>) -> Vec4<i64>

Performs the * operation. Read more
Source§

impl Mul<Vec4<i8>> for i8

Source§

type Output = Vec4<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<i8>) -> Vec4<i8>

Performs the * operation. Read more
Source§

impl Mul<Vec4<isize>> for isize

Source§

type Output = Vec4<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<isize>) -> Vec4<isize>

Performs the * operation. Read more
Source§

impl Mul<Vec4<u16>> for u16

Source§

type Output = Vec4<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<u16>) -> Vec4<u16>

Performs the * operation. Read more
Source§

impl Mul<Vec4<u32>> for u32

Source§

type Output = Vec4<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<u32>) -> Vec4<u32>

Performs the * operation. Read more
Source§

impl Mul<Vec4<u64>> for u64

Source§

type Output = Vec4<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<u64>) -> Vec4<u64>

Performs the * operation. Read more
Source§

impl Mul<Vec4<u8>> for u8

Source§

type Output = Vec4<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<u8>) -> Vec4<u8>

Performs the * operation. Read more
Source§

impl Mul<Vec4<usize>> for usize

Source§

type Output = Vec4<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<usize>) -> Vec4<usize>

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for Vec4<T>
where T: Copy + MulAssign,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T> Neg for Vec4<T>
where T: Neg<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Vec4<T>

Performs the unary - operation. Read more
Source§

impl<T> PartialEq for Vec4<T>
where T: PartialEq,

Source§

fn eq(&self, other: &Vec4<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Vec4<T>
where T: Serialize,

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Sub for Vec4<T>
where T: Sub<Output = T>,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec4<T>) -> Vec4<T>

Performs the - operation. Read more
Source§

impl<T> SubAssign for Vec4<T>
where T: SubAssign,

Source§

fn sub_assign(&mut self, rhs: Vec4<T>)

Performs the -= operation. Read more
Source§

impl<T> Trans for Vec4<T>
where T: Trans,

Source§

fn create_schema() -> Schema

Source§

fn write_to(&self, writer: &mut dyn Write) -> Result<(), Error>

Source§

fn read_from(reader: &mut dyn Read) -> Result<Vec4<T>, Error>

Source§

impl VertexAttribute for Vec4<f32>

Source§

const SIZE: usize = 4usize

Source§

const TYPE: AttributeType = AttributeType::Float

Source§

impl<T> Copy for Vec4<T>
where T: Copy,

Source§

impl<T> Eq for Vec4<T>
where T: Eq,

Source§

impl<T> StructuralPartialEq for Vec4<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vec4<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vec4<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vec4<T>
where T: Send,

§

impl<T> Sync for Vec4<T>
where T: Sync,

§

impl<T> Unpin for Vec4<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vec4<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Configurable for T
where T: ToString + Clone,

Source§

type Config = ShowValue<T>

Source§

fn config(theme: &Rc<Theme>, value: T) -> ShowValue<T>

Source§

impl<T> Diff for T
where T: Debug + Serialize + for<'de> Deserialize<'de> + Trans + Sync + Send + Copy + PartialEq + 'static,

Source§

type Delta = T

Source§

fn diff(&self, to: &T) -> T

Source§

fn update(&mut self, new_value: &T)

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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<T> Uniform for T
where T: AsUniform,

Source§

fn apply(&self, gl: &Context, info: &UniformInfo)

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Message for T
where T: Debug + Serialize + for<'de> Deserialize<'de> + Send + 'static,