Type Alias nalgebra::geometry::Rotation2

source ·
pub type Rotation2<T> = Rotation<T, 2>;
Expand description

A 2-dimensional rotation matrix.

Because this is an alias, not all its methods are listed here. See the Rotation type too.

Aliased Type§

struct Rotation2<T> { /* private fields */ }

Implementations§

source§

impl<T: SimdRealField> Rotation2<T>

§Interpolation

source

pub fn slerp(&self, other: &Self, t: T) -> Self

Spherical linear interpolation between two rotation matrices.

§Examples:

let rot1 = Rotation2::new(std::f32::consts::FRAC_PI_4);
let rot2 = Rotation2::new(-std::f32::consts::PI);

let rot = rot1.slerp(&rot2, 1.0 / 3.0);

assert_relative_eq!(rot.angle(), std::f32::consts::FRAC_PI_2);
source§

impl<T: SimdRealField> Rotation2<T>

§Construction from a 2D rotation angle

source

pub fn new(angle: T) -> Self

Builds a 2 dimensional rotation matrix from an angle in radian.

§Example
let rot = Rotation2::new(f32::consts::FRAC_PI_2);

assert_relative_eq!(rot * Point2::new(3.0, 4.0), Point2::new(-4.0, 3.0));
source

pub fn from_scaled_axis<SB: Storage<T, U1>>( axisangle: Vector<T, U1, SB> ) -> Self

Builds a 2 dimensional rotation matrix from an angle in radian wrapped in a 1-dimensional vector.

This is generally used in the context of generic programming. Using the ::new(angle) method instead is more common.

source§

impl<T: SimdRealField> Rotation2<T>

§Construction from an existing 2D matrix or rotations

source

pub fn from_basis_unchecked(basis: &[Vector2<T>; 2]) -> Self

Builds a rotation from a basis assumed to be orthonormal.

In order to get a valid rotation matrix, the input must be an orthonormal basis, i.e., all vectors are normalized, and the are all orthogonal to each other. These invariants are not checked by this method.

source

pub fn from_matrix(m: &Matrix2<T>) -> Self
where T: RealField,

Builds a rotation matrix by extracting the rotation part of the given transformation m.

This is an iterative method. See .from_matrix_eps to provide mover convergence parameters and starting solution. This implements “A Robust Method to Extract the Rotational Part of Deformations” by Müller et al.

source

pub fn from_matrix_eps( m: &Matrix2<T>, eps: T, max_iter: usize, guess: Self ) -> Self
where T: RealField,

Builds a rotation matrix by extracting the rotation part of the given transformation m.

This implements “A Robust Method to Extract the Rotational Part of Deformations” by Müller et al.

§Parameters
  • m: the matrix from which the rotational part is to be extracted.
  • eps: the angular errors tolerated between the current rotation and the optimal one.
  • max_iter: the maximum number of iterations. Loops indefinitely until convergence if set to 0.
  • guess: an estimate of the solution. Convergence will be significantly faster if an initial solution close to the actual solution is provided. Can be set to Rotation2::identity() if no other guesses come to mind.
source

pub fn rotation_between<SB, SC>( a: &Vector<T, U2, SB>, b: &Vector<T, U2, SC> ) -> Self
where T: RealField, SB: Storage<T, U2>, SC: Storage<T, U2>,

The rotation matrix required to align a and b but with its angle.

This is the rotation R such that (R * a).angle(b) == 0 && (R * a).dot(b).is_positive().

§Example
let a = Vector2::new(1.0, 2.0);
let b = Vector2::new(2.0, 1.0);
let rot = Rotation2::rotation_between(&a, &b);
assert_relative_eq!(rot * a, b);
assert_relative_eq!(rot.inverse() * b, a);
source

pub fn scaled_rotation_between<SB, SC>( a: &Vector<T, U2, SB>, b: &Vector<T, U2, SC>, s: T ) -> Self
where T: RealField, SB: Storage<T, U2>, SC: Storage<T, U2>,

The smallest rotation needed to make a and b collinear and point toward the same direction, raised to the power s.

§Example
let a = Vector2::new(1.0, 2.0);
let b = Vector2::new(2.0, 1.0);
let rot2 = Rotation2::scaled_rotation_between(&a, &b, 0.2);
let rot5 = Rotation2::scaled_rotation_between(&a, &b, 0.5);
assert_relative_eq!(rot2 * rot2 * rot2 * rot2 * rot2 * a, b, epsilon = 1.0e-6);
assert_relative_eq!(rot5 * rot5 * a, b, epsilon = 1.0e-6);
source

pub fn rotation_to(&self, other: &Self) -> Self

The rotation matrix needed to make self and other coincide.

The result is such that: self.rotation_to(other) * self == other.

§Example
let rot1 = Rotation2::new(0.1);
let rot2 = Rotation2::new(1.7);
let rot_to = rot1.rotation_to(&rot2);

assert_relative_eq!(rot_to * rot1, rot2);
assert_relative_eq!(rot_to.inverse() * rot2, rot1);
source

pub fn renormalize(&mut self)
where T: RealField,

Ensure this rotation is an orthonormal rotation matrix. This is useful when repeated computations might cause the matrix from progressively not being orthonormal anymore.

source

pub fn powf(&self, n: T) -> Self

Raise the rotation to a given floating power, i.e., returns the rotation with the angle of self multiplied by n.

§Example
let rot = Rotation2::new(0.78);
let pow = rot.powf(2.0);
assert_relative_eq!(pow.angle(), 2.0 * 0.78);
source§

impl<T: SimdRealField> Rotation2<T>

§2D angle extraction

source

pub fn angle(&self) -> T

The rotation angle.

§Example
let rot = Rotation2::new(1.78);
assert_relative_eq!(rot.angle(), 1.78);
source

pub fn angle_to(&self, other: &Self) -> T

The rotation angle needed to make self and other coincide.

§Example
let rot1 = Rotation2::new(0.1);
let rot2 = Rotation2::new(1.7);
assert_relative_eq!(rot1.angle_to(&rot2), 1.6);
source

pub fn scaled_axis(&self) -> SVector<T, 1>

The rotation angle returned as a 1-dimensional vector.

This is generally used in the context of generic programming. Using the .angle() method instead is more common.

Trait Implementations§

source§

impl<T: SimdRealField + Arbitrary> Arbitrary for Rotation2<T>
where T::Element: SimdRealField, Owned<T, U2, U2>: Send,

source§

fn arbitrary(g: &mut Gen) -> Self

Return an arbitrary value. Read more
source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<DMat2> for Rotation2<f64>

source§

fn from(e: DMat2) -> Rotation2<f64>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl From<Mat2> for Rotation2<f32>

source§

fn from(e: Mat2) -> Rotation2<f32>

Converts to this type from the input type.
source§

impl<T: SimdRealField> From<Unit<Complex<T>>> for Rotation2<T>

source§

fn from(q: UnitComplex<T>) -> Self

Converts to this type from the input type.
source§

impl<T1, T2> SubsetOf<Unit<Complex<T2>>> for Rotation2<T1>
where T1: RealField, T2: RealField + SupersetOf<T1>,

source§

fn to_superset(&self) -> UnitComplex<T2>

The inclusion map: converts self to the equivalent element of its superset.
source§

fn is_in_subset(q: &UnitComplex<T2>) -> bool

Checks if element is actually part of the subset Self (and can be converted to it).
source§

fn from_superset_unchecked(q: &UnitComplex<T2>) -> Self

Use with care! Same as self.to_superset but without any property checks. Always succeeds.
source§

fn from_superset(element: &T) -> Option<Self>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more