Struct nalgebra::geometry::Translation[][src]

#[repr(C)]
pub struct Translation<T, const D: usize> { pub vector: SVector<T, D>, }
Expand description

A translation.

Fields

vector: SVector<T, D>

The translation coordinates, i.e., how much is added to a point’s coordinates when it is translated.

Implementations

👎 Deprecated:

Use ::from instead.

Creates a new translation from the given vector.

Inverts self.

Example
let t = Translation3::new(1.0, 2.0, 3.0);
assert_eq!(t * t.inverse(), Translation3::identity());
assert_eq!(t.inverse() * t, Translation3::identity());

// Work in all dimensions.
let t = Translation2::new(1.0, 2.0);
assert_eq!(t * t.inverse(), Translation2::identity());
assert_eq!(t.inverse() * t, Translation2::identity());

Converts this translation into its equivalent homogeneous transformation matrix.

Example
let t = Translation3::new(10.0, 20.0, 30.0);
let expected = Matrix4::new(1.0, 0.0, 0.0, 10.0,
                            0.0, 1.0, 0.0, 20.0,
                            0.0, 0.0, 1.0, 30.0,
                            0.0, 0.0, 0.0, 1.0);
assert_eq!(t.to_homogeneous(), expected);

let t = Translation2::new(10.0, 20.0);
let expected = Matrix3::new(1.0, 0.0, 10.0,
                            0.0, 1.0, 20.0,
                            0.0, 0.0, 1.0);
assert_eq!(t.to_homogeneous(), expected);

Inverts self in-place.

Example
let t = Translation3::new(1.0, 2.0, 3.0);
let mut inv_t = Translation3::new(1.0, 2.0, 3.0);
inv_t.inverse_mut();
assert_eq!(t * inv_t, Translation3::identity());
assert_eq!(inv_t * t, Translation3::identity());

// Work in all dimensions.
let t = Translation2::new(1.0, 2.0);
let mut inv_t = Translation2::new(1.0, 2.0);
inv_t.inverse_mut();
assert_eq!(t * inv_t, Translation2::identity());
assert_eq!(inv_t * t, Translation2::identity());

Translate the given point.

This is the same as the multiplication self * pt.

Example
let t = Translation3::new(1.0, 2.0, 3.0);
let transformed_point = t.transform_point(&Point3::new(4.0, 5.0, 6.0));
assert_eq!(transformed_point, Point3::new(5.0, 7.0, 9.0));

Translate the given point by the inverse of this translation.

Example
let t = Translation3::new(1.0, 2.0, 3.0);
let transformed_point = t.inverse_transform_point(&Point3::new(4.0, 5.0, 6.0));
assert_eq!(transformed_point, Point3::new(3.0, 3.0, 3.0));

Creates a new identity translation.

Example
let t = Translation2::identity();
let p = Point2::new(1.0, 2.0);
assert_eq!(t * p, p);

// Works in all dimensions.
let t = Translation3::identity();
let p = Point3::new(1.0, 2.0, 3.0);
assert_eq!(t * p, p);

Cast the components of self to another type.

Example
let tra = Translation2::new(1.0f64, 2.0);
let tra2 = tra.cast::<f32>();
assert_eq!(tra2, Translation2::new(1.0f32, 2.0));

Initializes this translation from its components.

Example
let t = Translation1::new(1.0);
assert!(t.vector.x == 1.0);

Initializes this translation from its components.

Example
let t = Translation2::new(1.0, 2.0);
assert!(t.vector.x == 1.0 && t.vector.y == 2.0);

Initializes this translation from its components.

Example
let t = Translation3::new(1.0, 2.0, 3.0);
assert!(t.vector.x == 1.0 && t.vector.y == 2.0 && t.vector.z == 3.0);

Initializes this translation from its components.

Example
let t = Translation4::new(1.0, 2.0, 3.0, 4.0);
assert!(t.vector.x == 1.0 && t.vector.y == 2.0 && t.vector.z == 3.0 && t.vector.w == 4.0);

Initializes this translation from its components.

Example
let t = Translation5::new(1.0, 2.0, 3.0, 4.0, 5.0);
assert!(t.vector.x == 1.0 && t.vector.y == 2.0 && t.vector.z == 3.0 && t.vector.w == 4.0 && t.vector.a == 5.0);

Initializes this translation from its components.

Example
let t = Translation6::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
assert!(t.vector.x == 1.0 && t.vector.y == 2.0 && t.vector.z == 3.0 && t.vector.w == 4.0 && t.vector.a == 5.0 && t.vector.b == 6.0);

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 AbsDiffEq::abs_diff_eq.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

The resulting type after dereferencing.

Dereferences the value.

The resulting type after dereferencing.

Dereferences the value.

The resulting type after dereferencing.

Dereferences the value.

The resulting type after dereferencing.

Dereferences the value.

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Generate an arbitrary random variate for testing purposes.

Create an iterator that generates random values of T, using rng as the source of randomness. Read more

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F 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

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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

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

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

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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 RelativeEq::relative_eq.

The type of the elements of each lane of this SIMD value.

Type of the result of comparing two SIMD values like self.

The number of lanes of this SIMD value.

Initializes an SIMD value with each lanes set to val.

Extracts the i-th lane of self. Read more

Extracts the i-th lane of self without bound-checking.

Replaces the i-th lane of self by val. Read more

Replaces the i-th lane of self by val without bound-checking.

Merges self and other depending on the lanes of cond. Read more

Applies a function to each lane of self. Read more

Applies a function to each lane of self paired with the corresponding lane of b. 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

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 UlpsEq::ulps_eq.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

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

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.