Type Definition nalgebra::geometry::UnitComplex

source ·
pub type UnitComplex<N> = Unit<Complex<N>>;
Expand description

A complex number with a norm equal to 1.

Implementations§

The rotation angle in ]-pi; pi] of this unit complex number.

Example
let rot = UnitComplex::new(1.78);
assert_eq!(rot.angle(), 1.78);

The sine of the rotation angle.

Example
let angle = 1.78f32;
let rot = UnitComplex::new(angle);
assert_eq!(rot.sin_angle(), angle.sin());

The cosine of the rotation angle.

Example
let angle = 1.78f32;
let rot = UnitComplex::new(angle);
assert_eq!(rot.cos_angle(),angle.cos());

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.

The rotation axis and angle in ]0, pi] of this complex number.

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

The underlying complex number.

Same as self.as_ref().

Example
let angle = 1.78f32;
let rot = UnitComplex::new(angle);
assert_eq!(*rot.complex(), Complex::new(angle.cos(), angle.sin()));

Compute the conjugate of this unit complex number.

Example
let rot = UnitComplex::new(1.78);
let conj = rot.conjugate();
assert_eq!(rot.complex().im, -conj.complex().im);
assert_eq!(rot.complex().re, conj.complex().re);

Inverts this complex number if it is not zero.

Example
let rot = UnitComplex::new(1.2);
let inv = rot.inverse();
assert_relative_eq!(rot * inv, UnitComplex::identity(), epsilon = 1.0e-6);
assert_relative_eq!(inv * rot, UnitComplex::identity(), epsilon = 1.0e-6);

The rotation angle needed to make self and other coincide.

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

The unit complex number needed to make self and other coincide.

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

Example
let rot1 = UnitComplex::new(0.1);
let rot2 = UnitComplex::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);

Compute in-place the conjugate of this unit complex number.

Example
let angle = 1.7;
let rot = UnitComplex::new(angle);
let mut conj = UnitComplex::new(angle);
conj.conjugate_mut();
assert_eq!(rot.complex().im, -conj.complex().im);
assert_eq!(rot.complex().re, conj.complex().re);

Inverts in-place this unit complex number.

Example
let angle = 1.7;
let mut rot = UnitComplex::new(angle);
rot.inverse_mut();
assert_relative_eq!(rot * UnitComplex::new(angle), UnitComplex::identity());
assert_relative_eq!(UnitComplex::new(angle) * rot, UnitComplex::identity());

Raise this unit complex number to a given floating power.

This returns the unit complex number that identifies a rotation angle equal to self.angle() × n.

Example
let rot = UnitComplex::new(0.78);
let pow = rot.powf(2.0);
assert_eq!(pow.angle(), 2.0 * 0.78);

Builds the rotation matrix corresponding to this unit complex number.

Example
let rot = UnitComplex::new(f32::consts::FRAC_PI_6);
let expected = Rotation2::new(f32::consts::FRAC_PI_6);
assert_eq!(rot.to_rotation_matrix(), expected);

Converts this unit complex number into its equivalent homogeneous transformation matrix.

Example
let rot = UnitComplex::new(f32::consts::FRAC_PI_6);
let expected = Matrix3::new(0.8660254, -0.5,      0.0,
                            0.5,       0.8660254, 0.0,
                            0.0,       0.0,       1.0);
assert_eq!(rot.to_homogeneous(), expected);

The unit complex number multiplicative identity.

Example
let rot1 = UnitComplex::identity();
let rot2 = UnitComplex::new(1.7);

assert_eq!(rot1 * rot2, rot2);
assert_eq!(rot2 * rot1, rot2);

Builds the unit complex number corresponding to the rotation with the given angle.

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

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

Builds the unit complex number corresponding to the rotation with the angle.

Same as Self::new(angle).

Example
let rot = UnitComplex::from_angle(f32::consts::FRAC_PI_2);

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

Builds the unit complex number from the sinus and cosinus of the rotation angle.

The input values are not checked to actually be cosines and sine of the same value. Is is generally preferable to use the ::new(angle) constructor instead.

Example
let angle = f32::consts::FRAC_PI_2;
let rot = UnitComplex::from_cos_sin_unchecked(angle.cos(), angle.sin());

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

Builds a unit complex rotation 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.

Creates a new unit complex number from a complex number.

The input complex number will be normalized.

Creates a new unit complex number from a complex number.

The input complex number will be normalized. Returns the norm of the complex number as well.

Builds the unit complex number from the corresponding 2D rotation matrix.

Example
let rot = Rotation2::new(1.7);
let complex = UnitComplex::from_rotation_matrix(&rot);
assert_eq!(complex, UnitComplex::new(1.7));

The unit complex needed to make a and b be collinear and point toward the same direction.

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

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 = UnitComplex::scaled_rotation_between(&a, &b, 0.2);
let rot5 = UnitComplex::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);

The unit complex needed to make a and b be collinear and point toward the same direction.

Example
let a = Unit::new_normalize(Vector2::new(1.0, 2.0));
let b = Unit::new_normalize(Vector2::new(2.0, 1.0));
let rot = UnitComplex::rotation_between_axis(&a, &b);
assert_relative_eq!(rot * a, b);
assert_relative_eq!(rot.inverse() * b, a);

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

Example
let a = Unit::new_normalize(Vector2::new(1.0, 2.0));
let b = Unit::new_normalize(Vector2::new(2.0, 1.0));
let rot2 = UnitComplex::scaled_rotation_between_axis(&a, &b, 0.2);
let rot5 = UnitComplex::scaled_rotation_between_axis(&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);

Performs the multiplication rhs = self * rhs in-place.

Performs the multiplication lhs = lhs * self in-place.

Trait Implementations§

Used for specifying relative comparisons.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of ApproxEq::abs_diff_eq.
Performs an operation.
Performs specific operation.
Checks whether operating with the identity element is a no-op for the given argument. Approximate equality is used for verifications. Read more
Returns true if latin squareness holds for the given arguments. Approximate equality is used for verifications. Read more
Returns true if associativity holds for the given arguments. Approximate equality is used for verifications. Read more
Type of the first rotation to be applied.
Type of the non-uniform scaling to be applied.
The type of the pure translation part of this affine transformation.
Decomposes this affine transformation into a rotation followed by a non-uniform scaling, followed by a rotation, followed by a translation. Read more
Appends a translation to this similarity.
Prepends a translation to this similarity.
Appends a rotation to this similarity.
Prepends a rotation to this similarity.
Appends a scaling factor to this similarity.
Prepends a scaling factor to this similarity.
Appends to this similarity a rotation centered at the point p, i.e., this point is left invariant. Read more
Formats the value using the given formatter. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
Performs the /= operation. Read more
The identity element.
Specific identity.
Returns the inverse of self, relative to the operator O.
In-place inversin of self.
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
The resulting type after applying the * operator.
Performs the * operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Performs the *= operation. Read more
Returns the multiplicative identity element of Self, 1. Read more
Sets self to the multiplicative identity element of Self, 1.
Returns true if self is equal to the multiplicative identity. Read more
Applies this group’s inverse action on a point from the euclidean space.
Applies this group’s inverse action on a vector from the euclidean space. Read more
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of ApproxEq::relative_eq.
Raises this rotation to a power. If this is a simple rotation, the result must be equivalent to multiplying the rotation angle by n. Read more
Computes a simple rotation that makes the angle between a and b equal to zero, i.e., b.angle(a * delta_rotation(a, b)) = 0. If a and b are collinear, the computed rotation may not be unique. Returns None if no such simple rotation exists in the subgroup represented by Self. Read more
Computes the rotation between a and b and raises it to the power n. Read more
The type of the pure (uniform) scaling part of this similarity transformation.
The pure translational component of this similarity transformation.
The pure rotational component of this similarity transformation.
The pure scaling component of this similarity transformation.
Applies this transformation’s pure translational part to a point.
Applies this transformation’s pure rotational part to a point.
Applies this transformation’s pure scaling part to a point.
Applies this transformation’s pure rotational part to a vector.
Applies this transformation’s pure scaling part to a vector.
Applies this transformation inverse’s pure translational part to a point.
Applies this transformation inverse’s pure rotational part to a point.
Applies this transformation inverse’s pure scaling part to a point.
Applies this transformation inverse’s pure rotational part to a vector.
Applies this transformation inverse’s pure scaling part to a vector.
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
The inclusion map: converts self to the equivalent element of its superset.
Checks if element is actually part of the subset Self (and can be converted to it).
Use with care! Same as self.to_superset but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Applies this group’s action on a point from the euclidean space.
Applies this group’s action on a vector from the euclidean space. Read more
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The inverse of ApproxEq::ulps_eq.