forked from M-Labs/nalgebra
Fix automatic text replacement on comments.
This commit is contained in:
parent
ccce2f2a3f
commit
ce0178785c
22
src/lib.rs
22
src/lib.rs
@ -42,7 +42,7 @@ fn main() {
|
|||||||
an optimized set of tools for computer graphics and physics. Those features include:
|
an optimized set of tools for computer graphics and physics. Those features include:
|
||||||
|
|
||||||
* Vectors with static sizes: `Vec0`, `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
|
* Vectors with static sizes: `Vec0`, `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
|
||||||
* Poisizes with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
|
* Points with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
|
||||||
* Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
|
* Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
|
||||||
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`.
|
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`.
|
||||||
* Quaternions: `Quat`, `UnitQuat`.
|
* Quaternions: `Quat`, `UnitQuat`.
|
||||||
@ -315,7 +315,7 @@ pub fn orig<P: Orig>() -> P {
|
|||||||
Orig::orig()
|
Orig::orig()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the center of two poisizes.
|
/// Returns the center of two points.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P {
|
pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P {
|
||||||
let _2 = one::<N>() + one();
|
let _2 = one::<N>() + one();
|
||||||
@ -325,13 +325,13 @@ pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P {
|
|||||||
/*
|
/*
|
||||||
* FloatPnt
|
* FloatPnt
|
||||||
*/
|
*/
|
||||||
/// Returns the distance between two poisizes.
|
/// Returns the distance between two points.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
|
pub fn dist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
|
||||||
a.dist(b)
|
a.dist(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the squared distance between two poisizes.
|
/// Returns the squared distance between two points.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn sqdist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
|
pub fn sqdist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
|
||||||
a.sqdist(b)
|
a.sqdist(b)
|
||||||
@ -409,7 +409,7 @@ pub fn append_translation<V, M: Translation<V>>(m: &M, v: &V) -> M {
|
|||||||
* Translate<P>
|
* Translate<P>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// Applies a translation to a poisize.
|
/// Applies a translation to a point.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// extern crate "nalgebra" as na;
|
/// extern crate "nalgebra" as na;
|
||||||
@ -429,7 +429,7 @@ pub fn translate<P, M: Translate<P>>(m: &M, p: &P) -> P {
|
|||||||
m.translate(p)
|
m.translate(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies an inverse translation to a poisize.
|
/// Applies an inverse translation to a point.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// extern crate "nalgebra" as na;
|
/// extern crate "nalgebra" as na;
|
||||||
@ -576,18 +576,18 @@ pub fn inv_rotate<V, M: Rotate<V>>(m: &M, v: &V) -> V {
|
|||||||
* RotationWithTranslation<LV, AV>
|
* RotationWithTranslation<LV, AV>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// Rotates a copy of `m` by `amount` using `center` as the pivot poisize.
|
/// Rotates a copy of `m` by `amount` using `center` as the pivot point.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn append_rotation_wrt_poisize<LV: Neg<Output = LV> + Copy,
|
pub fn append_rotation_wrt_point<LV: Neg<Output = LV> + Copy,
|
||||||
AV,
|
AV,
|
||||||
M: RotationWithTranslation<LV, AV>>(
|
M: RotationWithTranslation<LV, AV>>(
|
||||||
m: &M,
|
m: &M,
|
||||||
amount: &AV,
|
amount: &AV,
|
||||||
center: &LV) -> M {
|
center: &LV) -> M {
|
||||||
RotationWithTranslation::append_rotation_wrt_poisize_cpy(m, amount, center)
|
RotationWithTranslation::append_rotation_wrt_point_cpy(m, amount, center)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot poisize.
|
/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot point.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn append_rotation_wrt_center<LV: Neg<Output = LV> + Copy,
|
pub fn append_rotation_wrt_center<LV: Neg<Output = LV> + Copy,
|
||||||
AV,
|
AV,
|
||||||
@ -745,7 +745,7 @@ pub fn from_homogeneous<M, Res: FromHomogeneous<M>>(m: &M) -> Res {
|
|||||||
|
|
||||||
/// Samples the unit sphere living on the dimension as the samples types.
|
/// Samples the unit sphere living on the dimension as the samples types.
|
||||||
///
|
///
|
||||||
/// The number of sampling poisize is implementation-specific. It is always uniform.
|
/// The number of sampling point is implementation-specific. It is always uniform.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn sample_sphere<V: UniformSphereSample, F: FnMut(V)>(f: F) {
|
pub fn sample_sphere<V: UniformSphereSample, F: FnMut(V)>(f: F) {
|
||||||
UniformSphereSample::sample(f)
|
UniformSphereSample::sample(f)
|
||||||
|
@ -52,29 +52,29 @@ pub struct Iso4<N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Clone + BaseFloat> Iso3<N> {
|
impl<N: Clone + BaseFloat> Iso3<N> {
|
||||||
/// Reorient and translate this transformation such that its local `x` axis poisizes to a given
|
/// Reorient and translate this transformation such that its local `x` axis points to a given
|
||||||
/// direction. Note that the usually known `look_at` function does the same thing but with the
|
/// direction. Note that the usually known `look_at` function does the same thing but with the
|
||||||
/// `z` axis. See `look_at_z` for that.
|
/// `z` axis. See `look_at_z` for that.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * eye - The new translation of the transformation.
|
/// * eye - The new translation of the transformation.
|
||||||
/// * at - The poisize to look at. `at - eye` is the direction the matrix `x` axis will be
|
/// * at - The point to look at. `at - eye` is the direction the matrix `x` axis will be
|
||||||
/// aligned with.
|
/// aligned with.
|
||||||
/// * up - Vector poisizeing up. The only requirement of this parameter is to not be colinear
|
/// * up - Vector pointing up. The only requirement of this parameter is to not be colinear
|
||||||
/// with `at`. Non-colinearity is not checked.
|
/// with `at`. Non-colinearity is not checked.
|
||||||
pub fn look_at(&mut self, eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) {
|
pub fn look_at(&mut self, eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) {
|
||||||
self.rotation.look_at(&(*at - *eye), up);
|
self.rotation.look_at(&(*at - *eye), up);
|
||||||
self.translation = eye.as_vec().clone();
|
self.translation = eye.as_vec().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reorient and translate this transformation such that its local `z` axis poisizes to a given
|
/// Reorient and translate this transformation such that its local `z` axis points to a given
|
||||||
/// direction.
|
/// direction.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * eye - The new translation of the transformation.
|
/// * eye - The new translation of the transformation.
|
||||||
/// * at - The poisize to look at. `at - eye` is the direction the matrix `x` axis will be
|
/// * at - The point to look at. `at - eye` is the direction the matrix `x` axis will be
|
||||||
/// aligned with
|
/// aligned with
|
||||||
/// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear
|
/// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear
|
||||||
/// with `at`. Non-colinearity is not checked.
|
/// with `at`. Non-colinearity is not checked.
|
||||||
pub fn look_at_z(&mut self, eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) {
|
pub fn look_at_z(&mut self, eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) {
|
||||||
self.rotation.look_at_z(&(*at - *eye), up);
|
self.rotation.look_at_z(&(*at - *eye), up);
|
||||||
|
@ -96,7 +96,7 @@ impl<N: BaseFloat + Clone> Ortho3<N> {
|
|||||||
self.zfar = zfar
|
self.zfar = zfar
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Projects a poisize.
|
/// Projects a point.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
||||||
// FIXME: optimize that
|
// FIXME: optimize that
|
||||||
@ -204,7 +204,7 @@ impl<N: BaseFloat> OrthoMat3<N> {
|
|||||||
self.mat.m34 = -(zfar + znear) / (zfar - znear);
|
self.mat.m34 = -(zfar + znear) / (zfar - znear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Projects a poisize.
|
/// Projects a point.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
||||||
Pnt3::new(
|
Pnt3::new(
|
||||||
|
@ -102,7 +102,7 @@ impl<N: BaseFloat + Clone> Persp3<N> {
|
|||||||
self.zfar = zfar;
|
self.zfar = zfar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Projects a poisize.
|
/// Projects a point.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
||||||
// FIXME: optimize that
|
// FIXME: optimize that
|
||||||
@ -231,7 +231,7 @@ impl<N: BaseFloat> PerspMat3<N> {
|
|||||||
self.mat.m34 = zfar * znear * _2 / (znear - zfar);
|
self.mat.m34 = zfar * znear * _2 / (znear - zfar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Projects a poisize.
|
/// Projects a point.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
|
||||||
let _1: N = ::one();
|
let _1: N = ::one();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Poisizes with dimensions known at compile-time.
|
//! Points with dimensions known at compile-time.
|
||||||
|
|
||||||
#![allow(missing_docs)] // we allow missing to avoid having to document the poisize components.
|
#![allow(missing_docs)] // we allow missing to avoid having to document the point components.
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::slice::{Iter, IterMut};
|
use std::slice::{Iter, IterMut};
|
||||||
@ -14,28 +14,28 @@ use traits::geometry::{Orig, FromHomogeneous, ToHomogeneous};
|
|||||||
use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
||||||
|
|
||||||
|
|
||||||
/// Poisize of dimension 0.
|
/// Point of dimension 0.
|
||||||
#[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)]
|
||||||
pub struct Pnt0<N>;
|
pub struct Pnt0<N>;
|
||||||
|
|
||||||
impl<N> Pnt0<N> {
|
impl<N> Pnt0<N> {
|
||||||
/// Creates a new poisize.
|
/// Creates a new point.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new() -> Pnt0<N> {
|
pub fn new() -> Pnt0<N> {
|
||||||
Pnt0
|
Pnt0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new poisize. The parameter is not taken in account.
|
/// Creates a new point. The parameter is not taken in account.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_repeat(_: N) -> Pnt0<N> {
|
pub fn new_repeat(_: N) -> Pnt0<N> {
|
||||||
Pnt0
|
Pnt0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Poisize of dimension 1.
|
/// Point of dimension 1.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt1<N> {
|
pub struct Pnt1<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N
|
pub x: N
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ pnt_to_homogeneous_impl!(Pnt1, Pnt2, y, x);
|
|||||||
pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x);
|
pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x);
|
||||||
num_float_pnt_impl!(Pnt1, Vec1);
|
num_float_pnt_impl!(Pnt1, Vec1);
|
||||||
|
|
||||||
/// Poisize of dimension 2.
|
/// Point of dimension 2.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt2<N> {
|
pub struct Pnt2<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N,
|
pub x: N,
|
||||||
/// Second component of the poisize.
|
/// Second component of the point.
|
||||||
pub y: N
|
pub y: N
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ pnt_to_homogeneous_impl!(Pnt2, Pnt3, z, x, y);
|
|||||||
pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y);
|
pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y);
|
||||||
num_float_pnt_impl!(Pnt2, Vec2);
|
num_float_pnt_impl!(Pnt2, Vec2);
|
||||||
|
|
||||||
/// Poisize of dimension 3.
|
/// Point of dimension 3.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt3<N> {
|
pub struct Pnt3<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N,
|
pub x: N,
|
||||||
/// Second component of the poisize.
|
/// Second component of the point.
|
||||||
pub y: N,
|
pub y: N,
|
||||||
/// Third component of the poisize.
|
/// Third component of the point.
|
||||||
pub z: N
|
pub z: N
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,16 +152,16 @@ pnt_to_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z);
|
|||||||
pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z);
|
pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z);
|
||||||
num_float_pnt_impl!(Pnt3, Vec3);
|
num_float_pnt_impl!(Pnt3, Vec3);
|
||||||
|
|
||||||
/// Poisize of dimension 4.
|
/// Point of dimension 4.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt4<N> {
|
pub struct Pnt4<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N,
|
pub x: N,
|
||||||
/// Second component of the poisize.
|
/// Second component of the point.
|
||||||
pub y: N,
|
pub y: N,
|
||||||
/// Third component of the poisize.
|
/// Third component of the point.
|
||||||
pub z: N,
|
pub z: N,
|
||||||
/// Fourth component of the poisize.
|
/// Fourth component of the point.
|
||||||
pub w: N
|
pub w: N
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,18 +196,18 @@ pnt_to_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w);
|
|||||||
pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w);
|
pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w);
|
||||||
num_float_pnt_impl!(Pnt4, Vec4);
|
num_float_pnt_impl!(Pnt4, Vec4);
|
||||||
|
|
||||||
/// Poisize of dimension 5.
|
/// Point of dimension 5.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt5<N> {
|
pub struct Pnt5<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N,
|
pub x: N,
|
||||||
/// Second component of the poisize.
|
/// Second component of the point.
|
||||||
pub y: N,
|
pub y: N,
|
||||||
/// Third component of the poisize.
|
/// Third component of the point.
|
||||||
pub z: N,
|
pub z: N,
|
||||||
/// Fourth component of the poisize.
|
/// Fourth component of the point.
|
||||||
pub w: N,
|
pub w: N,
|
||||||
/// Fifth of the poisize.
|
/// Fifth of the point.
|
||||||
pub a: N
|
pub a: N
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,20 +242,20 @@ pnt_to_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a);
|
|||||||
pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a);
|
pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a);
|
||||||
num_float_pnt_impl!(Pnt5, Vec5);
|
num_float_pnt_impl!(Pnt5, Vec5);
|
||||||
|
|
||||||
/// Poisize of dimension 6.
|
/// Point of dimension 6.
|
||||||
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
|
||||||
pub struct Pnt6<N> {
|
pub struct Pnt6<N> {
|
||||||
/// First component of the poisize.
|
/// First component of the point.
|
||||||
pub x: N,
|
pub x: N,
|
||||||
/// Second component of the poisize.
|
/// Second component of the point.
|
||||||
pub y: N,
|
pub y: N,
|
||||||
/// Third component of the poisize.
|
/// Third component of the point.
|
||||||
pub z: N,
|
pub z: N,
|
||||||
/// Fourth component of the poisize.
|
/// Fourth component of the point.
|
||||||
pub w: N,
|
pub w: N,
|
||||||
/// Fifth of the poisize.
|
/// Fifth of the point.
|
||||||
pub a: N,
|
pub a: N,
|
||||||
/// Sixth component of the poisize.
|
/// Sixth component of the point.
|
||||||
pub b: N
|
pub b: N
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ macro_rules! pnt_sub_vec_impl(
|
|||||||
macro_rules! pnt_as_vec_impl(
|
macro_rules! pnt_as_vec_impl(
|
||||||
($t: ident, $tv: ident, $($compN: ident),+) => (
|
($t: ident, $tv: ident, $($compN: ident),+) => (
|
||||||
impl<N> $t<N> {
|
impl<N> $t<N> {
|
||||||
/// Converts this poisize to its associated vector.
|
/// Converts this point to its associated vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_vec(self) -> $tv<N> {
|
pub fn to_vec(self) -> $tv<N> {
|
||||||
$tv::new(
|
$tv::new(
|
||||||
@ -68,7 +68,7 @@ macro_rules! pnt_as_vec_impl(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a reference to this poisize to a reference to its associated vector.
|
/// Converts a reference to this point to a reference to its associated vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_vec<'a>(&'a self) -> &'a $tv<N> {
|
pub fn as_vec<'a>(&'a self) -> &'a $tv<N> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -167,14 +167,14 @@ impl<N: Clone + BaseFloat> Rot3<N> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Clone + BaseFloat> Rot3<N> {
|
impl<N: Clone + BaseFloat> Rot3<N> {
|
||||||
/// Reorient this matrix such that its local `x` axis poisizes to a given poisize. Note that the
|
/// Reorient this matrix such that its local `x` axis points to a given point. Note that the
|
||||||
/// usually known `look_at` function does the same thing but with the `z` axis. See `look_at_z`
|
/// usually known `look_at` function does the same thing but with the `z` axis. See `look_at_z`
|
||||||
/// for that.
|
/// for that.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * at - The poisize to look at. It is also the direction the matrix `x` axis will be aligned
|
/// * at - The point to look at. It is also the direction the matrix `x` axis will be aligned
|
||||||
/// with
|
/// with
|
||||||
/// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear
|
/// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear
|
||||||
/// with `at`. Non-colinearity is not checked.
|
/// with `at`. Non-colinearity is not checked.
|
||||||
pub fn look_at(&mut self, at: &Vec3<N>, up: &Vec3<N>) {
|
pub fn look_at(&mut self, at: &Vec3<N>, up: &Vec3<N>) {
|
||||||
let xaxis = Norm::normalize_cpy(at);
|
let xaxis = Norm::normalize_cpy(at);
|
||||||
@ -187,11 +187,11 @@ impl<N: Clone + BaseFloat> Rot3<N> {
|
|||||||
xaxis.z , yaxis.z , zaxis.z)
|
xaxis.z , yaxis.z , zaxis.z)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reorient this matrix such that its local `z` axis poisizes to a given poisize.
|
/// Reorient this matrix such that its local `z` axis points to a given point.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * at - The look direction, that is, direction the matrix `y` axis will be aligned with
|
/// * at - The look direction, that is, direction the matrix `y` axis will be aligned with
|
||||||
/// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear
|
/// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear
|
||||||
/// with `at`. Non-colinearity is not checked.
|
/// with `at`. Non-colinearity is not checked.
|
||||||
pub fn look_at_z(&mut self, at: &Vec3<N>, up: &Vec3<N>) {
|
pub fn look_at_z(&mut self, at: &Vec3<N>, up: &Vec3<N>) {
|
||||||
let zaxis = Norm::normalize_cpy(at);
|
let zaxis = Norm::normalize_cpy(at);
|
||||||
|
@ -30,7 +30,7 @@ pub trait Translation<V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Trait of objects able to translate other objects. This is typically
|
/// Trait of objects able to translate other objects. This is typically
|
||||||
/// implemented by vectors to translate poisizes.
|
/// implemented by vectors to translate points.
|
||||||
pub trait Translate<V> {
|
pub trait Translate<V> {
|
||||||
/// Apply a translation to an object.
|
/// Apply a translation to an object.
|
||||||
fn translate(&self, &V) -> V;
|
fn translate(&self, &V) -> V;
|
||||||
@ -77,20 +77,20 @@ pub trait Rotate<V> {
|
|||||||
|
|
||||||
/// Various composition of rotation and translation.
|
/// Various composition of rotation and translation.
|
||||||
///
|
///
|
||||||
/// Utilities to make rotations with regard to a poisize different than the origin. All those
|
/// Utilities to make rotations with regard to a point different than the origin. All those
|
||||||
/// operations are the composition of rotations and translations.
|
/// operations are the composition of rotations and translations.
|
||||||
///
|
///
|
||||||
/// Those operations are automatically implemented in term of the `Rotation` and `Translation`
|
/// Those operations are automatically implemented in term of the `Rotation` and `Translation`
|
||||||
/// traits.
|
/// traits.
|
||||||
pub trait RotationWithTranslation<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV> + Translation<LV> + Sized {
|
pub trait RotationWithTranslation<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV> + Translation<LV> + Sized {
|
||||||
/// Applies a rotation centered on a specific poisize.
|
/// Applies a rotation centered on a specific point.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `t` - the object to be rotated.
|
/// * `t` - the object to be rotated.
|
||||||
/// * `amount` - the rotation to apply.
|
/// * `amount` - the rotation to apply.
|
||||||
/// * `poisize` - the center of rotation.
|
/// * `point` - the center of rotation.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_rotation_wrt_poisize_cpy(&self, amount: &AV, center: &LV) -> Self {
|
fn append_rotation_wrt_point_cpy(&self, amount: &AV, center: &LV) -> Self {
|
||||||
let mut res = Translation::append_translation_cpy(self, &-*center);
|
let mut res = Translation::append_translation_cpy(self, &-*center);
|
||||||
|
|
||||||
res.append_rotation(amount);
|
res.append_rotation(amount);
|
||||||
@ -107,7 +107,7 @@ pub trait RotationWithTranslation<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
|
|||||||
/// * `amount` - the rotation to be applied
|
/// * `amount` - the rotation to be applied
|
||||||
/// * `center` - the new center of rotation
|
/// * `center` - the new center of rotation
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_rotation_wrt_poisize(&mut self, amount: &AV, center: &LV) {
|
fn append_rotation_wrt_point(&mut self, amount: &AV, center: &LV) {
|
||||||
self.append_translation(&-*center);
|
self.append_translation(&-*center);
|
||||||
self.append_rotation(amount);
|
self.append_rotation(amount);
|
||||||
self.append_translation(center);
|
self.append_translation(center);
|
||||||
@ -120,7 +120,7 @@ pub trait RotationWithTranslation<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
|
|||||||
/// * `amount` - the rotation to apply.
|
/// * `amount` - the rotation to apply.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_rotation_wrt_center_cpy(&self, amount: &AV) -> Self {
|
fn append_rotation_wrt_center_cpy(&self, amount: &AV) -> Self {
|
||||||
RotationWithTranslation::append_rotation_wrt_poisize_cpy(self, amount, &self.translation())
|
RotationWithTranslation::append_rotation_wrt_point_cpy(self, amount, &self.translation())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies a rotation centered on the translation of `m`.
|
/// Applies a rotation centered on the translation of `m`.
|
||||||
@ -132,7 +132,7 @@ pub trait RotationWithTranslation<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn append_rotation_wrt_center(&mut self, amount: &AV) {
|
fn append_rotation_wrt_center(&mut self, amount: &AV) {
|
||||||
let center = self.translation();
|
let center = self.translation();
|
||||||
self.append_rotation_wrt_poisize(amount, ¢er)
|
self.append_rotation_wrt_point(amount, ¢er)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,6 +274,6 @@ pub trait UniformSphereSample {
|
|||||||
pub trait Orig {
|
pub trait Orig {
|
||||||
/// The trivial origin.
|
/// The trivial origin.
|
||||||
fn orig() -> Self;
|
fn orig() -> Self;
|
||||||
/// Returns true if this poisizes is exactly the trivial origin.
|
/// Returns true if this points is exactly the trivial origin.
|
||||||
fn is_orig(&self) -> bool;
|
fn is_orig(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ impl POrdering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Poisizewise ordering operations.
|
/// Pointwise ordering operations.
|
||||||
pub trait POrd {
|
pub trait POrd {
|
||||||
/// Returns the infimum of this value and another
|
/// Returns the infimum of this value and another
|
||||||
fn inf(&self, other: &Self) -> Self;
|
fn inf(&self, other: &Self) -> Self;
|
||||||
|
@ -16,7 +16,7 @@ pub trait BaseNum: Copy + Zero + One +
|
|||||||
Absolute<Self> + Axpy<Self> {
|
Absolute<Self> + Axpy<Self> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Basic floating-poisize number numeric trait.
|
/// Basic floating-point number numeric trait.
|
||||||
pub trait BaseFloat: Float + BaseNum {
|
pub trait BaseFloat: Float + BaseNum {
|
||||||
/// Archimedes' constant.
|
/// Archimedes' constant.
|
||||||
fn pi() -> Self;
|
fn pi() -> Self;
|
||||||
@ -226,13 +226,13 @@ pub trait IterableMut<N> {
|
|||||||
/*
|
/*
|
||||||
* Vec related traits.
|
* Vec related traits.
|
||||||
*/
|
*/
|
||||||
/// Trait that relates a poisize of an affine space to a vector of the associated vector space.
|
/// Trait that relates a point of an affine space to a vector of the associated vector space.
|
||||||
#[deprecated = "This will be removed in the future. Use poisize + vector operations instead."]
|
#[deprecated = "This will be removed in the future. Use point + vector operations instead."]
|
||||||
pub trait VecAsPnt<P> {
|
pub trait VecAsPnt<P> {
|
||||||
/// Converts this poisize to its associated vector.
|
/// Converts this point to its associated vector.
|
||||||
fn to_pnt(self) -> P;
|
fn to_pnt(self) -> P;
|
||||||
|
|
||||||
/// Converts a reference to this poisize to a reference to its associated vector.
|
/// Converts a reference to this point to a reference to its associated vector.
|
||||||
fn as_pnt<'a>(&'a self) -> &'a P;
|
fn as_pnt<'a>(&'a self) -> &'a P;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,21 +252,21 @@ pub trait FloatVec<N: BaseFloat>: NumVec<N> + Norm<N> + Basis {
|
|||||||
/*
|
/*
|
||||||
* Pnt related traits.
|
* Pnt related traits.
|
||||||
*/
|
*/
|
||||||
/// Trait that relates a poisize of an affine space to a vector of the associated vector space.
|
/// Trait that relates a point of an affine space to a vector of the associated vector space.
|
||||||
pub trait PntAsVec<V> {
|
pub trait PntAsVec<V> {
|
||||||
/// Converts this poisize to its associated vector.
|
/// Converts this point to its associated vector.
|
||||||
fn to_vec(self) -> V;
|
fn to_vec(self) -> V;
|
||||||
|
|
||||||
/// Converts a reference to this poisize to a reference to its associated vector.
|
/// Converts a reference to this point to a reference to its associated vector.
|
||||||
fn as_vec<'a>(&'a self) -> &'a V;
|
fn as_vec<'a>(&'a self) -> &'a V;
|
||||||
|
|
||||||
// NOTE: this is used in some places to overcome some limitations untill the trait reform is
|
// NOTE: this is used in some places to overcome some limitations untill the trait reform is
|
||||||
// done on rustc.
|
// done on rustc.
|
||||||
/// Sets the coordinates of this poisize to match those of a given vector.
|
/// Sets the coordinates of this point to match those of a given vector.
|
||||||
fn set_coords(&mut self, coords: V);
|
fn set_coords(&mut self, coords: V);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait grouping most common operations on poisizes.
|
/// Trait grouping most common operations on points.
|
||||||
// XXX: the vector space element `V` should be an associated type. Though this would prevent V from
|
// XXX: the vector space element `V` should be an associated type. Though this would prevent V from
|
||||||
// having bounds (they are not supported yet). So, for now, we will just use a type parameter.
|
// having bounds (they are not supported yet). So, for now, we will just use a type parameter.
|
||||||
pub trait NumPnt<N, V>:
|
pub trait NumPnt<N, V>:
|
||||||
@ -284,15 +284,15 @@ pub trait NumPnt<N, V>:
|
|||||||
Index<usize, Output = N> { // FIXME: + Sub<V, Self>
|
Index<usize, Output = N> { // FIXME: + Sub<V, Self>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait of poisizes with components implementing the `BaseFloat` trait.
|
/// Trait of points with components implementing the `BaseFloat` trait.
|
||||||
pub trait FloatPnt<N: BaseFloat, V: Norm<N>>: NumPnt<N, V> + Sized {
|
pub trait FloatPnt<N: BaseFloat, V: Norm<N>>: NumPnt<N, V> + Sized {
|
||||||
/// Computes the square distance between two poisizes.
|
/// Computes the square distance between two points.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sqdist(&self, other: &Self) -> N {
|
fn sqdist(&self, other: &Self) -> N {
|
||||||
(*self - *other).sqnorm()
|
(*self - *other).sqnorm()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the distance between two poisizes.
|
/// Computes the distance between two points.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn dist(&self, other: &Self) -> N {
|
fn dist(&self, other: &Self) -> N {
|
||||||
(*self - *other).norm()
|
(*self - *other).norm()
|
||||||
|
Loading…
Reference in New Issue
Block a user