Add simple constructors for pure-translation and pure-rotation isometries.
This commit is contained in:
parent
a7ab61f974
commit
13f76efe36
|
@ -16,7 +16,7 @@ use base::{DefaultAllocator, Vector2, Vector3};
|
||||||
|
|
||||||
use geometry::{
|
use geometry::{
|
||||||
Isometry, Point, Point3, Rotation, Rotation2, Rotation3, Translation, UnitComplex,
|
Isometry, Point, Point3, Rotation, Rotation2, Rotation3, Translation, UnitComplex,
|
||||||
UnitQuaternion,
|
UnitQuaternion, Translation2, Translation3
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<N: Real, D: DimName, R: AlgaRotation<Point<N, D>>> Isometry<N, D, R>
|
impl<N: Real, D: DimName, R: AlgaRotation<Point<N, D>>> Isometry<N, D, R>
|
||||||
|
@ -89,6 +89,18 @@ impl<N: Real> Isometry<N, U2, Rotation2<N>> {
|
||||||
Rotation::<N, U2>::new(angle),
|
Rotation::<N, U2>::new(angle),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given translation coordinates.
|
||||||
|
#[inline]
|
||||||
|
pub fn translation(x: N, y: N) -> Self {
|
||||||
|
Self::new(Vector2::new(x, y), N::zero())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given rotation angle.
|
||||||
|
#[inline]
|
||||||
|
pub fn rotation(angle: N) -> Self {
|
||||||
|
Self::new(Vector2::zeros(), angle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Real> Isometry<N, U2, UnitComplex<N>> {
|
impl<N: Real> Isometry<N, U2, UnitComplex<N>> {
|
||||||
|
@ -100,6 +112,18 @@ impl<N: Real> Isometry<N, U2, UnitComplex<N>> {
|
||||||
UnitComplex::from_angle(angle),
|
UnitComplex::from_angle(angle),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given translation coordinates.
|
||||||
|
#[inline]
|
||||||
|
pub fn translation(x: N, y: N) -> Self {
|
||||||
|
Self::from_parts(Translation2::new(x, y), UnitComplex::identity())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given rotation angle.
|
||||||
|
#[inline]
|
||||||
|
pub fn rotation(angle: N) -> Self {
|
||||||
|
Self::new(Vector2::zeros(), angle)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3D rotation.
|
// 3D rotation.
|
||||||
|
@ -114,6 +138,18 @@ macro_rules! isometry_construction_impl(
|
||||||
$RotId::<$($RotParams),*>::from_scaled_axis(axisangle))
|
$RotId::<$($RotParams),*>::from_scaled_axis(axisangle))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given translation coordinates.
|
||||||
|
#[inline]
|
||||||
|
pub fn translation(x: N, y: N, z: N) -> Self {
|
||||||
|
Self::from_parts(Translation3::new(x, y, z), $RotId::identity())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a new isometry from the given rotation angle.
|
||||||
|
#[inline]
|
||||||
|
pub fn rotation(axisangle: Vector3<N>) -> Self {
|
||||||
|
Self::new(Vector3::zeros(), axisangle)
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates an isometry that corresponds to the local frame of an observer standing at the
|
/// Creates an isometry that corresponds to the local frame of an observer standing at the
|
||||||
/// point `eye` and looking toward `target`.
|
/// point `eye` and looking toward `target`.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue