Skip to main content

Rotation

Struct Rotation 

Source
pub struct Rotation { /* private fields */ }
Expand description

Représente une rotation dans l’espace 3D (Groupe SO(3)).

Stocke un quaternion unitaire q = [w, x, y, z] où :

  • w = cos(θ/2)
  • (x, y, z) = sin(θ/2) · û avec û l’axe de rotation unitaire

L’invariant w² + x² + y² + z² = 1 est garanti à la construction et maintenu après chaque composition via re-normalisation automatique.

Implementations§

Source§

impl Rotation

Source

pub const IDENTITY: Self

Identité : aucune rotation (quaternion [1, 0, 0, 0]).

Source

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

Crée une rotation à partir d’un quaternion brut [w, x, y, z].

Les composants sont normalisés automatiquement.

§Erreurs
§Exemple
use embedded_so3_f32::Rotation;
// 90° autour de Z  (w = cos 45°, z = sin 45°)
let s = core::f32::consts::FRAC_1_SQRT_2;
let rot = Rotation::new(s, 0.0, 0.0, s).unwrap();
Source

pub fn compose(&self, other: &Rotation) -> Result<Self, So3Error>

Compose deux rotations : R_new = self ∘ other.

Équivalent à self * other via l’implémentation de Mul.

Applique une re-normalisation automatique pour contenir la dérive numérique inhérente à l’arithmétique f32 sur SO(3).

§Erreurs

Retourne So3Error::InvalidNorm ou So3Error::NonFiniteValue si le résultat est dégénéré (cas extrêmement rare avec des entrées valides).

Source

pub fn rotate_vector(&self, v: [f32; 3]) -> [f32; 3]

Applique la rotation à un vecteur [x, y, z].

Utilise la formule optimisée de Rodrigues pour quaternions : v' = v + 2w·(q⃗ × v) + 2·(q⃗ × (q⃗ × v))

Cette forme évite le produit p·q·p⁻¹ naïf (28 multiplications) et ne nécessite que 15 multiplications.

Source

pub fn inverse(&self) -> Self

Retourne la rotation inverse.

Pour un quaternion unitaire, l’inverse est le conjugué : q⁻¹ = [w, -x, -y, -z].

Aucune normalisation n’est nécessaire car le conjugué d’un quaternion unitaire est déjà unitaire.

Source

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

Retourne les composants bruts sous la forme [w, x, y, z].

Trait Implementations§

Source§

impl Clone for Rotation

Source§

fn clone(&self) -> Rotation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rotation

Source§

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

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

impl Mul for &Rotation

Opérateur * par référence pour éviter la copie inutile.

Source§

type Output = Result<Rotation, So3Error>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Rotation

Opérateur * pour composer deux rotations.

Équivalent à Rotation::compose.

§Exemple

use embedded_so3_f32::Rotation;
let s = core::f32::consts::FRAC_1_SQRT_2;
let r = Rotation::new(s, s, 0.0, 0.0).unwrap(); // 90° autour de X
let r180 = (r * r).unwrap();                      // 180° autour de X
Source§

type Output = Result<Rotation, So3Error>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl PartialEq for Rotation

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

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

impl Copy for Rotation

Source§

impl StructuralPartialEq for Rotation

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.