Skip to main content

Rotate

Trait Rotate 

Source
pub trait Rotate<V: Vector> {
    type Matrix: Rotate<V>;

    // Required method
    fn rotate(&self, vector: &V) -> V;
}
Expand description

Applies the rotation operation to vectors.

The Rotate trait describes a type that can rotate a given vector. The rotated vector has the same magnitude, but possibly a different direction.

Types that implement Rotate may or may not implement Rotation.

Required Associated Types§

Source

type Matrix: Rotate<V>

Type of the related rotation matrix

Required Methods§

Source

fn rotate(&self, vector: &V) -> V

Rotate a vector.

\vec{b} = R(\vec{a})
§Example
use approxim::assert_relative_eq;
use hoomd_vector::{Angle, Cartesian, Rotate, Rotation};

let v = Cartesian::from([-1.0, 0.0]);
let a = Angle::from(std::f64::consts::PI / 2.0);
let rotated = a.rotate(&v);
assert_relative_eq!(rotated, [0.0, -1.0].into());

Implementors§