#![doc = " Trait implementations for quaternion."]
#![doc = ""]
#![doc = " This file is auto-generated by clifford-codegen."]
#![doc = " Do not edit manually."]
use super::types::{Bivector, Imaginary, Quaternion, Scalar};
#[allow(unused_imports)]
use crate::ops::{
Antidot, Antireverse, Antisandwich, Antiwedge, BulkContract, BulkExpand, Dot,
InverseAntisandwich, InverseSandwich, Involute, LeftContract, Reverse, RightComplement,
RightContract, Sandwich, ScalarProduct, Transform, Versor, VersorInverse, Wedge,
WeightContract, WeightDual, WeightExpand,
};
use crate::scalar::Float;
#[allow(unused_imports)]
use crate::wrappers::Unit;
use approx::{AbsDiffEq, RelativeEq, UlpsEq};
use std::ops::{Add, Mul, Neg, Sub};
impl<T: Float> Add for Bivector<T> {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Self::new_unchecked(self.k() + rhs.k())
}
}
impl<T: Float> Sub for Bivector<T> {
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self {
Self::new_unchecked(self.k() - rhs.k())
}
}
impl<T: Float> Neg for Bivector<T> {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self::new_unchecked(-self.k())
}
}
impl<T: Float> Mul<T> for Bivector<T> {
type Output = Self;
#[inline]
fn mul(self, scalar: T) -> Self {
self.scale(scalar)
}
}
impl Mul<Bivector<f32>> for f32 {
type Output = Bivector<f32>;
#[inline]
fn mul(self, v: Bivector<f32>) -> Bivector<f32> {
v.scale(self)
}
}
impl Mul<Bivector<f64>> for f64 {
type Output = Bivector<f64>;
#[inline]
fn mul(self, v: Bivector<f64>) -> Bivector<f64> {
v.scale(self)
}
}
impl<T: Float> Mul<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn mul(self, rhs: Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.k()))
}
}
impl<T: Float> Mul<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn mul(self, rhs: Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.j() * self.k()), rhs.i() * self.k())
}
}
impl<T: Float> Mul<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(rhs.k() * self.k()),
-(rhs.j() * self.k()),
rhs.i() * self.k(),
rhs.w() * self.k(),
)
}
}
impl<T: Float> Mul<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn mul(self, rhs: Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.k())
}
}
impl<T: Float> Add for Imaginary<T> {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Self::new_unchecked(self.i() + rhs.i(), self.j() + rhs.j())
}
}
impl<T: Float> Sub for Imaginary<T> {
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self {
Self::new_unchecked(self.i() - rhs.i(), self.j() - rhs.j())
}
}
impl<T: Float> Neg for Imaginary<T> {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self::new_unchecked(-self.i(), -self.j())
}
}
impl<T: Float> Mul<T> for Imaginary<T> {
type Output = Self;
#[inline]
fn mul(self, scalar: T) -> Self {
self.scale(scalar)
}
}
impl Mul<Imaginary<f32>> for f32 {
type Output = Imaginary<f32>;
#[inline]
fn mul(self, v: Imaginary<f32>) -> Imaginary<f32> {
v.scale(self)
}
}
impl Mul<Imaginary<f64>> for f64 {
type Output = Imaginary<f64>;
#[inline]
fn mul(self, v: Imaginary<f64>) -> Imaginary<f64> {
v.scale(self)
}
}
impl<T: Float> Mul<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn mul(self, rhs: Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.k() * self.j(), -(rhs.k() * self.i()))
}
}
impl<T: Float> Mul<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(rhs.i() * self.i()) + -(rhs.j() * self.j()),
rhs.k() * self.j() + rhs.w() * self.i(),
-(rhs.k() * self.i()) + rhs.w() * self.j(),
-(rhs.i() * self.j()) + rhs.j() * self.i(),
)
}
}
impl<T: Float> Mul<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn mul(self, rhs: Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.i(), rhs.s() * self.j())
}
}
impl<T: Float> Add for Quaternion<T> {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Self::new_unchecked(
self.w() + rhs.w(),
self.i() + rhs.i(),
self.j() + rhs.j(),
self.k() + rhs.k(),
)
}
}
impl<T: Float> Sub for Quaternion<T> {
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self {
Self::new_unchecked(
self.w() - rhs.w(),
self.i() - rhs.i(),
self.j() - rhs.j(),
self.k() - rhs.k(),
)
}
}
impl<T: Float> Neg for Quaternion<T> {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self::new_unchecked(-self.w(), -self.i(), -self.j(), -self.k())
}
}
impl<T: Float> Mul<T> for Quaternion<T> {
type Output = Self;
#[inline]
fn mul(self, scalar: T) -> Self {
self.scale(scalar)
}
}
impl Mul<Quaternion<f32>> for f32 {
type Output = Quaternion<f32>;
#[inline]
fn mul(self, v: Quaternion<f32>) -> Quaternion<f32> {
v.scale(self)
}
}
impl Mul<Quaternion<f64>> for f64 {
type Output = Quaternion<f64>;
#[inline]
fn mul(self, v: Quaternion<f64>) -> Quaternion<f64> {
v.scale(self)
}
}
impl<T: Float> Mul<Bivector<T>> for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Bivector<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(rhs.k() * self.k()),
rhs.k() * self.j(),
-(rhs.k() * self.i()),
rhs.k() * self.w(),
)
}
}
impl<T: Float> Mul<Imaginary<T>> for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Imaginary<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(rhs.i() * self.i()) + -(rhs.j() * self.j()),
-(rhs.j() * self.k()) + rhs.i() * self.w(),
rhs.i() * self.k() + rhs.j() * self.w(),
-(rhs.i() * self.j()) + rhs.j() * self.i(),
)
}
}
impl<T: Float> Mul<Quaternion<T>> for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(rhs.i() * self.i())
+ -(rhs.j() * self.j())
+ -(rhs.k() * self.k())
+ rhs.w() * self.w(),
-(rhs.j() * self.k()) + rhs.i() * self.w() + rhs.k() * self.j() + rhs.w() * self.i(),
-(rhs.k() * self.i()) + rhs.i() * self.k() + rhs.j() * self.w() + rhs.w() * self.j(),
-(rhs.i() * self.j()) + rhs.j() * self.i() + rhs.k() * self.w() + rhs.w() * self.k(),
)
}
}
impl<T: Float> Mul<Scalar<T>> for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Scalar<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
rhs.s() * self.w(),
rhs.s() * self.i(),
rhs.s() * self.j(),
rhs.s() * self.k(),
)
}
}
impl<T: Float> Add for Scalar<T> {
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self {
Self::new_unchecked(self.s() + rhs.s())
}
}
impl<T: Float> Sub for Scalar<T> {
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self {
Self::new_unchecked(self.s() - rhs.s())
}
}
impl<T: Float> Neg for Scalar<T> {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self::new_unchecked(-self.s())
}
}
impl<T: Float> Mul<T> for Scalar<T> {
type Output = Self;
#[inline]
fn mul(self, scalar: T) -> Self {
self.scale(scalar)
}
}
impl Mul<Scalar<f32>> for f32 {
type Output = Scalar<f32>;
#[inline]
fn mul(self, v: Scalar<f32>) -> Scalar<f32> {
v.scale(self)
}
}
impl Mul<Scalar<f64>> for f64 {
type Output = Scalar<f64>;
#[inline]
fn mul(self, v: Scalar<f64>) -> Scalar<f64> {
v.scale(self)
}
}
impl<T: Float> Mul<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn mul(self, rhs: Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.s())
}
}
impl<T: Float> Mul<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn mul(self, rhs: Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.i() * self.s(), rhs.j() * self.s())
}
}
impl<T: Float> Mul<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn mul(self, rhs: Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
rhs.w() * self.s(),
rhs.i() * self.s(),
rhs.j() * self.s(),
rhs.k() * self.s(),
)
}
}
impl<T: Float> Mul<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn mul(self, rhs: Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.s())
}
}
#[doc = "Wedge (exterior/outer) product of [`Bivector`] and [`Scalar`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Scalar<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.as_inner().k())
}
}
#[doc = "Wedge (exterior/outer) product of [`Imaginary`] and [`Imaginary`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Imaginary<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.i() * self.j()) + rhs.j() * self.i())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.i() * self.as_inner().j()) + rhs.j() * self.as_inner().i())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().i() * self.j()) + rhs.as_inner().j() * self.i())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().j()) + rhs.as_inner().j() * self.as_inner().i(),
)
}
}
#[doc = "Wedge (exterior/outer) product of [`Imaginary`] and [`Scalar`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.i(), rhs.s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.as_inner().i(), rhs.s() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().s() * self.i(), rhs.as_inner().s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().s() * self.as_inner().i(),
rhs.as_inner().s() * self.as_inner().j(),
)
}
}
#[doc = "Wedge (exterior/outer) product of [`Scalar`] and [`Bivector`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Bivector<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Bivector<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.as_inner().s())
}
}
#[doc = "Wedge (exterior/outer) product of [`Scalar`] and [`Imaginary`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.i() * self.s(), rhs.j() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.i() * self.as_inner().s(), rhs.j() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().i() * self.s(), rhs.as_inner().j() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().i() * self.as_inner().s(),
rhs.as_inner().j() * self.as_inner().s(),
)
}
}
#[doc = "Wedge (exterior/outer) product of [`Scalar`] and [`Scalar`].\n\nThe wedge product `a ^ b` computes the outer product, which represents\nthe oriented subspace spanned by both operands. The result grade is the\nsum of the input grades (or zero if they share common factors)."]
impl<T: Float> Wedge<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn wedge(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Wedge<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn wedge(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.as_inner().s())
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Bivector`] and [`Bivector`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.as_inner().k())
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Bivector`] and [`Imaginary`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.i() * self.k()), -(rhs.j() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.i() * self.as_inner().k()),
-(rhs.j() * self.as_inner().k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().i() * self.k()),
-(rhs.as_inner().j() * self.k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().k()),
-(rhs.as_inner().j() * self.as_inner().k()),
)
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Bivector`] and [`Scalar`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Scalar<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Scalar<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.as_inner().k())
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Imaginary`] and [`Bivector`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.k() * self.i()), -(rhs.k() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.k() * self.as_inner().i()),
-(rhs.k() * self.as_inner().j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().k() * self.i()),
-(rhs.as_inner().k() * self.j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().k() * self.as_inner().i()),
-(rhs.as_inner().k() * self.as_inner().j()),
)
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Imaginary`] and [`Imaginary`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Imaginary<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.j()) + rhs.j() * self.i())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.as_inner().j()) + rhs.j() * self.as_inner().i())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().i() * self.j()) + rhs.as_inner().j() * self.i())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().j()) + rhs.as_inner().j() * self.as_inner().i(),
)
}
}
#[doc = "Antiwedge (regressive/meet) product of [`Scalar`] and [`Bivector`].\n\nThe antiwedge product `a v b` computes the meet of two subspaces,\nreturning the largest subspace contained in both. In projective geometry,\nthis finds intersections (e.g., where two planes meet to form a line)."]
impl<T: Float> Antiwedge<Bivector<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Bivector<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antiwedge<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn antiwedge(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.as_inner().s())
}
}
#[doc = "Left contraction of [`Bivector`] into [`Bivector`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Bivector<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.as_inner().k()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.as_inner().k()))
}
}
#[doc = "Left contraction of [`Imaginary`] into [`Bivector`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.k() * self.j(), -(rhs.k() * self.i()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.k() * self.as_inner().j(),
-(rhs.k() * self.as_inner().i()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().k() * self.j(),
-(rhs.as_inner().k() * self.i()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().k() * self.as_inner().j(),
-(rhs.as_inner().k() * self.as_inner().i()),
)
}
}
#[doc = "Left contraction of [`Imaginary`] into [`Imaginary`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Imaginary<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.i()) + -(rhs.j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j()),
)
}
}
#[doc = "Left contraction of [`Scalar`] into [`Bivector`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Bivector<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn left_contract(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.as_inner().s())
}
}
#[doc = "Left contraction of [`Scalar`] into [`Imaginary`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.i() * self.s(), rhs.j() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.i() * self.as_inner().s(), rhs.j() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().i() * self.s(), rhs.as_inner().j() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().i() * self.as_inner().s(),
rhs.as_inner().j() * self.as_inner().s(),
)
}
}
#[doc = "Left contraction of [`Scalar`] into [`Scalar`].\n\nThe left contraction `a _| b` projects `a` onto `b`, returning the\ncomponent of `b` orthogonal to `a`. The result grade is grade(b) - grade(a)\n(or zero if grade(a) > grade(b))."]
impl<T: Float> LeftContract<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> LeftContract<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn left_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.as_inner().s())
}
}
#[doc = "Right contraction of [`Bivector`] by [`Bivector`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Bivector<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.as_inner().k()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Bivector<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.as_inner().k()))
}
}
#[doc = "Right contraction of [`Bivector`] by [`Imaginary`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.j() * self.k()), rhs.i() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.j() * self.as_inner().k()),
rhs.i() * self.as_inner().k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.k()),
rhs.as_inner().i() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.as_inner().k()),
rhs.as_inner().i() * self.as_inner().k(),
)
}
}
#[doc = "Right contraction of [`Bivector`] by [`Scalar`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Scalar<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.as_inner().k())
}
}
#[doc = "Right contraction of [`Imaginary`] by [`Imaginary`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Imaginary<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.i()) + -(rhs.j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j()),
)
}
}
#[doc = "Right contraction of [`Imaginary`] by [`Scalar`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.i(), rhs.s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.as_inner().i(), rhs.s() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().s() * self.i(), rhs.as_inner().s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().s() * self.as_inner().i(),
rhs.as_inner().s() * self.as_inner().j(),
)
}
}
#[doc = "Right contraction of [`Scalar`] by [`Scalar`].\n\nThe right contraction `a |_ b` projects `b` onto `a`, returning the\ncomponent of `a` orthogonal to `b`. The result grade is grade(a) - grade(b)\n(or zero if grade(b) > grade(a))."]
impl<T: Float> RightContract<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> RightContract<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn right_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.as_inner().s())
}
}
#[doc = "Sandwich product: [`Bivector`] x [`Bivector`] x rev([`Bivector`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(self.k() * operand.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k() * self.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Sandwich product: [`Bivector`] x [`Imaginary`] x rev([`Bivector`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(self.k() * operand.i() * self.k()),
-(self.k() * operand.j() * self.k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(operand.i()), -(operand.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.as_inner().i() * self.k() * self.k()),
-(operand.as_inner().j() * self.k() * self.k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(-(operand.as_inner().i()), -(operand.as_inner().j()))
}
}
#[doc = "Sandwich product: [`Bivector`] x [`Quaternion`] x rev([`Bivector`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
self.k() * operand.w() * self.k(),
-(self.k() * operand.i() * self.k()),
-(self.k() * operand.j() * self.k()),
self.k() * operand.k() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(operand.w(), -(operand.i()), -(operand.j()), operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w() * self.k() * self.k(),
-(operand.as_inner().i() * self.k() * self.k()),
-(operand.as_inner().j() * self.k() * self.k()),
operand.as_inner().k() * self.k() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w(),
-(operand.as_inner().i()),
-(operand.as_inner().j()),
operand.as_inner().k(),
)
}
}
#[doc = "Sandwich product: [`Bivector`] x [`Scalar`] x rev([`Bivector`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(self.k() * operand.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(operand.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s() * self.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s())
}
}
#[doc = "Sandwich product: [`Imaginary`] x [`Bivector`] x rev([`Imaginary`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(
self.i() * operand.k() * self.i() + self.j() * operand.k() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(
operand.as_inner().k() * self.i() * self.i()
+ operand.as_inner().k() * self.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Sandwich product: [`Imaginary`] x [`Imaginary`] x rev([`Imaginary`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(self.i() * operand.i() * self.i()) - self.i() * operand.j() * self.j()
+ self.j() * operand.i() * self.j()
- self.j() * operand.j() * self.i(),
-(self.i() * operand.i() * self.j()) + self.i() * operand.j() * self.i()
- self.j() * operand.i() * self.i()
- self.j() * operand.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.i())
+ -T::TWO * operand.j() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.i() * self.as_inner().j() * self.as_inner().j(),
-T::TWO * operand.i() * self.as_inner().i() * self.as_inner().j()
+ -T::TWO * operand.j() * self.as_inner().j() * self.as_inner().j()
+ operand.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.as_inner().i() * self.i() * self.i())
+ -T::TWO * operand.as_inner().j() * self.i() * self.j()
+ operand.as_inner().i() * self.j() * self.j(),
-(operand.as_inner().j() * self.j() * self.j())
+ -T::TWO * operand.as_inner().i() * self.i() * self.j()
+ operand.as_inner().j() * self.i() * self.i(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.as_inner().i())
+ -T::TWO * operand.as_inner().j() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.as_inner().i() * self.as_inner().j() * self.as_inner().j(),
-T::TWO * operand.as_inner().i() * self.as_inner().i() * self.as_inner().j()
+ -T::TWO * operand.as_inner().j() * self.as_inner().j() * self.as_inner().j()
+ operand.as_inner().j(),
)
}
}
#[doc = "Sandwich product: [`Imaginary`] x [`Quaternion`] x rev([`Imaginary`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
self.i() * operand.k() * self.j()
- self.i() * operand.w() * self.i()
- self.j() * operand.k() * self.i()
- self.j() * operand.w() * self.j(),
-(self.i() * operand.i() * self.i()) - self.i() * operand.j() * self.j()
+ self.j() * operand.i() * self.j()
- self.j() * operand.j() * self.i(),
-(self.i() * operand.i() * self.j()) + self.i() * operand.j() * self.i()
- self.j() * operand.i() * self.i()
- self.j() * operand.j() * self.j(),
self.i() * operand.k() * self.i()
+ self.i() * operand.w() * self.j()
+ self.j() * operand.k() * self.j()
- self.j() * operand.w() * self.i(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.w()),
-(operand.i())
+ -T::TWO * operand.j() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.i() * self.as_inner().j() * self.as_inner().j(),
-T::TWO * operand.i() * self.as_inner().i() * self.as_inner().j()
+ -T::TWO * operand.j() * self.as_inner().j() * self.as_inner().j()
+ operand.j(),
operand.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.as_inner().w() * self.i() * self.i())
+ -(operand.as_inner().w() * self.j() * self.j()),
-(operand.as_inner().i() * self.i() * self.i())
+ -T::TWO * operand.as_inner().j() * self.i() * self.j()
+ operand.as_inner().i() * self.j() * self.j(),
-(operand.as_inner().j() * self.j() * self.j())
+ -T::TWO * operand.as_inner().i() * self.i() * self.j()
+ operand.as_inner().j() * self.i() * self.i(),
operand.as_inner().k() * self.i() * self.i()
+ operand.as_inner().k() * self.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.as_inner().w()),
-(operand.as_inner().i())
+ -T::TWO * operand.as_inner().j() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.as_inner().i() * self.as_inner().j() * self.as_inner().j(),
-T::TWO * operand.as_inner().i() * self.as_inner().i() * self.as_inner().j()
+ -T::TWO * operand.as_inner().j() * self.as_inner().j() * self.as_inner().j()
+ operand.as_inner().j(),
operand.as_inner().k(),
)
}
}
#[doc = "Sandwich product: [`Imaginary`] x [`Scalar`] x rev([`Imaginary`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(
-(self.i() * operand.s() * self.i()) - self.j() * operand.s() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(-(operand.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(operand.as_inner().s() * self.i() * self.i())
+ -(operand.as_inner().s() * self.j() * self.j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(operand.as_inner().s()))
}
}
#[doc = "Sandwich product: [`Scalar`] x [`Bivector`] x rev([`Scalar`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(self.s() * operand.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Bivector<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k() * self.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Sandwich product: [`Scalar`] x [`Imaginary`] x rev([`Scalar`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
self.s() * operand.i() * self.s(),
self.s() * operand.j() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(operand.i(), operand.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
operand.as_inner().i() * self.s() * self.s(),
operand.as_inner().j() * self.s() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(operand.as_inner().i(), operand.as_inner().j())
}
}
#[doc = "Sandwich product: [`Scalar`] x [`Quaternion`] x rev([`Scalar`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
self.s() * operand.w() * self.s(),
self.s() * operand.i() * self.s(),
self.s() * operand.j() * self.s(),
self.s() * operand.k() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Quaternion<T>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(operand.w(), operand.i(), operand.j(), operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w() * self.s() * self.s(),
operand.as_inner().i() * self.s() * self.s(),
operand.as_inner().j() * self.s() * self.s(),
operand.as_inner().k() * self.s() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Quaternion<T>>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w(),
operand.as_inner().i(),
operand.as_inner().j(),
operand.as_inner().k(),
)
}
}
#[doc = "Sandwich product: [`Scalar`] x [`Scalar`] x rev([`Scalar`]).\n\nThe sandwich product `v x a x rev(v)` applies the transformation\nrepresented by the versor `v` to the operand `a`. For rotors, this\nperforms rotation; for motors, it performs rigid body transformation."]
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(self.s() * operand.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(operand.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s() * self.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Sandwich<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn sandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s())
}
}
#[doc = "Antisandwich product: [`Bivector`] x [`Bivector`] x antirev([`Bivector`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(self.k() * operand.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k() * self.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Antisandwich product: [`Bivector`] x [`Imaginary`] x antirev([`Bivector`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
self.k() * operand.i() * self.k(),
self.k() * operand.j() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(operand.i(), operand.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
operand.as_inner().i() * self.k() * self.k(),
operand.as_inner().j() * self.k() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(operand.as_inner().i(), operand.as_inner().j())
}
}
#[doc = "Antisandwich product: [`Bivector`] x [`Quaternion`] x antirev([`Bivector`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
self.k() * operand.w() * self.k(),
self.k() * operand.i() * self.k(),
self.k() * operand.j() * self.k(),
self.k() * operand.k() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(operand.w(), operand.i(), operand.j(), operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w() * self.k() * self.k(),
operand.as_inner().i() * self.k() * self.k(),
operand.as_inner().j() * self.k() * self.k(),
operand.as_inner().k() * self.k() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w(),
operand.as_inner().i(),
operand.as_inner().j(),
operand.as_inner().k(),
)
}
}
#[doc = "Antisandwich product: [`Bivector`] x [`Scalar`] x antirev([`Bivector`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(self.k() * operand.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(operand.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s() * self.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s())
}
}
#[doc = "Antisandwich product: [`Imaginary`] x [`Bivector`] x antirev([`Imaginary`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(
self.i() * operand.k() * self.i() + self.j() * operand.k() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(
operand.as_inner().k() * self.i() * self.i()
+ operand.as_inner().k() * self.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Antisandwich product: [`Imaginary`] x [`Imaginary`] x antirev([`Imaginary`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
self.i() * operand.i() * self.i() + self.i() * operand.j() * self.j()
- self.j() * operand.i() * self.j()
+ self.j() * operand.j() * self.i(),
self.i() * operand.i() * self.j() - self.i() * operand.j() * self.i()
+ self.j() * operand.i() * self.i()
+ self.j() * operand.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-T::TWO * operand.i() * self.as_inner().j() * self.as_inner().j()
+ T::TWO * operand.j() * self.as_inner().i() * self.as_inner().j()
+ operand.i(),
-(operand.j())
+ T::TWO * operand.i() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.j() * self.as_inner().j() * self.as_inner().j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.as_inner().i() * self.j() * self.j())
+ T::TWO * operand.as_inner().j() * self.i() * self.j()
+ operand.as_inner().i() * self.i() * self.i(),
-(operand.as_inner().j() * self.i() * self.i())
+ T::TWO * operand.as_inner().i() * self.i() * self.j()
+ operand.as_inner().j() * self.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-T::TWO * operand.as_inner().i() * self.as_inner().j() * self.as_inner().j()
+ T::TWO * operand.as_inner().j() * self.as_inner().i() * self.as_inner().j()
+ operand.as_inner().i(),
-(operand.as_inner().j())
+ T::TWO * operand.as_inner().i() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.as_inner().j() * self.as_inner().j() * self.as_inner().j(),
)
}
}
#[doc = "Antisandwich product: [`Imaginary`] x [`Quaternion`] x antirev([`Imaginary`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(self.i() * operand.k() * self.j()) - self.i() * operand.w() * self.i()
+ self.j() * operand.k() * self.i()
- self.j() * operand.w() * self.j(),
self.i() * operand.i() * self.i() + self.i() * operand.j() * self.j()
- self.j() * operand.i() * self.j()
+ self.j() * operand.j() * self.i(),
self.i() * operand.i() * self.j() - self.i() * operand.j() * self.i()
+ self.j() * operand.i() * self.i()
+ self.j() * operand.j() * self.j(),
self.i() * operand.k() * self.i() - self.i() * operand.w() * self.j()
+ self.j() * operand.k() * self.j()
+ self.j() * operand.w() * self.i(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.w()),
-T::TWO * operand.i() * self.as_inner().j() * self.as_inner().j()
+ T::TWO * operand.j() * self.as_inner().i() * self.as_inner().j()
+ operand.i(),
-(operand.j())
+ T::TWO * operand.i() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.j() * self.as_inner().j() * self.as_inner().j(),
operand.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.as_inner().w() * self.i() * self.i())
+ -(operand.as_inner().w() * self.j() * self.j()),
-(operand.as_inner().i() * self.j() * self.j())
+ T::TWO * operand.as_inner().j() * self.i() * self.j()
+ operand.as_inner().i() * self.i() * self.i(),
-(operand.as_inner().j() * self.i() * self.i())
+ T::TWO * operand.as_inner().i() * self.i() * self.j()
+ operand.as_inner().j() * self.j() * self.j(),
operand.as_inner().k() * self.i() * self.i()
+ operand.as_inner().k() * self.j() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
-(operand.as_inner().w()),
-T::TWO * operand.as_inner().i() * self.as_inner().j() * self.as_inner().j()
+ T::TWO * operand.as_inner().j() * self.as_inner().i() * self.as_inner().j()
+ operand.as_inner().i(),
-(operand.as_inner().j())
+ T::TWO * operand.as_inner().i() * self.as_inner().i() * self.as_inner().j()
+ T::TWO * operand.as_inner().j() * self.as_inner().j() * self.as_inner().j(),
operand.as_inner().k(),
)
}
}
#[doc = "Antisandwich product: [`Imaginary`] x [`Scalar`] x antirev([`Imaginary`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(
-(self.i() * operand.s() * self.i()) - self.j() * operand.s() * self.j(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(-(operand.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(operand.as_inner().s() * self.i() * self.i())
+ -(operand.as_inner().s() * self.j() * self.j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(operand.as_inner().s()))
}
}
#[doc = "Antisandwich product: [`Scalar`] x [`Bivector`] x antirev([`Scalar`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(self.s() * operand.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Bivector<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k() * self.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(operand.as_inner().k())
}
}
#[doc = "Antisandwich product: [`Scalar`] x [`Imaginary`] x antirev([`Scalar`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(self.s() * operand.i() * self.s()),
-(self.s() * operand.j() * self.s()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(operand.i()), -(operand.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(operand.as_inner().i() * self.s() * self.s()),
-(operand.as_inner().j() * self.s() * self.s()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(-(operand.as_inner().i()), -(operand.as_inner().j()))
}
}
#[doc = "Antisandwich product: [`Scalar`] x [`Quaternion`] x antirev([`Scalar`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(
self.s() * operand.w() * self.s(),
-(self.s() * operand.i() * self.s()),
-(self.s() * operand.j() * self.s()),
self.s() * operand.k() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Quaternion<T>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Quaternion<T>) -> Quaternion<T> {
Quaternion::new_unchecked(operand.w(), -(operand.i()), -(operand.j()), operand.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w() * self.s() * self.s(),
-(operand.as_inner().i() * self.s() * self.s()),
-(operand.as_inner().j() * self.s() * self.s()),
operand.as_inner().k() * self.s() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Quaternion<T>>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
Quaternion::new_unchecked(
operand.as_inner().w(),
-(operand.as_inner().i()),
-(operand.as_inner().j()),
operand.as_inner().k(),
)
}
}
#[doc = "Antisandwich product: [`Scalar`] x [`Scalar`] x antirev([`Scalar`]).\n\nThe antisandwich product `v x a x antirev(v)` is the dual of the\nsandwich product, used in Projective GA for transforming dual objects\n(planes, ideal points). Motors use antisandwich for plane transforms."]
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(self.s() * operand.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(operand.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s() * self.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antisandwich<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn antisandwich(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(operand.as_inner().s())
}
}
#[doc = "Transform a [`Bivector`] using this [`Bivector`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Imaginary`] using this [`Bivector`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Quaternion`] using this [`Bivector`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Quaternion<T>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Unit<Bivector<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Scalar`] using this [`Bivector`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Scalar<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Bivector`] using this [`Imaginary`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Bivector<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Imaginary`] using this [`Imaginary`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Imaginary<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Quaternion`] using this [`Imaginary`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Quaternion<T>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Unit<Imaginary<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Scalar`] using this [`Imaginary`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Scalar<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Bivector`] using this [`Scalar`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Bivector<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Bivector<T>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn transform(&self, operand: &Unit<Bivector<T>>) -> Bivector<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Imaginary`] using this [`Scalar`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Imaginary<T>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn transform(&self, operand: &Unit<Imaginary<T>>) -> Imaginary<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Quaternion`] using this [`Scalar`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Quaternion<T>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Quaternion<T>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Quaternion<T>>> for Unit<Scalar<T>> {
type Output = Quaternion<T>;
#[inline]
fn transform(&self, operand: &Unit<Quaternion<T>>) -> Quaternion<T> {
self.sandwich(operand)
}
}
#[doc = "Transform a [`Scalar`] using this [`Scalar`].\n\nApplies the geometric transformation represented by this versor.\nFor rotors, this performs rotation. For motors, this performs rigid\nbody transformation (rotation + translation). Internally uses the\nsandwich product."]
impl<T: Float> Transform<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Scalar<T>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
impl<T: Float> Transform<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn transform(&self, operand: &Unit<Scalar<T>>) -> Scalar<T> {
self.sandwich(operand)
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.k() * operand.k() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(-(self.k() * operand.i() * self.k())) * inv_norm_sq,
(-(self.k() * operand.j() * self.k())) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(self.k() * operand.w() * self.k()) * inv_norm_sq,
(-(self.k() * operand.i() * self.k())) * inv_norm_sq,
(-(self.k() * operand.j() * self.k())) * inv_norm_sq,
(self.k() * operand.k() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(self.k() * operand.s() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Bivector<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.i() * operand.k() * self.i() + self.j() * operand.k() * self.j()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Imaginary<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(-(self.i() * operand.i() * self.i()) - self.i() * operand.j() * self.j()
+ self.j() * operand.i() * self.j()
- self.j() * operand.j() * self.i())
* inv_norm_sq,
(-(self.i() * operand.i() * self.j()) + self.i() * operand.j() * self.i()
- self.j() * operand.i() * self.i()
- self.j() * operand.j() * self.j())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(self.i() * operand.k() * self.j()
- self.i() * operand.w() * self.i()
- self.j() * operand.k() * self.i()
- self.j() * operand.w() * self.j())
* inv_norm_sq,
(-(self.i() * operand.i() * self.i()) - self.i() * operand.j() * self.j()
+ self.j() * operand.i() * self.j()
- self.j() * operand.j() * self.i())
* inv_norm_sq,
(-(self.i() * operand.i() * self.j()) + self.i() * operand.j() * self.i()
- self.j() * operand.i() * self.i()
- self.j() * operand.j() * self.j())
* inv_norm_sq,
(self.i() * operand.k() * self.i()
+ self.i() * operand.w() * self.j()
+ self.j() * operand.k() * self.j()
- self.j() * operand.w() * self.i())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Scalar<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(-(self.i() * operand.s() * self.i()) - self.j() * operand.s() * self.j())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.s() * operand.k() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(self.s() * operand.i() * self.s()) * inv_norm_sq,
(self.s() * operand.j() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(self.s() * operand.w() * self.s()) * inv_norm_sq,
(self.s() * operand.i() * self.s()) * inv_norm_sq,
(self.s() * operand.j() * self.s()) * inv_norm_sq,
(self.s() * operand.k() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseSandwich<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_sandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(self.s() * operand.s() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.k() * operand.k() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(self.k() * operand.i() * self.k()) * inv_norm_sq,
(self.k() * operand.j() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Quaternion<T>> for Bivector<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(self.k() * operand.w() * self.k()) * inv_norm_sq,
(self.k() * operand.i() * self.k()) * inv_norm_sq,
(self.k() * operand.j() * self.k()) * inv_norm_sq,
(self.k() * operand.k() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Scalar<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(self.k() * operand.s() * self.k()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Bivector<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.i() * operand.k() * self.i() + self.j() * operand.k() * self.j()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Imaginary<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(self.i() * operand.i() * self.i() + self.i() * operand.j() * self.j()
- self.j() * operand.i() * self.j()
+ self.j() * operand.j() * self.i())
* inv_norm_sq,
(self.i() * operand.i() * self.j() - self.i() * operand.j() * self.i()
+ self.j() * operand.i() * self.i()
+ self.j() * operand.j() * self.j())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Quaternion<T>> for Imaginary<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(-(self.i() * operand.k() * self.j()) - self.i() * operand.w() * self.i()
+ self.j() * operand.k() * self.i()
- self.j() * operand.w() * self.j())
* inv_norm_sq,
(self.i() * operand.i() * self.i() + self.i() * operand.j() * self.j()
- self.j() * operand.i() * self.j()
+ self.j() * operand.j() * self.i())
* inv_norm_sq,
(self.i() * operand.i() * self.j() - self.i() * operand.j() * self.i()
+ self.j() * operand.i() * self.i()
+ self.j() * operand.j() * self.j())
* inv_norm_sq,
(self.i() * operand.k() * self.i() - self.i() * operand.w() * self.j()
+ self.j() * operand.k() * self.j()
+ self.j() * operand.w() * self.i())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Scalar<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(-(self.i() * operand.s() * self.i()) - self.j() * operand.s() * self.j())
* inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Bivector<T>) -> Option<Bivector<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Bivector::new_unchecked(
(self.s() * operand.k() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Imaginary<T>) -> Option<Imaginary<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Imaginary::new_unchecked(
(-(self.s() * operand.i() * self.s())) * inv_norm_sq,
(-(self.s() * operand.j() * self.s())) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Quaternion<T>> for Scalar<T> {
type Output = Quaternion<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Quaternion<T>) -> Option<Quaternion<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Quaternion::new_unchecked(
(self.s() * operand.w() * self.s()) * inv_norm_sq,
(-(self.s() * operand.i() * self.s())) * inv_norm_sq,
(-(self.s() * operand.j() * self.s())) * inv_norm_sq,
(self.s() * operand.k() * self.s()) * inv_norm_sq,
))
}
}
#[allow(unused_variables)]
impl<T: Float> InverseAntisandwich<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn try_inverse_antisandwich(&self, operand: &Scalar<T>) -> Option<Scalar<T>> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Scalar::new_unchecked(
(self.s() * operand.s() * self.s()) * inv_norm_sq,
))
}
}
impl<T: Float> Versor<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn compose(&self, other: &Bivector<T>) -> Scalar<T> {
*self * *other
}
}
impl<T: Float> Versor<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn compose(&self, other: &Imaginary<T>) -> Imaginary<T> {
*self * *other
}
}
impl<T: Float> Versor<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn compose(&self, other: &Scalar<T>) -> Bivector<T> {
*self * *other
}
}
impl<T: Float> Versor<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn compose(&self, other: &Bivector<T>) -> Imaginary<T> {
*self * *other
}
}
impl<T: Float> Versor<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn compose(&self, other: &Scalar<T>) -> Imaginary<T> {
*self * *other
}
}
impl<T: Float> Versor<Bivector<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn compose(&self, other: &Bivector<T>) -> Bivector<T> {
*self * *other
}
}
impl<T: Float> Versor<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn compose(&self, other: &Imaginary<T>) -> Imaginary<T> {
*self * *other
}
}
impl<T: Float> Versor<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn compose(&self, other: &Scalar<T>) -> Scalar<T> {
*self * *other
}
}
impl<T: Float> ScalarProduct<Bivector<T>> for Bivector<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Bivector<T>) -> T {
-(self.k() * rhs.k())
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Bivector<T>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Bivector<T>) -> T {
-(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Bivector<T>>> for Bivector<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.as_inner().k())
}
}
impl<T: Float> ScalarProduct<Imaginary<T>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Imaginary<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Imaginary<T>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Imaginary<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Imaginary<T>>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> ScalarProduct<Scalar<T>> for Scalar<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Scalar<T>) -> T {
self.s() * rhs.s()
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Scalar<T>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Scalar<T>) -> T {
rhs.s() * self.as_inner().s()
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Scalar<T>>> for Scalar<T> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.s()
}
}
#[allow(unused_variables)]
impl<T: Float> ScalarProduct<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn scalar_product(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.as_inner().s()
}
}
#[doc = "Bulk contraction of [`Bivector`] with [`Bivector`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Bivector<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Bivector<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.as_inner().k())
}
}
#[doc = "Bulk contraction of [`Bivector`] with [`Imaginary`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.j() * self.k()), rhs.i() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.j() * self.as_inner().k()),
rhs.i() * self.as_inner().k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.k()),
rhs.as_inner().i() * self.k(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.as_inner().k()),
rhs.as_inner().i() * self.as_inner().k(),
)
}
}
#[doc = "Bulk contraction of [`Bivector`] with [`Scalar`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Scalar<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.as_inner().k())
}
}
#[doc = "Bulk contraction of [`Imaginary`] with [`Imaginary`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Imaginary<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.i()) + -(rhs.j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j()),
)
}
}
#[doc = "Bulk contraction of [`Imaginary`] with [`Scalar`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.s() * self.i()), -(rhs.s() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.s() * self.as_inner().i()),
-(rhs.s() * self.as_inner().j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().s() * self.i()),
-(rhs.as_inner().s() * self.j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().s() * self.as_inner().i()),
-(rhs.as_inner().s() * self.as_inner().j()),
)
}
}
#[doc = "Bulk contraction of [`Scalar`] with [`Scalar`].\n\nThe bulk contraction extracts the Euclidean (non-degenerate) component\nof the interior product. In PGA, this isolates the finite/spatial part."]
impl<T: Float> BulkContract<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkContract<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().s() * self.as_inner().s())
}
}
#[doc = "Weight contraction of [`Bivector`] with [`Bivector`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Bivector<T>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Bivector<T>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.as_inner().k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Bivector<T>>> for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.as_inner().k()))
}
}
#[doc = "Weight contraction of [`Bivector`] with [`Imaginary`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Imaginary<T>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.j() * self.k(), -(rhs.i() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Imaginary<T>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.j() * self.as_inner().k(),
-(rhs.i() * self.as_inner().k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Imaginary<T>>> for Bivector<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().j() * self.k(),
-(rhs.as_inner().i() * self.k()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Imaginary<T>>> for Unit<Bivector<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().j() * self.as_inner().k(),
-(rhs.as_inner().i() * self.as_inner().k()),
)
}
}
#[doc = "Weight contraction of [`Bivector`] with [`Scalar`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Scalar<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.s() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Scalar<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.s() * self.as_inner().k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().s() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().s() * self.as_inner().k()))
}
}
#[doc = "Weight contraction of [`Imaginary`] with [`Imaginary`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Imaginary<T>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.i() * self.i() + rhs.j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Imaginary<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.i() * self.as_inner().i() + rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().i() * self.i() + rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Imaginary<T>>) -> Scalar<T> {
Scalar::new_unchecked(
rhs.as_inner().i() * self.as_inner().i() + rhs.as_inner().j() * self.as_inner().j(),
)
}
}
#[doc = "Weight contraction of [`Imaginary`] with [`Scalar`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Scalar<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.i(), rhs.s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Scalar<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.s() * self.as_inner().i(), rhs.s() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().s() * self.i(), rhs.as_inner().s() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().s() * self.as_inner().i(),
rhs.as_inner().s() * self.as_inner().j(),
)
}
}
#[doc = "Weight contraction of [`Scalar`] with [`Scalar`].\n\nThe weight contraction extracts the degenerate/ideal component of the\ninterior product. In PGA, this measures the 'weight' or projective part."]
impl<T: Float> WeightContract<Scalar<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.s() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Scalar<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Scalar<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.s() * self.as_inner().s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().s() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightContract<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_contract(&self, rhs: &Unit<Scalar<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().s() * self.as_inner().s()))
}
}
#[doc = "Bulk expansion of [`Bivector`] with [`Bivector`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().k() * self.as_inner().k())
}
}
#[doc = "Bulk expansion of [`Imaginary`] with [`Bivector`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.k() * self.i(), rhs.k() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.k() * self.as_inner().i(), rhs.k() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.as_inner().k() * self.i(), rhs.as_inner().k() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().k() * self.as_inner().i(),
rhs.as_inner().k() * self.as_inner().j(),
)
}
}
#[doc = "Bulk expansion of [`Imaginary`] with [`Imaginary`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Imaginary<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.i() * self.i()) + -(rhs.j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j()),
)
}
}
#[doc = "Bulk expansion of [`Scalar`] with [`Bivector`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Bivector<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Bivector<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_expand(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(rhs.k() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(rhs.as_inner().k() * self.as_inner().s())
}
}
#[doc = "Bulk expansion of [`Scalar`] with [`Imaginary`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(rhs.j() * self.s(), -(rhs.i() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.j() * self.as_inner().s(),
-(rhs.i() * self.as_inner().s()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().j() * self.s(),
-(rhs.as_inner().i() * self.s()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
rhs.as_inner().j() * self.as_inner().s(),
-(rhs.as_inner().i() * self.as_inner().s()),
)
}
}
#[doc = "Bulk expansion of [`Scalar`] with [`Scalar`].\n\nThe bulk expansion is the dual of bulk contraction, extracting the\nEuclidean component of the exterior product complement."]
impl<T: Float> BulkExpand<Scalar<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Scalar<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Scalar<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> BulkExpand<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn bulk_expand(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().s() * self.as_inner().s())
}
}
#[doc = "Weight expansion of [`Bivector`] with [`Bivector`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Bivector<T>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Bivector<T>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.k() * self.as_inner().k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Bivector<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().k() * self.k()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().k() * self.as_inner().k()))
}
}
#[doc = "Weight expansion of [`Imaginary`] with [`Bivector`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Bivector<T>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.k() * self.i()), -(rhs.k() * self.j()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Bivector<T>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.k() * self.as_inner().i()),
-(rhs.k() * self.as_inner().j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().k() * self.i()),
-(rhs.as_inner().k() * self.j()),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Unit<Imaginary<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().k() * self.as_inner().i()),
-(rhs.as_inner().k() * self.as_inner().j()),
)
}
}
#[doc = "Weight expansion of [`Imaginary`] with [`Imaginary`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Imaginary<T>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.i() * self.i() + rhs.j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Imaginary<T>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Imaginary<T>) -> Bivector<T> {
Bivector::new_unchecked(rhs.i() * self.as_inner().i() + rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Imaginary<T>>> for Imaginary<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(rhs.as_inner().i() * self.i() + rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Imaginary<T>>) -> Bivector<T> {
Bivector::new_unchecked(
rhs.as_inner().i() * self.as_inner().i() + rhs.as_inner().j() * self.as_inner().j(),
)
}
}
#[doc = "Weight expansion of [`Scalar`] with [`Bivector`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Bivector<T>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Bivector<T>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_expand(&self, rhs: &Bivector<T>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.k() * self.as_inner().s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Scalar<T> {
type Output = Scalar<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Bivector<T>>> for Unit<Scalar<T>> {
type Output = Scalar<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Bivector<T>>) -> Scalar<T> {
Scalar::new_unchecked(-(rhs.as_inner().k() * self.as_inner().s()))
}
}
#[doc = "Weight expansion of [`Scalar`] with [`Imaginary`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Imaginary<T>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(-(rhs.j() * self.s()), rhs.i() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Imaginary<T>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Imaginary<T>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.j() * self.as_inner().s()),
rhs.i() * self.as_inner().s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Imaginary<T>>> for Scalar<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.s()),
rhs.as_inner().i() * self.s(),
)
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Imaginary<T>>> for Unit<Scalar<T>> {
type Output = Imaginary<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Imaginary<T>>) -> Imaginary<T> {
Imaginary::new_unchecked(
-(rhs.as_inner().j() * self.as_inner().s()),
rhs.as_inner().i() * self.as_inner().s(),
)
}
}
#[doc = "Weight expansion of [`Scalar`] with [`Scalar`].\n\nThe weight expansion is the dual of weight contraction, extracting the\ndegenerate/ideal component of the exterior product complement."]
impl<T: Float> WeightExpand<Scalar<T>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.s() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Scalar<T>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Scalar<T>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.s() * self.as_inner().s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Scalar<T>>> for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().s() * self.s()))
}
}
#[allow(unused_variables)]
impl<T: Float> WeightExpand<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Output = Bivector<T>;
#[inline]
fn weight_expand(&self, rhs: &Unit<Scalar<T>>) -> Bivector<T> {
Bivector::new_unchecked(-(rhs.as_inner().s() * self.as_inner().s()))
}
}
impl<T: Float> Dot<Bivector<T>> for Bivector<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Bivector<T>) -> T {
-(self.k() * rhs.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Bivector<T>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Bivector<T>) -> T {
-(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Bivector<T>>> for Bivector<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.as_inner().k())
}
}
impl<T: Float> Dot<Quaternion<T>> for Bivector<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
-(self.k() * rhs.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Quaternion<T>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Bivector<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().k() * self.as_inner().k())
}
}
impl<T: Float> Dot<Imaginary<T>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Imaginary<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Imaginary<T>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Imaginary<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Imaginary<T>>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Dot<Quaternion<T>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Quaternion<T>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Dot<Bivector<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Bivector<T>) -> T {
-(self.k() * rhs.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Bivector<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Bivector<T>) -> T {
-(rhs.k() * self.as_inner().k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Bivector<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.k())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Bivector<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Bivector<T>>) -> T {
-(rhs.as_inner().k() * self.as_inner().k())
}
}
impl<T: Float> Dot<Imaginary<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Imaginary<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Imaginary<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Imaginary<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Imaginary<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Imaginary<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Dot<Quaternion<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
self.w() * rhs.w() - self.i() * rhs.i() - self.j() * rhs.j() - self.k() * rhs.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Quaternion<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.i() * self.as_inner().i())
+ -(rhs.j() * self.as_inner().j())
+ -(rhs.k() * self.as_inner().k())
+ rhs.w() * self.as_inner().w()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.i())
+ -(rhs.as_inner().j() * self.j())
+ -(rhs.as_inner().k() * self.k())
+ rhs.as_inner().w() * self.w()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j())
+ -(rhs.as_inner().k() * self.as_inner().k())
+ rhs.as_inner().w() * self.as_inner().w()
}
}
impl<T: Float> Dot<Scalar<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Scalar<T>) -> T {
self.w() * rhs.s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Scalar<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Scalar<T>) -> T {
rhs.s() * self.as_inner().w()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Scalar<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.w()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Scalar<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.as_inner().w()
}
}
impl<T: Float> Dot<Quaternion<T>> for Scalar<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
self.s() * rhs.w()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Quaternion<T>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Quaternion<T>) -> T {
rhs.w() * self.as_inner().s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Scalar<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
rhs.as_inner().w() * self.s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Quaternion<T>>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Quaternion<T>>) -> T {
rhs.as_inner().w() * self.as_inner().s()
}
}
impl<T: Float> Dot<Scalar<T>> for Scalar<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Scalar<T>) -> T {
self.s() * rhs.s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Scalar<T>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Scalar<T>) -> T {
rhs.s() * self.as_inner().s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Scalar<T>>> for Scalar<T> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.s()
}
}
#[allow(unused_variables)]
impl<T: Float> Dot<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn dot(&self, rhs: &Unit<Scalar<T>>) -> T {
rhs.as_inner().s() * self.as_inner().s()
}
}
impl<T: Float> Antidot<Bivector<T>> for Bivector<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Bivector<T>) -> T {
self.k() * rhs.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Bivector<T>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Bivector<T>) -> T {
rhs.k() * self.as_inner().k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Bivector<T>>> for Bivector<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Bivector<T>>) -> T {
rhs.as_inner().k() * self.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Bivector<T>>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Bivector<T>>) -> T {
rhs.as_inner().k() * self.as_inner().k()
}
}
impl<T: Float> Antidot<Quaternion<T>> for Bivector<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
self.k() * rhs.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Quaternion<T>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
rhs.k() * self.as_inner().k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Bivector<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
rhs.as_inner().k() * self.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Unit<Bivector<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
rhs.as_inner().k() * self.as_inner().k()
}
}
impl<T: Float> Antidot<Imaginary<T>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Imaginary<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Imaginary<T>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Imaginary<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Imaginary<T>>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Imaginary<T>>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Antidot<Quaternion<T>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Quaternion<T>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Imaginary<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Unit<Imaginary<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Antidot<Bivector<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Bivector<T>) -> T {
self.k() * rhs.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Bivector<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Bivector<T>) -> T {
rhs.k() * self.as_inner().k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Bivector<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Bivector<T>>) -> T {
rhs.as_inner().k() * self.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Bivector<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Bivector<T>>) -> T {
rhs.as_inner().k() * self.as_inner().k()
}
}
impl<T: Float> Antidot<Imaginary<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Imaginary<T>) -> T {
-(self.i() * rhs.i()) - self.j() * rhs.j()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Imaginary<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Imaginary<T>) -> T {
-(rhs.i() * self.as_inner().i()) + -(rhs.j() * self.as_inner().j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Imaginary<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.i()) + -(rhs.as_inner().j() * self.j())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Imaginary<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Imaginary<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i()) + -(rhs.as_inner().j() * self.as_inner().j())
}
}
impl<T: Float> Antidot<Quaternion<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(self.w() * rhs.w()) - self.i() * rhs.i() - self.j() * rhs.j() + self.k() * rhs.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Quaternion<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.i() * self.as_inner().i())
+ -(rhs.j() * self.as_inner().j())
+ -(rhs.w() * self.as_inner().w())
+ rhs.k() * self.as_inner().k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.i())
+ -(rhs.as_inner().j() * self.j())
+ -(rhs.as_inner().w() * self.w())
+ rhs.as_inner().k() * self.k()
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().i() * self.as_inner().i())
+ -(rhs.as_inner().j() * self.as_inner().j())
+ -(rhs.as_inner().w() * self.as_inner().w())
+ rhs.as_inner().k() * self.as_inner().k()
}
}
impl<T: Float> Antidot<Scalar<T>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Scalar<T>) -> T {
-(self.w() * rhs.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Scalar<T>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Scalar<T>) -> T {
-(rhs.s() * self.as_inner().w())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Scalar<T>>> for Quaternion<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Scalar<T>>) -> T {
-(rhs.as_inner().s() * self.w())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Scalar<T>>> for Unit<Quaternion<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Scalar<T>>) -> T {
-(rhs.as_inner().s() * self.as_inner().w())
}
}
impl<T: Float> Antidot<Quaternion<T>> for Scalar<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(self.s() * rhs.w())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Quaternion<T>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Quaternion<T>) -> T {
-(rhs.w() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Scalar<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().w() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Quaternion<T>>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Quaternion<T>>) -> T {
-(rhs.as_inner().w() * self.as_inner().s())
}
}
impl<T: Float> Antidot<Scalar<T>> for Scalar<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Scalar<T>) -> T {
-(self.s() * rhs.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Scalar<T>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Scalar<T>) -> T {
-(rhs.s() * self.as_inner().s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Scalar<T>>> for Scalar<T> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Scalar<T>>) -> T {
-(rhs.as_inner().s() * self.s())
}
}
#[allow(unused_variables)]
impl<T: Float> Antidot<Unit<Scalar<T>>> for Unit<Scalar<T>> {
type Scalar = T;
#[inline]
fn antidot(&self, rhs: &Unit<Scalar<T>>) -> T {
-(rhs.as_inner().s() * self.as_inner().s())
}
}
impl<T: Float> Reverse for Bivector<T> {
#[inline]
fn reverse(&self) -> Self {
Self::new_unchecked(-self.k())
}
}
impl<T: Float> Reverse for Imaginary<T> {
#[inline]
fn reverse(&self) -> Self {
Self::new_unchecked(self.i(), self.j())
}
}
impl<T: Float> Reverse for Quaternion<T> {
#[inline]
fn reverse(&self) -> Self {
Self::new_unchecked(self.w(), self.i(), self.j(), -self.k())
}
}
impl<T: Float> Reverse for Scalar<T> {
#[inline]
fn reverse(&self) -> Self {
Self::new_unchecked(self.s())
}
}
impl<T: Float> Antireverse for Bivector<T> {
#[inline]
fn antireverse(&self) -> Self {
Self::new_unchecked(self.k())
}
}
impl<T: Float> Antireverse for Imaginary<T> {
#[inline]
fn antireverse(&self) -> Self {
Self::new_unchecked(self.i(), self.j())
}
}
impl<T: Float> Antireverse for Quaternion<T> {
#[inline]
fn antireverse(&self) -> Self {
Self::new_unchecked(-self.w(), self.i(), self.j(), self.k())
}
}
impl<T: Float> Antireverse for Scalar<T> {
#[inline]
fn antireverse(&self) -> Self {
Self::new_unchecked(-self.s())
}
}
impl<T: Float> Involute for Bivector<T> {
#[inline]
fn involute(&self) -> Self {
Self::new_unchecked(-self.k())
}
}
impl<T: Float> Involute for Imaginary<T> {
#[inline]
fn involute(&self) -> Self {
Self::new_unchecked(-self.i(), -self.j())
}
}
impl<T: Float> Involute for Quaternion<T> {
#[inline]
fn involute(&self) -> Self {
Self::new_unchecked(self.w(), -self.i(), -self.j(), -self.k())
}
}
impl<T: Float> Involute for Scalar<T> {
#[inline]
fn involute(&self) -> Self {
Self::new_unchecked(self.s())
}
}
impl<T: Float> RightComplement for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn right_complement(&self) -> Scalar<T> {
Scalar::new_unchecked(self.k())
}
}
impl<T: Float> RightComplement for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn right_complement(&self) -> Imaginary<T> {
Imaginary::new_unchecked(-self.j(), self.i())
}
}
impl<T: Float> RightComplement for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn right_complement(&self) -> Quaternion<T> {
Quaternion::new_unchecked(self.k(), -self.j(), self.i(), self.w())
}
}
impl<T: Float> RightComplement for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn right_complement(&self) -> Bivector<T> {
Bivector::new_unchecked(self.s())
}
}
impl<T: Float> WeightDual for Bivector<T> {
type Output = Scalar<T>;
#[inline]
fn weight_dual(&self) -> Scalar<T> {
Scalar::new_unchecked(-self.k())
}
}
impl<T: Float> WeightDual for Imaginary<T> {
type Output = Imaginary<T>;
#[inline]
fn weight_dual(&self) -> Imaginary<T> {
Imaginary::new_unchecked(-self.j(), self.i())
}
}
impl<T: Float> WeightDual for Quaternion<T> {
type Output = Quaternion<T>;
#[inline]
fn weight_dual(&self) -> Quaternion<T> {
Quaternion::new_unchecked(-self.k(), -self.j(), self.i(), -self.w())
}
}
impl<T: Float> WeightDual for Scalar<T> {
type Output = Bivector<T>;
#[inline]
fn weight_dual(&self) -> Bivector<T> {
Bivector::new_unchecked(-self.s())
}
}
impl<T: Float> VersorInverse for Bivector<T> {
fn try_inverse(&self) -> Option<Self> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Self::new_unchecked(-self.k() * inv_norm_sq))
}
}
impl<T: Float> VersorInverse for Imaginary<T> {
fn try_inverse(&self) -> Option<Self> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Self::new_unchecked(
self.i() * inv_norm_sq,
self.j() * inv_norm_sq,
))
}
}
impl<T: Float> VersorInverse for Scalar<T> {
fn try_inverse(&self) -> Option<Self> {
let norm_sq = <Self as crate::norm::Normed>::norm_squared(self);
if norm_sq.abs() < T::epsilon() {
return None;
}
let inv_norm_sq = T::one() / norm_sq;
Some(Self::new_unchecked(self.s() * inv_norm_sq))
}
}
impl<T: Float> crate::norm::Normed for Bivector<T> {
type Scalar = T;
#[inline]
fn norm_squared(&self) -> T {
self.k() * self.k()
}
fn try_normalize(&self) -> Option<Self> {
let n = self.norm();
if n < T::epsilon() {
None
} else {
Some(self.scale(T::one() / n))
}
}
#[inline]
fn scale(&self, factor: T) -> Self {
Self::new_unchecked(self.k() * factor)
}
}
impl<T: Float> crate::norm::Normed for Imaginary<T> {
type Scalar = T;
#[inline]
fn norm_squared(&self) -> T {
self.i() * self.i() + self.j() * self.j()
}
fn try_normalize(&self) -> Option<Self> {
let n = self.norm();
if n < T::epsilon() {
None
} else {
Some(self.scale(T::one() / n))
}
}
#[inline]
fn scale(&self, factor: T) -> Self {
Self::new_unchecked(self.i() * factor, self.j() * factor)
}
}
impl<T: Float> crate::norm::Normed for Quaternion<T> {
type Scalar = T;
#[inline]
fn norm_squared(&self) -> T {
self.w() * self.w() + self.i() * self.i() + self.j() * self.j() + self.k() * self.k()
}
fn try_normalize(&self) -> Option<Self> {
let n = self.norm();
if n < T::epsilon() {
None
} else {
Some(self.scale(T::one() / n))
}
}
#[inline]
fn scale(&self, factor: T) -> Self {
Self::new_unchecked(
self.w() * factor,
self.i() * factor,
self.j() * factor,
self.k() * factor,
)
}
}
impl<T: Float> crate::norm::Normed for Scalar<T> {
type Scalar = T;
#[inline]
fn norm_squared(&self) -> T {
self.s() * self.s()
}
fn try_normalize(&self) -> Option<Self> {
let n = self.norm();
if n < T::epsilon() {
None
} else {
Some(self.scale(T::one() / n))
}
}
#[inline]
fn scale(&self, factor: T) -> Self {
Self::new_unchecked(self.s() * factor)
}
}
impl<T: Float + AbsDiffEq<Epsilon = T>> AbsDiffEq for Bivector<T> {
type Epsilon = T;
fn default_epsilon() -> Self::Epsilon {
T::default_epsilon()
}
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.k().abs_diff_eq(&other.k(), epsilon)
}
}
impl<T: Float + RelativeEq<Epsilon = T>> RelativeEq for Bivector<T> {
fn default_max_relative() -> Self::Epsilon {
T::default_max_relative()
}
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool {
self.k().relative_eq(&other.k(), epsilon, max_relative)
}
}
impl<T: Float + UlpsEq<Epsilon = T>> UlpsEq for Bivector<T> {
fn default_max_ulps() -> u32 {
T::default_max_ulps()
}
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
self.k().ulps_eq(&other.k(), epsilon, max_ulps)
}
}
impl<T: Float + AbsDiffEq<Epsilon = T>> AbsDiffEq for Imaginary<T> {
type Epsilon = T;
fn default_epsilon() -> Self::Epsilon {
T::default_epsilon()
}
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.i().abs_diff_eq(&other.i(), epsilon) && self.j().abs_diff_eq(&other.j(), epsilon)
}
}
impl<T: Float + RelativeEq<Epsilon = T>> RelativeEq for Imaginary<T> {
fn default_max_relative() -> Self::Epsilon {
T::default_max_relative()
}
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool {
self.i().relative_eq(&other.i(), epsilon, max_relative)
&& self.j().relative_eq(&other.j(), epsilon, max_relative)
}
}
impl<T: Float + UlpsEq<Epsilon = T>> UlpsEq for Imaginary<T> {
fn default_max_ulps() -> u32 {
T::default_max_ulps()
}
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
self.i().ulps_eq(&other.i(), epsilon, max_ulps)
&& self.j().ulps_eq(&other.j(), epsilon, max_ulps)
}
}
impl<T: Float + AbsDiffEq<Epsilon = T>> AbsDiffEq for Quaternion<T> {
type Epsilon = T;
fn default_epsilon() -> Self::Epsilon {
T::default_epsilon()
}
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.w().abs_diff_eq(&other.w(), epsilon)
&& self.i().abs_diff_eq(&other.i(), epsilon)
&& self.j().abs_diff_eq(&other.j(), epsilon)
&& self.k().abs_diff_eq(&other.k(), epsilon)
}
}
impl<T: Float + RelativeEq<Epsilon = T>> RelativeEq for Quaternion<T> {
fn default_max_relative() -> Self::Epsilon {
T::default_max_relative()
}
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool {
self.w().relative_eq(&other.w(), epsilon, max_relative)
&& self.i().relative_eq(&other.i(), epsilon, max_relative)
&& self.j().relative_eq(&other.j(), epsilon, max_relative)
&& self.k().relative_eq(&other.k(), epsilon, max_relative)
}
}
impl<T: Float + UlpsEq<Epsilon = T>> UlpsEq for Quaternion<T> {
fn default_max_ulps() -> u32 {
T::default_max_ulps()
}
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
self.w().ulps_eq(&other.w(), epsilon, max_ulps)
&& self.i().ulps_eq(&other.i(), epsilon, max_ulps)
&& self.j().ulps_eq(&other.j(), epsilon, max_ulps)
&& self.k().ulps_eq(&other.k(), epsilon, max_ulps)
}
}
impl<T: Float + AbsDiffEq<Epsilon = T>> AbsDiffEq for Scalar<T> {
type Epsilon = T;
fn default_epsilon() -> Self::Epsilon {
T::default_epsilon()
}
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool {
self.s().abs_diff_eq(&other.s(), epsilon)
}
}
impl<T: Float + RelativeEq<Epsilon = T>> RelativeEq for Scalar<T> {
fn default_max_relative() -> Self::Epsilon {
T::default_max_relative()
}
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool {
self.s().relative_eq(&other.s(), epsilon, max_relative)
}
}
impl<T: Float + UlpsEq<Epsilon = T>> UlpsEq for Scalar<T> {
fn default_max_ulps() -> u32 {
T::default_max_ulps()
}
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool {
self.s().ulps_eq(&other.s(), epsilon, max_ulps)
}
}
#[cfg(any(test, feature = "proptest-support"))]
#[allow(clippy::missing_docs_in_private_items)]
mod arbitrary_impls {
use super::*;
use proptest::prelude::*;
use proptest::strategy::BoxedStrategy;
use std::fmt::Debug;
impl<T: Float + Debug + 'static> Arbitrary for Bivector<T> {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
(-100.0f64..100.0)
.prop_map(|x0| Bivector::new_unchecked(T::from_f64(x0)))
.boxed()
}
}
impl<T: Float + Debug + 'static> Arbitrary for Imaginary<T> {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
(-100.0f64..100.0, -100.0f64..100.0)
.prop_map(|(x0, x1)| Imaginary::new_unchecked(T::from_f64(x0), T::from_f64(x1)))
.boxed()
}
}
impl<T: Float + Debug + 'static> Arbitrary for Quaternion<T> {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
(
-100.0f64..100.0,
-100.0f64..100.0,
-100.0f64..100.0,
-100.0f64..100.0,
)
.prop_map(|(x0, x1, x2, x3)| {
Quaternion::new_unchecked(
T::from_f64(x0),
T::from_f64(x1),
T::from_f64(x2),
T::from_f64(x3),
)
})
.boxed()
}
}
impl<T: Float + Debug + 'static> Arbitrary for Scalar<T> {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
(-100.0f64..100.0)
.prop_map(|x0| Scalar::new_unchecked(T::from_f64(x0)))
.boxed()
}
}
}
#[cfg(test)]
#[allow(clippy::missing_docs_in_private_items)]
mod verification_tests {
use super::*;
use crate::algebra::Multivector;
#[allow(unused_imports)]
use crate::norm::{DegenerateNormed, Normed};
use crate::signature::Cl0_2_0;
#[allow(unused_imports)]
use crate::wrappers::Unit;
use approx::relative_eq;
use proptest::prelude::*;
const REL_EPSILON: f64 = 1e-10;
proptest! {
#[test]
fn bivector_add_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a + b;
let generic_result = mv_a + mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Add mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn bivector_sub_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a - b;
let generic_result = mv_a - mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Sub mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn bivector_neg_matches_multivector(a in any::<Bivector<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let specialized_result = -a;
let generic_result = -mv_a;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Neg mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn imaginary_add_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a + b;
let generic_result = mv_a + mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Add mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn imaginary_sub_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a - b;
let generic_result = mv_a - mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Sub mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn imaginary_neg_matches_multivector(a in any::<Imaginary<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let specialized_result = -a;
let generic_result = -mv_a;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Neg mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn quaternion_add_matches_multivector(a in any::<Quaternion<f64>>(), b in any::<Quaternion<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a + b;
let generic_result = mv_a + mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Add mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn quaternion_sub_matches_multivector(a in any::<Quaternion<f64>>(), b in any::<Quaternion<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a - b;
let generic_result = mv_a - mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Sub mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn quaternion_neg_matches_multivector(a in any::<Quaternion<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let specialized_result = -a;
let generic_result = -mv_a;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Neg mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn scalar_add_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a + b;
let generic_result = mv_a + mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Add mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn scalar_sub_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result = a - b;
let generic_result = mv_a - mv_b;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Sub mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
#[test]
fn scalar_neg_matches_multivector(a in any::<Scalar<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let specialized_result = -a;
let generic_result = -mv_a;
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Neg mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_bivector_scalar_bivector_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_imaginary_imaginary_bivector_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_imaginary_scalar_imaginary_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_scalar_bivector_bivector_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_scalar_imaginary_imaginary_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn wedge_scalar_scalar_scalar_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::Wedge;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.wedge(&b);
let generic_result = mv_a.exterior(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Wedge product mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_bivector_bivector_scalar_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_bivector_imaginary_imaginary_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_bivector_scalar_bivector_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_imaginary_imaginary_scalar_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_imaginary_scalar_imaginary_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_contraction_scalar_scalar_scalar_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::BulkContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.bulk_contract(&b);
let generic_result = mv_a.bulk_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_bivector_bivector_scalar_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_bivector_imaginary_imaginary_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_bivector_scalar_bivector_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_imaginary_imaginary_scalar_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_imaginary_scalar_imaginary_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_contraction_scalar_scalar_scalar_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::WeightContract;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.weight_contract(&b);
let generic_result = mv_a.weight_contraction(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight contraction mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_bivector_bivector_bivector_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_imaginary_bivector_imaginary_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_imaginary_imaginary_bivector_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_scalar_bivector_scalar_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_scalar_imaginary_imaginary_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn bulk_expansion_scalar_scalar_bivector_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::BulkExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.bulk_expand(&b);
let generic_result = mv_a.bulk_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Bulk expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_bivector_bivector_bivector_matches_multivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_imaginary_bivector_imaginary_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_imaginary_imaginary_bivector_matches_multivector(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_scalar_bivector_scalar_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Bivector<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Scalar<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_scalar_imaginary_imaginary_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Imaginary<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Imaginary<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn weight_expansion_scalar_scalar_bivector_matches_multivector(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
use crate::ops::WeightExpand;
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let specialized_result: Bivector<f64> = a.weight_expand(&b);
let generic_result = mv_a.weight_expansion(&mv_b);
let specialized_mv: Multivector<f64, Cl0_2_0> = specialized_result.into();
prop_assert!(
relative_eq!(specialized_mv, generic_result, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Weight expansion mismatch: specialized={:?}, generic={:?}",
specialized_mv, generic_result
);
}
}
proptest! {
#[test]
fn de_morgan_geometric_bivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = (mv_a * mv_b).complement();
let rhs = mv_a.complement().antiproduct(&mv_b.complement());
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (geometric) failed: complement(a*b)={:?}, complement(a)⋇complement(b)={:?}",
lhs, rhs
);
}
#[test]
fn de_morgan_antiproduct_bivector(a in any::<Bivector<f64>>(), b in any::<Bivector<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = mv_a.antiproduct(&mv_b).complement();
let rhs = mv_a.complement() * mv_b.complement();
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (antiproduct) failed: complement(a⋇b)={:?}, complement(a)*complement(b)={:?}",
lhs, rhs
);
}
}
proptest! {
#[test]
fn de_morgan_geometric_imaginary(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = (mv_a * mv_b).complement();
let rhs = mv_a.complement().antiproduct(&mv_b.complement());
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (geometric) failed: complement(a*b)={:?}, complement(a)⋇complement(b)={:?}",
lhs, rhs
);
}
#[test]
fn de_morgan_antiproduct_imaginary(a in any::<Imaginary<f64>>(), b in any::<Imaginary<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = mv_a.antiproduct(&mv_b).complement();
let rhs = mv_a.complement() * mv_b.complement();
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (antiproduct) failed: complement(a⋇b)={:?}, complement(a)*complement(b)={:?}",
lhs, rhs
);
}
}
proptest! {
#[test]
fn de_morgan_geometric_scalar(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = (mv_a * mv_b).complement();
let rhs = mv_a.complement().antiproduct(&mv_b.complement());
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (geometric) failed: complement(a*b)={:?}, complement(a)⋇complement(b)={:?}",
lhs, rhs
);
}
#[test]
fn de_morgan_antiproduct_scalar(a in any::<Scalar<f64>>(), b in any::<Scalar<f64>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = b.into();
let lhs = mv_a.antiproduct(&mv_b).complement();
let rhs = mv_a.complement() * mv_b.complement();
prop_assert!(
relative_eq!(lhs, rhs, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"De Morgan (antiproduct) failed: complement(a⋇b)={:?}, complement(a)*complement(b)={:?}",
lhs, rhs
);
}
}
proptest! {
#[test]
fn project_idempotent_bivector_imaginary(a in any::<Bivector<f64>>(), unit_b in any::<Unit<Imaginary<f64>>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = unit_b.into_inner().into();
let first = mv_a.project(&mv_b);
let second = first.project(&mv_b);
prop_assert!(
relative_eq!(first, second, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Project idempotency failed: first={:?}, second={:?}",
first, second
);
}
}
proptest! {
#[test]
fn antiproject_idempotent_imaginary_bivector(a in any::<Imaginary<f64>>(), unit_b in any::<Unit<Bivector<f64>>>()) {
let mv_a: Multivector<f64, Cl0_2_0> = a.into();
let mv_b: Multivector<f64, Cl0_2_0> = unit_b.into_inner().into();
let first = mv_a.antiproject(&mv_b);
let second = first.antiproject(&mv_b);
prop_assert!(
relative_eq!(first, second, epsilon = REL_EPSILON, max_relative = REL_EPSILON),
"Antiproject idempotency failed: first={:?}, second={:?}",
first, second
);
}
}
}