commit
17d8a223f7
16 changed files with 123 additions and 126 deletions
|
@ -9,14 +9,14 @@ cache: cargo
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- CARGO_FEATURES=""
|
- CARGO_FEATURES=""
|
||||||
- CARGO_FEATURES="eders"
|
- CARGO_FEATURES="serde"
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: CARGO_FEATURES="use_simd"
|
env: CARGO_FEATURES="simd"
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: CARGO_FEATURES="eders use_simd"
|
env: CARGO_FEATURES="serde simd"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo build --features "$CARGO_FEATURES"
|
- cargo build --features "$CARGO_FEATURES"
|
||||||
|
|
|
@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Refactored `simd` and `serde` dependencies to match feature names
|
||||||
|
|
||||||
## [v0.14.1] - 2017-05-02
|
## [v0.14.1] - 2017-05-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
|
|
||||||
name = "cgmath"
|
name = "cgmath"
|
||||||
version = "0.14.1"
|
version = "0.15.0"
|
||||||
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>"]
|
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
description = "A linear algebra and mathematics library for computer graphics."
|
description = "A linear algebra and mathematics library for computer graphics."
|
||||||
|
@ -18,15 +18,12 @@ name = "cgmath"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = []
|
unstable = []
|
||||||
eders = ["serde", "serde_derive"]
|
|
||||||
use_simd = ["simd"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
approx = "0.1"
|
approx = "0.1"
|
||||||
num-traits = "0.1"
|
num-traits = "0.1"
|
||||||
rand = "0.3"
|
rand = "0.3"
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", features = ["serde_derive"], optional = true }
|
||||||
serde_derive = { version = "1.0", optional = true }
|
|
||||||
simd = { version = "0.2", optional = true }
|
simd = { version = "0.2", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -34,7 +34,7 @@ use num::BaseFloat;
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Rad<S>(pub S);
|
pub struct Rad<S>(pub S);
|
||||||
|
|
||||||
/// An angle, in degrees.
|
/// An angle, in degrees.
|
||||||
|
@ -42,7 +42,7 @@ pub struct Rad<S>(pub S);
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Deg<S>(pub S);
|
pub struct Deg<S>(pub S);
|
||||||
|
|
||||||
impl<S> From<Rad<S>> for Deg<S> where S: BaseFloat {
|
impl<S> From<Rad<S>> for Deg<S> where S: BaseFloat {
|
||||||
|
|
|
@ -75,7 +75,7 @@ use num::BaseFloat;
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Euler<A: Angle> {
|
pub struct Euler<A: Angle> {
|
||||||
/// The angle to apply around the _x_ axis. Also known at the _pitch_.
|
/// The angle to apply around the _x_ axis. Also known at the _pitch_.
|
||||||
pub x: A,
|
pub x: A,
|
||||||
|
|
|
@ -50,20 +50,18 @@
|
||||||
//! use cgmath::prelude::*;
|
//! use cgmath::prelude::*;
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![cfg_attr(feature = "use_simd", feature(specialization))]
|
#![cfg_attr(feature = "simd", feature(specialization))]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
pub extern crate num_traits;
|
pub extern crate num_traits;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
|
||||||
#[cfg(feature = "eders")]
|
#[cfg(feature = "serde")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
|
||||||
#[cfg(feature = "eders")]
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
extern crate simd;
|
extern crate simd;
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
|
|
|
@ -255,7 +255,7 @@ macro_rules! impl_index_operators {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
macro_rules! impl_operator_default {
|
macro_rules! impl_operator_default {
|
||||||
// When it is an unary operator
|
// When it is an unary operator
|
||||||
(<$S:ident: $Constraint:ident> $Op:ident for $Lhs:ty {
|
(<$S:ident: $Constraint:ident> $Op:ident for $Lhs:ty {
|
||||||
|
@ -355,7 +355,7 @@ macro_rules! impl_operator_default {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
macro_rules! impl_assignment_operator_default {
|
macro_rules! impl_assignment_operator_default {
|
||||||
(<$S:ident: $Constraint:ident> $Op:ident<$Rhs:ty> for $Lhs:ty {
|
(<$S:ident: $Constraint:ident> $Op:ident<$Rhs:ty> for $Lhs:ty {
|
||||||
fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block
|
fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block
|
||||||
|
@ -368,13 +368,13 @@ macro_rules! impl_assignment_operator_default {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a binary operator implementation for the permutations of by-ref and by-val, for simd
|
/// Generates a binary operator implementation for the permutations of by-ref and by-val, for simd
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
macro_rules! impl_operator_simd {
|
macro_rules! impl_operator_simd {
|
||||||
// When it is an unary operator
|
// When it is an unary operator
|
||||||
([$Simd:ident]; $Op:ident for $Lhs:ty {
|
([$Simd:ident]; $Op:ident for $Lhs:ty {
|
||||||
fn $op:ident($x:ident) -> $Output:ty { $body:expr }
|
fn $op:ident($x:ident) -> $Output:ty { $body:expr }
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
impl $Op for $Lhs {
|
impl $Op for $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self) -> $Output {
|
fn $op(self) -> $Output {
|
||||||
|
@ -393,7 +393,7 @@ macro_rules! impl_operator_simd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> $Op<$Rhs> for &'a $Lhs {
|
impl<'a> $Op<$Rhs> for &'a $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: $Rhs) -> $Output {
|
fn $op(self, other: $Rhs) -> $Output {
|
||||||
|
@ -406,7 +406,7 @@ macro_rules! impl_operator_simd {
|
||||||
([$Simd:ident]; $Op:ident<$Rhs:ty> for $Lhs:ty {
|
([$Simd:ident]; $Op:ident<$Rhs:ty> for $Lhs:ty {
|
||||||
fn $op:ident($lhs:ident, $rhs:ident) -> $Output:ty { $body:expr }
|
fn $op:ident($lhs:ident, $rhs:ident) -> $Output:ty { $body:expr }
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
impl $Op<$Rhs> for $Lhs {
|
impl $Op<$Rhs> for $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: $Rhs) -> $Output {
|
fn $op(self, other: $Rhs) -> $Output {
|
||||||
|
@ -414,14 +414,14 @@ macro_rules! impl_operator_simd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> $Op<&'a $Rhs> for $Lhs {
|
impl<'a> $Op<&'a $Rhs> for $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: &'a $Rhs) -> $Output {
|
fn $op(self, other: &'a $Rhs) -> $Output {
|
||||||
let ($lhs, $rhs): ($Simd, $Simd) = (self.into(), (*other).into()); $body
|
let ($lhs, $rhs): ($Simd, $Simd) = (self.into(), (*other).into()); $body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> $Op<$Rhs> for &'a $Lhs {
|
impl<'a> $Op<$Rhs> for &'a $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: $Rhs) -> $Output {
|
fn $op(self, other: $Rhs) -> $Output {
|
||||||
|
@ -447,7 +447,7 @@ macro_rules! impl_operator_simd {
|
||||||
let ($lhs, $rhs): ($Simd, $Simd) = ($Simd::splat(self), other.into()); $body
|
let ($lhs, $rhs): ($Simd, $Simd) = ($Simd::splat(self), other.into()); $body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> $Op<&'a $Rhs> for $Lhs {
|
impl<'a> $Op<&'a $Rhs> for $Lhs {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: &'a $Rhs) -> $Output {
|
fn $op(self, other: &'a $Rhs) -> $Output {
|
||||||
|
|
|
@ -37,7 +37,7 @@ use vector::{Vector2, Vector3, Vector4};
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Matrix2<S> {
|
pub struct Matrix2<S> {
|
||||||
/// The first column of the matrix.
|
/// The first column of the matrix.
|
||||||
pub x: Vector2<S>,
|
pub x: Vector2<S>,
|
||||||
|
@ -50,7 +50,7 @@ pub struct Matrix2<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Matrix3<S> {
|
pub struct Matrix3<S> {
|
||||||
/// The first column of the matrix.
|
/// The first column of the matrix.
|
||||||
pub x: Vector3<S>,
|
pub x: Vector3<S>,
|
||||||
|
@ -65,7 +65,7 @@ pub struct Matrix3<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Matrix4<S> {
|
pub struct Matrix4<S> {
|
||||||
/// The first column of the matrix.
|
/// The first column of the matrix.
|
||||||
pub x: Vector4<S>,
|
pub x: Vector4<S>,
|
||||||
|
@ -666,7 +666,7 @@ impl<S: BaseFloat> SquareMatrix for Matrix4<S> {
|
||||||
// A better option would be using specialization. But currently somewhat
|
// A better option would be using specialization. But currently somewhat
|
||||||
// specialization is too buggy, and it won't apply here. I'm getting
|
// specialization is too buggy, and it won't apply here. I'm getting
|
||||||
// weird error msgs. Help wanted.
|
// weird error msgs. Help wanted.
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
fn invert(&self) -> Option<Matrix4<S>> {
|
fn invert(&self) -> Option<Matrix4<S>> {
|
||||||
let det = self.determinant();
|
let det = self.determinant();
|
||||||
if det == S::zero() {
|
if det == S::zero() {
|
||||||
|
@ -692,7 +692,7 @@ impl<S: BaseFloat> SquareMatrix for Matrix4<S> {
|
||||||
cf(3, 0), cf(3, 1), cf(3, 2), cf(3, 3)))
|
cf(3, 0), cf(3, 1), cf(3, 2), cf(3, 3)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
fn invert(&self) -> Option<Matrix4<S>> {
|
fn invert(&self) -> Option<Matrix4<S>> {
|
||||||
let tmp0 = unsafe {
|
let tmp0 = unsafe {
|
||||||
det_sub_proc_unsafe(self, 1, 2, 3)
|
det_sub_proc_unsafe(self, 1, 2, 3)
|
||||||
|
@ -1057,9 +1057,9 @@ macro_rules! impl_mv_operator {
|
||||||
|
|
||||||
impl_mv_operator!(Matrix2, Vector2 { x: 0, y: 1 });
|
impl_mv_operator!(Matrix2, Vector2 { x: 0, y: 1 });
|
||||||
impl_mv_operator!(Matrix3, Vector3 { x: 0, y: 1, z: 2 });
|
impl_mv_operator!(Matrix3, Vector3 { x: 0, y: 1, z: 2 });
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_mv_operator!(Matrix4, Vector4 { x: 0, y: 1, z: 2, w: 3 });
|
impl_mv_operator!(Matrix4, Vector4 { x: 0, y: 1, z: 2, w: 3 });
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator!(<S: BaseFloat> Mul<Vector4<S> > for Matrix4<S> {
|
impl_operator!(<S: BaseFloat> Mul<Vector4<S> > for Matrix4<S> {
|
||||||
fn mul(matrix, vector) -> Vector4<S> {
|
fn mul(matrix, vector) -> Vector4<S> {
|
||||||
matrix[0] * vector[0] + matrix[1] * vector[1] + matrix[2] * vector[2] + matrix[3] * vector[3]
|
matrix[0] * vector[0] + matrix[1] * vector[1] + matrix[2] * vector[2] + matrix[3] * vector[3]
|
||||||
|
|
|
@ -33,7 +33,7 @@ use vector::{Vector1, Vector2, Vector3, Vector4};
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Point1<S> {
|
pub struct Point1<S> {
|
||||||
pub x: S,
|
pub x: S,
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ pub struct Point1<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Point2<S> {
|
pub struct Point2<S> {
|
||||||
pub x: S,
|
pub x: S,
|
||||||
pub y: S,
|
pub y: S,
|
||||||
|
@ -54,7 +54,7 @@ pub struct Point2<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Point3<S> {
|
pub struct Point3<S> {
|
||||||
pub x: S,
|
pub x: S,
|
||||||
pub y: S,
|
pub y: S,
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub fn ortho<S: BaseFloat>(left: S, right: S, bottom: S, top: S, near: S, far: S
|
||||||
/// A perspective projection based on a vertical field-of-view angle.
|
/// A perspective projection based on a vertical field-of-view angle.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct PerspectiveFov<S> {
|
pub struct PerspectiveFov<S> {
|
||||||
pub fovy: Rad<S>,
|
pub fovy: Rad<S>,
|
||||||
pub aspect: S,
|
pub aspect: S,
|
||||||
|
@ -135,7 +135,7 @@ impl<S: BaseFloat> From<PerspectiveFov<S>> for Matrix4<S> {
|
||||||
|
|
||||||
/// A perspective projection with arbitrary left/right/bottom/top distances
|
/// A perspective projection with arbitrary left/right/bottom/top distances
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Perspective<S> {
|
pub struct Perspective<S> {
|
||||||
pub left: S,
|
pub left: S,
|
||||||
pub right: S,
|
pub right: S,
|
||||||
|
@ -182,7 +182,7 @@ impl<S: BaseFloat> From<Perspective<S>> for Matrix4<S> {
|
||||||
|
|
||||||
/// An orthographic projection with arbitrary left/right/bottom/top distances
|
/// An orthographic projection with arbitrary left/right/bottom/top distances
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Ortho<S> {
|
pub struct Ortho<S> {
|
||||||
pub left: S,
|
pub left: S,
|
||||||
pub right: S,
|
pub right: S,
|
||||||
|
|
|
@ -31,7 +31,7 @@ use point::Point3;
|
||||||
use rotation::{Rotation, Rotation3, Basis3};
|
use rotation::{Rotation, Rotation3, Basis3};
|
||||||
use vector::Vector3;
|
use vector::Vector3;
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
use simd::f32x4 as Simdf32x4;
|
use simd::f32x4 as Simdf32x4;
|
||||||
|
|
||||||
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
|
/// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector
|
||||||
|
@ -40,7 +40,7 @@ use simd::f32x4 as Simdf32x4;
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Quaternion<S> {
|
pub struct Quaternion<S> {
|
||||||
/// The scalar part of the quaternion.
|
/// The scalar part of the quaternion.
|
||||||
pub s: S,
|
pub s: S,
|
||||||
|
@ -48,7 +48,7 @@ pub struct Quaternion<S> {
|
||||||
pub v: Vector3<S>,
|
pub v: Vector3<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl From<Simdf32x4> for Quaternion<f32> {
|
impl From<Simdf32x4> for Quaternion<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(f: Simdf32x4) -> Self {
|
fn from(f: Simdf32x4) -> Self {
|
||||||
|
@ -63,7 +63,7 @@ impl From<Simdf32x4> for Quaternion<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl Into<Simdf32x4> for Quaternion<f32> {
|
impl Into<Simdf32x4> for Quaternion<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> Simdf32x4 {
|
fn into(self) -> Simdf32x4 {
|
||||||
|
@ -229,7 +229,7 @@ impl<S: BaseFloat> MetricSpace for Quaternion<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dot(self, other: Quaternion<S>) -> S {
|
fn dot(self, other: Quaternion<S>) -> S {
|
||||||
|
@ -237,7 +237,7 @@ impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn dot(self, other: Quaternion<S>) -> S {
|
default fn dot(self, other: Quaternion<S>) -> S {
|
||||||
|
@ -245,7 +245,7 @@ impl<S: BaseFloat> InnerSpace for Quaternion<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl InnerSpace for Quaternion<f32> {
|
impl InnerSpace for Quaternion<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dot(self, other: Quaternion<f32>) -> f32 {
|
fn dot(self, other: Quaternion<f32>) -> f32 {
|
||||||
|
@ -277,21 +277,21 @@ impl<A> From<Euler<A>> for Quaternion<A::Unitless> where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Neg for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Neg for Quaternion<S> {
|
||||||
fn neg(quat) -> Quaternion<S> {
|
fn neg(quat) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(-quat.s, -quat.v)
|
Quaternion::from_sv(-quat.s, -quat.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Neg for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Neg for Quaternion<S> {
|
||||||
fn neg(quat) -> Quaternion<S> {
|
fn neg(quat) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(-quat.s, -quat.v)
|
Quaternion::from_sv(-quat.s, -quat.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Neg for Quaternion<f32> {
|
[Simdf32x4]; Neg for Quaternion<f32> {
|
||||||
fn neg(lhs) -> Quaternion<f32> {
|
fn neg(lhs) -> Quaternion<f32> {
|
||||||
|
@ -300,21 +300,21 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Mul<S> for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Mul<S> for Quaternion<S> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<S> {
|
fn mul(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs)
|
Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Mul<S> for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Mul<S> for Quaternion<S> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<S> {
|
fn mul(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs)
|
Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdf32x4]; Mul<f32> for Quaternion<f32> {
|
[Simdf32x4]; Mul<f32> for Quaternion<f32> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<f32> {
|
fn mul(lhs, rhs) -> Quaternion<f32> {
|
||||||
|
@ -323,17 +323,17 @@ impl_operator_simd!{@rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_assignment_operator!(<S: BaseFloat> MulAssign<S> for Quaternion<S> {
|
impl_assignment_operator!(<S: BaseFloat> MulAssign<S> for Quaternion<S> {
|
||||||
fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; }
|
fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_assignment_operator_default!(<S: BaseFloat> MulAssign<S> for Quaternion<S> {
|
impl_assignment_operator_default!(<S: BaseFloat> MulAssign<S> for Quaternion<S> {
|
||||||
fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; }
|
fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl MulAssign<f32> for Quaternion<f32> {
|
impl MulAssign<f32> for Quaternion<f32> {
|
||||||
fn mul_assign(&mut self, other: f32) {
|
fn mul_assign(&mut self, other: f32) {
|
||||||
let s: Simdf32x4 = (*self).into();
|
let s: Simdf32x4 = (*self).into();
|
||||||
|
@ -342,21 +342,21 @@ impl MulAssign<f32> for Quaternion<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Div<S> for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Div<S> for Quaternion<S> {
|
||||||
fn div(lhs, rhs) -> Quaternion<S> {
|
fn div(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs)
|
Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Div<S> for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Div<S> for Quaternion<S> {
|
||||||
fn div(lhs, rhs) -> Quaternion<S> {
|
fn div(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs)
|
Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdf32x4]; Div<f32> for Quaternion<f32> {
|
[Simdf32x4]; Div<f32> for Quaternion<f32> {
|
||||||
fn div(lhs, rhs) -> Quaternion<f32> {
|
fn div(lhs, rhs) -> Quaternion<f32> {
|
||||||
|
@ -365,17 +365,17 @@ impl_operator_simd!{@rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_assignment_operator!(<S: BaseFloat> DivAssign<S> for Quaternion<S> {
|
impl_assignment_operator!(<S: BaseFloat> DivAssign<S> for Quaternion<S> {
|
||||||
fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; }
|
fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_assignment_operator_default!(<S: BaseFloat> DivAssign<S> for Quaternion<S> {
|
impl_assignment_operator_default!(<S: BaseFloat> DivAssign<S> for Quaternion<S> {
|
||||||
fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; }
|
fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl DivAssign<f32> for Quaternion<f32> {
|
impl DivAssign<f32> for Quaternion<f32> {
|
||||||
fn div_assign(&mut self, other: f32) {
|
fn div_assign(&mut self, other: f32) {
|
||||||
let s: Simdf32x4 = (*self).into();
|
let s: Simdf32x4 = (*self).into();
|
||||||
|
@ -403,21 +403,21 @@ impl_operator!(<S: BaseFloat> Mul<Vector3<S> > for Quaternion<S> {
|
||||||
}}
|
}}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Add<Quaternion<S> > for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Add<Quaternion<S> > for Quaternion<S> {
|
||||||
fn add(lhs, rhs) -> Quaternion<S> {
|
fn add(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v)
|
Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Add<Quaternion<S> > for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Add<Quaternion<S> > for Quaternion<S> {
|
||||||
fn add(lhs, rhs) -> Quaternion<S> {
|
fn add(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v)
|
Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Add<Quaternion<f32>> for Quaternion<f32> {
|
[Simdf32x4]; Add<Quaternion<f32>> for Quaternion<f32> {
|
||||||
fn add(lhs, rhs) -> Quaternion<f32> {
|
fn add(lhs, rhs) -> Quaternion<f32> {
|
||||||
|
@ -426,17 +426,17 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_assignment_operator!(<S: BaseFloat> AddAssign<Quaternion<S> > for Quaternion<S> {
|
impl_assignment_operator!(<S: BaseFloat> AddAssign<Quaternion<S> > for Quaternion<S> {
|
||||||
fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; }
|
fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_assignment_operator_default!(<S: BaseFloat> AddAssign<Quaternion<S> > for Quaternion<S> {
|
impl_assignment_operator_default!(<S: BaseFloat> AddAssign<Quaternion<S> > for Quaternion<S> {
|
||||||
fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; }
|
fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl AddAssign for Quaternion<f32> {
|
impl AddAssign for Quaternion<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_assign(&mut self, rhs: Self) {
|
fn add_assign(&mut self, rhs: Self) {
|
||||||
|
@ -446,21 +446,21 @@ impl AddAssign for Quaternion<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Sub<Quaternion<S> > for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Sub<Quaternion<S> > for Quaternion<S> {
|
||||||
fn sub(lhs, rhs) -> Quaternion<S> {
|
fn sub(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v)
|
Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Sub<Quaternion<S> > for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Sub<Quaternion<S> > for Quaternion<S> {
|
||||||
fn sub(lhs, rhs) -> Quaternion<S> {
|
fn sub(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v)
|
Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Sub<Quaternion<f32>> for Quaternion<f32> {
|
[Simdf32x4]; Sub<Quaternion<f32>> for Quaternion<f32> {
|
||||||
fn sub(lhs, rhs) -> Quaternion<f32> {
|
fn sub(lhs, rhs) -> Quaternion<f32> {
|
||||||
|
@ -469,17 +469,17 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_assignment_operator!(<S: BaseFloat> SubAssign<Quaternion<S> > for Quaternion<S> {
|
impl_assignment_operator!(<S: BaseFloat> SubAssign<Quaternion<S> > for Quaternion<S> {
|
||||||
fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; }
|
fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_assignment_operator_default!(<S: BaseFloat> SubAssign<Quaternion<S> > for Quaternion<S> {
|
impl_assignment_operator_default!(<S: BaseFloat> SubAssign<Quaternion<S> > for Quaternion<S> {
|
||||||
fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; }
|
fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; }
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl SubAssign for Quaternion<f32> {
|
impl SubAssign for Quaternion<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub_assign(&mut self, rhs: Self) {
|
fn sub_assign(&mut self, rhs: Self) {
|
||||||
|
@ -489,7 +489,7 @@ impl SubAssign for Quaternion<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_operator!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
impl_operator!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<S> {
|
fn mul(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z,
|
Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z,
|
||||||
|
@ -499,7 +499,7 @@ impl_operator!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_default!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
impl_operator_default!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<S> {
|
fn mul(lhs, rhs) -> Quaternion<S> {
|
||||||
Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z,
|
Quaternion::new(lhs.s * rhs.s - lhs.v.x * rhs.v.x - lhs.v.y * rhs.v.y - lhs.v.z * rhs.v.z,
|
||||||
|
@ -509,7 +509,7 @@ impl_operator_default!(<S: BaseFloat> Mul<Quaternion<S> > for Quaternion<S> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Mul<Quaternion<f32>> for Quaternion<f32> {
|
[Simdf32x4]; Mul<Quaternion<f32>> for Quaternion<f32> {
|
||||||
fn mul(lhs, rhs) -> Quaternion<f32> {
|
fn mul(lhs, rhs) -> Quaternion<f32> {
|
||||||
|
|
|
@ -142,7 +142,7 @@ pub trait Rotation3<S: BaseFloat>: Rotation<Point3<S>>
|
||||||
/// // assert_ulps_eq!(&unit_y3, &unit_y2); // TODO: Figure out how to use this
|
/// // assert_ulps_eq!(&unit_y3, &unit_y2); // TODO: Figure out how to use this
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Basis2<S> {
|
pub struct Basis2<S> {
|
||||||
mat: Matrix2<S>
|
mat: Matrix2<S>
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ impl<S: fmt::Debug> fmt::Debug for Basis2<S> {
|
||||||
/// `math::Matrix3`. To ensure orthogonality is maintained, the operations have
|
/// `math::Matrix3`. To ensure orthogonality is maintained, the operations have
|
||||||
/// been restricted to a subset of those implemented on `Matrix3`.
|
/// been restricted to a subset of those implemented on `Matrix3`.
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Basis3<S> {
|
pub struct Basis3<S> {
|
||||||
mat: Matrix3<S>
|
mat: Matrix3<S>
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,9 +184,9 @@ impl<S: VectorSpace, R, E: BaseFloat> ApproxEq for Decomposed<S, R>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eders")]
|
#[cfg(feature = "serde")]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod eders_ser {
|
mod serde_ser {
|
||||||
use structure::VectorSpace;
|
use structure::VectorSpace;
|
||||||
use super::Decomposed;
|
use super::Decomposed;
|
||||||
use serde::{self, Serialize};
|
use serde::{self, Serialize};
|
||||||
|
@ -209,9 +209,9 @@ mod eders_ser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eders")]
|
#[cfg(feature = "serde")]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod eders_de {
|
mod serde_de {
|
||||||
use structure::VectorSpace;
|
use structure::VectorSpace;
|
||||||
use super::Decomposed;
|
use super::Decomposed;
|
||||||
use serde::{self, Deserialize};
|
use serde::{self, Deserialize};
|
||||||
|
|
|
@ -26,11 +26,11 @@ use angle::Rad;
|
||||||
use approx::ApproxEq;
|
use approx::ApproxEq;
|
||||||
use num::{BaseNum, BaseFloat};
|
use num::{BaseNum, BaseFloat};
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
use simd::f32x4 as Simdf32x4;
|
use simd::f32x4 as Simdf32x4;
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
use simd::i32x4 as Simdi32x4;
|
use simd::i32x4 as Simdi32x4;
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
use simd::u32x4 as Simdu32x4;
|
use simd::u32x4 as Simdu32x4;
|
||||||
|
|
||||||
/// A 1-dimensional vector.
|
/// A 1-dimensional vector.
|
||||||
|
@ -38,7 +38,7 @@ use simd::u32x4 as Simdu32x4;
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Vector1<S> {
|
pub struct Vector1<S> {
|
||||||
/// The x component of the vector.
|
/// The x component of the vector.
|
||||||
pub x: S,
|
pub x: S,
|
||||||
|
@ -49,7 +49,7 @@ pub struct Vector1<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Vector2<S> {
|
pub struct Vector2<S> {
|
||||||
/// The x component of the vector.
|
/// The x component of the vector.
|
||||||
pub x: S,
|
pub x: S,
|
||||||
|
@ -62,7 +62,7 @@ pub struct Vector2<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Vector3<S> {
|
pub struct Vector3<S> {
|
||||||
/// The x component of the vector.
|
/// The x component of the vector.
|
||||||
pub x: S,
|
pub x: S,
|
||||||
|
@ -77,7 +77,7 @@ pub struct Vector3<S> {
|
||||||
/// This type is marked as `#[repr(C)]`.
|
/// This type is marked as `#[repr(C)]`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Hash)]
|
||||||
#[cfg_attr(feature = "eders", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Vector4<S> {
|
pub struct Vector4<S> {
|
||||||
/// The x component of the vector.
|
/// The x component of the vector.
|
||||||
pub x: S,
|
pub x: S,
|
||||||
|
@ -301,7 +301,7 @@ macro_rules! impl_vector {
|
||||||
|
|
||||||
// Utility macro for generating associated functions for the vectors
|
// Utility macro for generating associated functions for the vectors
|
||||||
// mainly duplication
|
// mainly duplication
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
macro_rules! impl_vector_default {
|
macro_rules! impl_vector_default {
|
||||||
($VectorN:ident { $($field:ident),+ }, $n:expr, $constructor:ident) => {
|
($VectorN:ident { $($field:ident),+ }, $n:expr, $constructor:ident) => {
|
||||||
impl<S> $VectorN<S> {
|
impl<S> $VectorN<S> {
|
||||||
|
@ -529,7 +529,7 @@ macro_rules! impl_scalar_ops {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
macro_rules! impl_scalar_ops_default {
|
macro_rules! impl_scalar_ops_default {
|
||||||
($VectorN:ident<$S:ident> { $($field:ident),+ }) => {
|
($VectorN:ident<$S:ident> { $($field:ident),+ }) => {
|
||||||
impl_operator_default!(Mul<$VectorN<$S>> for $S {
|
impl_operator_default!(Mul<$VectorN<$S>> for $S {
|
||||||
|
@ -547,9 +547,9 @@ macro_rules! impl_scalar_ops_default {
|
||||||
impl_vector!(Vector1 { x }, 1, vec1);
|
impl_vector!(Vector1 { x }, 1, vec1);
|
||||||
impl_vector!(Vector2 { x, y }, 2, vec2);
|
impl_vector!(Vector2 { x, y }, 2, vec2);
|
||||||
impl_vector!(Vector3 { x, y, z }, 3, vec3);
|
impl_vector!(Vector3 { x, y, z }, 3, vec3);
|
||||||
#[cfg(not(feature = "use_simd"))]
|
#[cfg(not(feature = "simd"))]
|
||||||
impl_vector!(Vector4 { x, y, z, w }, 4, vec4);
|
impl_vector!(Vector4 { x, y, z, w }, 4, vec4);
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_vector_default!(Vector4 { x, y, z, w }, 4, vec4);
|
impl_vector_default!(Vector4 { x, y, z, w }, 4, vec4);
|
||||||
|
|
||||||
impl_fixed_array_conversions!(Vector1<S> { x: 0 }, 1);
|
impl_fixed_array_conversions!(Vector1<S> { x: 0 }, 1);
|
||||||
|
@ -757,7 +757,7 @@ impl<S: fmt::Debug> fmt::Debug for Vector4<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl From<Simdf32x4> for Vector4<f32> {
|
impl From<Simdf32x4> for Vector4<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(f: Simdf32x4) -> Self {
|
fn from(f: Simdf32x4) -> Self {
|
||||||
|
@ -772,7 +772,7 @@ impl From<Simdf32x4> for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl Vector4<f32> {
|
impl Vector4<f32> {
|
||||||
/// Compute and return the square root of each element.
|
/// Compute and return the square root of each element.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -798,7 +798,7 @@ impl Vector4<f32> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl Into<Simdf32x4> for Vector4<f32> {
|
impl Into<Simdf32x4> for Vector4<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> Simdf32x4 {
|
fn into(self) -> Simdf32x4 {
|
||||||
|
@ -807,7 +807,7 @@ impl Into<Simdf32x4> for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Add<Vector4<f32>> for Vector4<f32> {
|
[Simdf32x4]; Add<Vector4<f32>> for Vector4<f32> {
|
||||||
fn add(lhs, rhs) -> Vector4<f32> {
|
fn add(lhs, rhs) -> Vector4<f32> {
|
||||||
|
@ -816,7 +816,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Sub<Vector4<f32>> for Vector4<f32> {
|
[Simdf32x4]; Sub<Vector4<f32>> for Vector4<f32> {
|
||||||
fn sub(lhs, rhs) -> Vector4<f32> {
|
fn sub(lhs, rhs) -> Vector4<f32> {
|
||||||
|
@ -825,7 +825,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdf32x4]; Mul<f32> for Vector4<f32> {
|
[Simdf32x4]; Mul<f32> for Vector4<f32> {
|
||||||
fn mul(lhs, rhs) -> Vector4<f32> {
|
fn mul(lhs, rhs) -> Vector4<f32> {
|
||||||
|
@ -834,7 +834,7 @@ impl_operator_simd!{@rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdf32x4]; Div<f32> for Vector4<f32> {
|
[Simdf32x4]; Div<f32> for Vector4<f32> {
|
||||||
fn div(lhs, rhs) -> Vector4<f32> {
|
fn div(lhs, rhs) -> Vector4<f32> {
|
||||||
|
@ -845,7 +845,7 @@ impl_operator_simd!{@rs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdf32x4]; Neg for Vector4<f32> {
|
[Simdf32x4]; Neg for Vector4<f32> {
|
||||||
fn neg(lhs) -> Vector4<f32> {
|
fn neg(lhs) -> Vector4<f32> {
|
||||||
|
@ -854,7 +854,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl AddAssign for Vector4<f32> {
|
impl AddAssign for Vector4<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_assign(&mut self, rhs: Self) {
|
fn add_assign(&mut self, rhs: Self) {
|
||||||
|
@ -864,7 +864,7 @@ impl AddAssign for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl SubAssign for Vector4<f32> {
|
impl SubAssign for Vector4<f32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub_assign(&mut self, rhs: Self) {
|
fn sub_assign(&mut self, rhs: Self) {
|
||||||
|
@ -874,7 +874,7 @@ impl SubAssign for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl MulAssign<f32> for Vector4<f32> {
|
impl MulAssign<f32> for Vector4<f32> {
|
||||||
fn mul_assign(&mut self, other: f32) {
|
fn mul_assign(&mut self, other: f32) {
|
||||||
let s: Simdf32x4 = (*self).into();
|
let s: Simdf32x4 = (*self).into();
|
||||||
|
@ -883,7 +883,7 @@ impl MulAssign<f32> for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl DivAssign<f32> for Vector4<f32> {
|
impl DivAssign<f32> for Vector4<f32> {
|
||||||
fn div_assign(&mut self, other: f32) {
|
fn div_assign(&mut self, other: f32) {
|
||||||
let s: Simdf32x4 = (*self).into();
|
let s: Simdf32x4 = (*self).into();
|
||||||
|
@ -892,7 +892,7 @@ impl DivAssign<f32> for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl ElementWise for Vector4<f32> {
|
impl ElementWise for Vector4<f32> {
|
||||||
#[inline] fn add_element_wise(self, rhs: Vector4<f32>) -> Vector4<f32> { self + rhs }
|
#[inline] fn add_element_wise(self, rhs: Vector4<f32>) -> Vector4<f32> { self + rhs }
|
||||||
#[inline] fn sub_element_wise(self, rhs: Vector4<f32>) -> Vector4<f32> { self - rhs }
|
#[inline] fn sub_element_wise(self, rhs: Vector4<f32>) -> Vector4<f32> { self - rhs }
|
||||||
|
@ -921,7 +921,7 @@ impl ElementWise for Vector4<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl ElementWise<f32> for Vector4<f32> {
|
impl ElementWise<f32> for Vector4<f32> {
|
||||||
#[inline] fn add_element_wise(self, rhs: f32) -> Vector4<f32> {
|
#[inline] fn add_element_wise(self, rhs: f32) -> Vector4<f32> {
|
||||||
let s: Simdf32x4 = self.into();
|
let s: Simdf32x4 = self.into();
|
||||||
|
@ -950,7 +950,7 @@ impl ElementWise<f32> for Vector4<f32> {
|
||||||
#[inline] fn div_assign_element_wise(&mut self, rhs: f32) { (*self) /= rhs; }
|
#[inline] fn div_assign_element_wise(&mut self, rhs: f32) { (*self) /= rhs; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl From<Simdi32x4> for Vector4<i32> {
|
impl From<Simdi32x4> for Vector4<i32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(f: Simdi32x4) -> Self {
|
fn from(f: Simdi32x4) -> Self {
|
||||||
|
@ -965,7 +965,7 @@ impl From<Simdi32x4> for Vector4<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl Into<Simdi32x4> for Vector4<i32> {
|
impl Into<Simdi32x4> for Vector4<i32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> Simdi32x4 {
|
fn into(self) -> Simdi32x4 {
|
||||||
|
@ -974,7 +974,7 @@ impl Into<Simdi32x4> for Vector4<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdi32x4]; Add<Vector4<i32>> for Vector4<i32> {
|
[Simdi32x4]; Add<Vector4<i32>> for Vector4<i32> {
|
||||||
fn add(lhs, rhs) -> Vector4<i32> {
|
fn add(lhs, rhs) -> Vector4<i32> {
|
||||||
|
@ -983,7 +983,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdi32x4]; Sub<Vector4<i32>> for Vector4<i32> {
|
[Simdi32x4]; Sub<Vector4<i32>> for Vector4<i32> {
|
||||||
fn sub(lhs, rhs) -> Vector4<i32> {
|
fn sub(lhs, rhs) -> Vector4<i32> {
|
||||||
|
@ -992,7 +992,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdi32x4]; Mul<i32> for Vector4<i32> {
|
[Simdi32x4]; Mul<i32> for Vector4<i32> {
|
||||||
fn mul(lhs, rhs) -> Vector4<i32> {
|
fn mul(lhs, rhs) -> Vector4<i32> {
|
||||||
|
@ -1001,7 +1001,7 @@ impl_operator_simd!{@rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdi32x4]; Neg for Vector4<i32> {
|
[Simdi32x4]; Neg for Vector4<i32> {
|
||||||
fn neg(lhs) -> Vector4<i32> {
|
fn neg(lhs) -> Vector4<i32> {
|
||||||
|
@ -1010,7 +1010,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl AddAssign for Vector4<i32> {
|
impl AddAssign for Vector4<i32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_assign(&mut self, rhs: Self) {
|
fn add_assign(&mut self, rhs: Self) {
|
||||||
|
@ -1020,7 +1020,7 @@ impl AddAssign for Vector4<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl SubAssign for Vector4<i32> {
|
impl SubAssign for Vector4<i32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub_assign(&mut self, rhs: Self) {
|
fn sub_assign(&mut self, rhs: Self) {
|
||||||
|
@ -1030,7 +1030,7 @@ impl SubAssign for Vector4<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl MulAssign<i32> for Vector4<i32> {
|
impl MulAssign<i32> for Vector4<i32> {
|
||||||
fn mul_assign(&mut self, other: i32) {
|
fn mul_assign(&mut self, other: i32) {
|
||||||
let s: Simdi32x4 = (*self).into();
|
let s: Simdi32x4 = (*self).into();
|
||||||
|
@ -1039,7 +1039,7 @@ impl MulAssign<i32> for Vector4<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl From<Simdu32x4> for Vector4<u32> {
|
impl From<Simdu32x4> for Vector4<u32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(f: Simdu32x4) -> Self {
|
fn from(f: Simdu32x4) -> Self {
|
||||||
|
@ -1054,7 +1054,7 @@ impl From<Simdu32x4> for Vector4<u32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl Into<Simdu32x4> for Vector4<u32> {
|
impl Into<Simdu32x4> for Vector4<u32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> Simdu32x4 {
|
fn into(self) -> Simdu32x4 {
|
||||||
|
@ -1063,7 +1063,7 @@ impl Into<Simdu32x4> for Vector4<u32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdu32x4]; Add<Vector4<u32>> for Vector4<u32> {
|
[Simdu32x4]; Add<Vector4<u32>> for Vector4<u32> {
|
||||||
fn add(lhs, rhs) -> Vector4<u32> {
|
fn add(lhs, rhs) -> Vector4<u32> {
|
||||||
|
@ -1072,7 +1072,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{
|
impl_operator_simd!{
|
||||||
[Simdu32x4]; Sub<Vector4<u32>> for Vector4<u32> {
|
[Simdu32x4]; Sub<Vector4<u32>> for Vector4<u32> {
|
||||||
fn sub(lhs, rhs) -> Vector4<u32> {
|
fn sub(lhs, rhs) -> Vector4<u32> {
|
||||||
|
@ -1081,7 +1081,7 @@ impl_operator_simd!{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl_operator_simd!{@rs
|
impl_operator_simd!{@rs
|
||||||
[Simdu32x4]; Mul<u32> for Vector4<u32> {
|
[Simdu32x4]; Mul<u32> for Vector4<u32> {
|
||||||
fn mul(lhs, rhs) -> Vector4<u32> {
|
fn mul(lhs, rhs) -> Vector4<u32> {
|
||||||
|
@ -1090,7 +1090,7 @@ impl_operator_simd!{@rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl AddAssign for Vector4<u32> {
|
impl AddAssign for Vector4<u32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add_assign(&mut self, rhs: Self) {
|
fn add_assign(&mut self, rhs: Self) {
|
||||||
|
@ -1100,7 +1100,7 @@ impl AddAssign for Vector4<u32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl SubAssign for Vector4<u32> {
|
impl SubAssign for Vector4<u32> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub_assign(&mut self, rhs: Self) {
|
fn sub_assign(&mut self, rhs: Self) {
|
||||||
|
@ -1110,7 +1110,7 @@ impl SubAssign for Vector4<u32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
impl MulAssign<u32> for Vector4<u32> {
|
impl MulAssign<u32> for Vector4<u32> {
|
||||||
fn mul_assign(&mut self, other: u32) {
|
fn mul_assign(&mut self, other: u32) {
|
||||||
let s: Simdu32x4 = (*self).into();
|
let s: Simdu32x4 = (*self).into();
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
|
|
||||||
#[cfg(feature = "eders")]
|
#[cfg(feature = "serde")]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
use cgmath::*;
|
use cgmath::*;
|
||||||
|
@ -46,7 +46,7 @@ fn test_look_at() {
|
||||||
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
assert_ulps_eq!(&t.transform_point(point), &view_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eders")]
|
#[cfg(feature = "serde")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize() {
|
fn test_serialize() {
|
||||||
let t = Decomposed {
|
let t = Decomposed {
|
||||||
|
|
|
@ -146,7 +146,7 @@ mod test_magnitude {
|
||||||
assert_eq!(a.magnitude(), a_res);
|
assert_eq!(a.magnitude(), a_res);
|
||||||
assert_eq!(b.magnitude(), b_res);
|
assert_eq!(b.magnitude(), b_res);
|
||||||
|
|
||||||
#[cfg(feature = "use_simd")]
|
#[cfg(feature = "simd")]
|
||||||
{
|
{
|
||||||
let a = Vector4::new(1f32, 4f32, 9f32, 16f32);
|
let a = Vector4::new(1f32, 4f32, 9f32, 16f32);
|
||||||
assert_ulps_eq!(a.sqrt_element_wide(), Vector4::new(1f32, 2f32, 3f32, 4f32));
|
assert_ulps_eq!(a.sqrt_element_wide(), Vector4::new(1f32, 2f32, 3f32, 4f32));
|
||||||
|
|
Loading…
Reference in a new issue