Documentation fixes.

This commit is contained in:
Sébastien Crozet 2014-10-10 20:56:40 +02:00
parent e852eb4783
commit 6fb6d35980
8 changed files with 64 additions and 40 deletions

View File

@ -215,6 +215,10 @@ pub mod overload {
Vec1DivRhs, Vec2DivRhs, Vec3DivRhs, Vec4DivRhs, Vec5DivRhs, Vec6DivRhs,
Vec1AddRhs, Vec2AddRhs, Vec3AddRhs, Vec4AddRhs, Vec5AddRhs, Vec6AddRhs,
Vec1SubRhs, Vec2SubRhs, Vec3SubRhs, Vec4SubRhs, Vec5SubRhs, Vec6SubRhs,
Pnt1MulRhs, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs, Pnt5MulRhs, Pnt6MulRhs,
Pnt1DivRhs, Pnt2DivRhs, Pnt3DivRhs, Pnt4DivRhs, Pnt5DivRhs, Pnt6DivRhs,
Pnt1AddRhs, Pnt2AddRhs, Pnt3AddRhs, Pnt4AddRhs, Pnt5AddRhs, Pnt6AddRhs,
Pnt1SubRhs, Pnt2SubRhs, Pnt3SubRhs, Pnt4SubRhs, Pnt5SubRhs, Pnt6SubRhs,
Mat1MulRhs, Mat2MulRhs, Mat3MulRhs, Mat4MulRhs, Mat5MulRhs, Mat6MulRhs,
Mat1DivRhs, Mat2DivRhs, Mat3DivRhs, Mat4DivRhs, Mat5DivRhs, Mat6DivRhs,
Mat1AddRhs, Mat2AddRhs, Mat3AddRhs, Mat4AddRhs, Mat5AddRhs, Mat6AddRhs,

View File

@ -12,6 +12,10 @@ pub use self::vec::{Vec1MulRhs, Vec2MulRhs, Vec3MulRhs, Vec4MulRhs, Vec5MulRhs,
Vec1DivRhs, Vec2DivRhs, Vec3DivRhs, Vec4DivRhs, Vec5DivRhs, Vec6DivRhs,
Vec1AddRhs, Vec2AddRhs, Vec3AddRhs, Vec4AddRhs, Vec5AddRhs, Vec6AddRhs,
Vec1SubRhs, Vec2SubRhs, Vec3SubRhs, Vec4SubRhs, Vec5SubRhs, Vec6SubRhs};
pub use self::pnt::{Pnt1MulRhs, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs, Pnt5MulRhs, Pnt6MulRhs,
Pnt1DivRhs, Pnt2DivRhs, Pnt3DivRhs, Pnt4DivRhs, Pnt5DivRhs, Pnt6DivRhs,
Pnt1AddRhs, Pnt2AddRhs, Pnt3AddRhs, Pnt4AddRhs, Pnt5AddRhs, Pnt6AddRhs,
Pnt1SubRhs, Pnt2SubRhs, Pnt3SubRhs, Pnt4SubRhs, Pnt5SubRhs, Pnt6SubRhs};
pub use self::mat::{Mat1MulRhs, Mat2MulRhs, Mat3MulRhs, Mat4MulRhs, Mat5MulRhs, Mat6MulRhs,
Mat1DivRhs, Mat2DivRhs, Mat3DivRhs, Mat4DivRhs, Mat5DivRhs, Mat6DivRhs,
Mat1AddRhs, Mat2AddRhs, Mat3AddRhs, Mat4AddRhs, Mat5AddRhs, Mat6AddRhs,

View File

@ -1,6 +1,6 @@
//! Points with dimensions known at compile-time.
#![allow(missing_doc)] // we allow missing to avoid having to document the vector components.
#![allow(missing_doc)] // we allow missing to avoid having to document the point components.
use std::mem;
use std::num::{Zero, One, Bounded};
@ -18,13 +18,13 @@ use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
pub struct Pnt0<N>;
impl<N> Pnt0<N> {
/// Creates a new vector.
/// Creates a new point.
#[inline]
pub fn new() -> Pnt0<N> {
Pnt0
}
/// Creates a new vector. The parameter is not taken in account.
/// Creates a new point. The parameter is not taken in account.
#[inline]
pub fn new_repeat(_: N) -> Pnt0<N> {
Pnt0
@ -34,7 +34,7 @@ impl<N> Pnt0<N> {
/// Point of dimension 1.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt1<N> {
/// First component of the vector.
/// First component of the point.
pub x: N
}
@ -123,9 +123,9 @@ pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x)
/// Point of dimension 2.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt2<N> {
/// First component of the vector.
/// First component of the point.
pub x: N,
/// Second component of the vector.
/// Second component of the point.
pub y: N
}
@ -214,11 +214,11 @@ pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y)
/// Point of dimension 3.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt3<N> {
/// First component of the vector.
/// First component of the point.
pub x: N,
/// Second component of the vector.
/// Second component of the point.
pub y: N,
/// Third component of the vector.
/// Third component of the point.
pub z: N
}
@ -307,13 +307,13 @@ pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z)
/// Point of dimension 4.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt4<N> {
/// First component of the vector.
/// First component of the point.
pub x: N,
/// Second component of the vector.
/// Second component of the point.
pub y: N,
/// Third component of the vector.
/// Third component of the point.
pub z: N,
/// Fourth component of the vector.
/// Fourth component of the point.
pub w: N
}
@ -402,15 +402,15 @@ pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w)
/// Point of dimension 5.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt5<N> {
/// First component of the vector.
/// First component of the point.
pub x: N,
/// Second component of the vector.
/// Second component of the point.
pub y: N,
/// Third component of the vector.
/// Third component of the point.
pub z: N,
/// Fourth component of the vector.
/// Fourth component of the point.
pub w: N,
/// Fifth of the vector.
/// Fifth of the point.
pub a: N
}
@ -499,17 +499,17 @@ pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a)
/// Point of dimension 6.
#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)]
pub struct Pnt6<N> {
/// First component of the vector.
/// First component of the point.
pub x: N,
/// Second component of the vector.
/// Second component of the point.
pub y: N,
/// Third component of the vector.
/// Third component of the point.
pub z: N,
/// Fourth component of the vector.
/// Fourth component of the point.
pub w: N,
/// Fifth of the vector.
/// Fifth of the point.
pub a: N,
/// Sixth component of the vector.
/// Sixth component of the point.
pub b: N
}

View File

@ -69,6 +69,12 @@ macro_rules! pnt_as_vec_impl(
mem::transmute(self)
}
}
#[inline]
fn set_coords(&mut self, v: $tv<N>) {
self.$comp0 = v.$comp0;
$(self.$compN = v.$compN;)*
}
}
impl<N> PntAsVec<$tv<N>> for $t<N> {
@ -81,6 +87,11 @@ macro_rules! pnt_as_vec_impl(
fn as_vec<'a>(&'a self) -> &'a $tv<N> {
self.as_vec()
}
#[inline]
fn set_coords(&mut self, v: $tv<N>) {
self.set_coords(v)
}
}
)
)

View File

@ -162,8 +162,7 @@ impl<N: Clone + Float> Rot3<N> {
/// Reorient this matrix such that its local `z` axis points to a given point.
///
/// # Arguments
/// * at - The point to look at. It is also the 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 pointing `up`. The only requirement of this parameter is to not be colinear
/// with `at`. Non-colinearity is not checked.
pub fn look_at_z(&mut self, at: &Vec3<N>, up: &Vec3<N>) {

View File

@ -123,8 +123,8 @@ from_iterator_impl!(Vec1, iterator)
bounded_impl!(Vec1, x)
iterable_impl!(Vec1, 1)
iterable_mut_impl!(Vec1, 1)
to_homogeneous_impl!(Vec1, Vec2, y, x)
from_homogeneous_impl!(Vec1, Vec2, y, x)
vec_to_homogeneous_impl!(Vec1, Vec2, y, x)
vec_from_homogeneous_impl!(Vec1, Vec2, y, x)
translate_impl!(Vec1, Pnt1)
rotate_impl!(Vec1)
rotate_impl!(Pnt1)
@ -224,8 +224,8 @@ from_iterator_impl!(Vec2, iterator, iterator)
bounded_impl!(Vec2, x, y)
iterable_impl!(Vec2, 2)
iterable_mut_impl!(Vec2, 2)
to_homogeneous_impl!(Vec2, Vec3, z, x, y)
from_homogeneous_impl!(Vec2, Vec3, z, x, y)
vec_to_homogeneous_impl!(Vec2, Vec3, z, x, y)
vec_from_homogeneous_impl!(Vec2, Vec3, z, x, y)
translate_impl!(Vec2, Pnt2)
rotate_impl!(Vec2)
rotate_impl!(Pnt2)
@ -330,8 +330,8 @@ from_iterator_impl!(Vec3, iterator, iterator, iterator)
bounded_impl!(Vec3, x, y, z)
iterable_impl!(Vec3, 3)
iterable_mut_impl!(Vec3, 3)
to_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
from_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
vec_to_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
vec_from_homogeneous_impl!(Vec3, Vec4, w, x, y, z)
translate_impl!(Vec3, Pnt3)
rotate_impl!(Vec3)
rotate_impl!(Pnt3)
@ -436,8 +436,8 @@ from_iterator_impl!(Vec4, iterator, iterator, iterator, iterator)
bounded_impl!(Vec4, x, y, z, w)
iterable_impl!(Vec4, 4)
iterable_mut_impl!(Vec4, 4)
to_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
from_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
vec_to_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
vec_from_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w)
translate_impl!(Vec4, Pnt4)
rotate_impl!(Vec4)
rotate_impl!(Pnt4)
@ -543,8 +543,8 @@ from_iterator_impl!(Vec5, iterator, iterator, iterator, iterator, iterator)
bounded_impl!(Vec5, x, y, z, w, a)
iterable_impl!(Vec5, 5)
iterable_mut_impl!(Vec5, 5)
to_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
from_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
vec_to_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
vec_from_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a)
translate_impl!(Vec5, Pnt5)
rotate_impl!(Vec5)
rotate_impl!(Pnt5)

View File

@ -599,7 +599,7 @@ macro_rules! bounded_impl(
)
)
macro_rules! to_homogeneous_impl(
macro_rules! vec_to_homogeneous_impl(
($t: ident, $t2: ident, $extra: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + One + Zero> ToHomogeneous<$t2<N>> for $t<N> {
fn to_homogeneous(v: &$t<N>) -> $t2<N> {
@ -614,7 +614,7 @@ macro_rules! to_homogeneous_impl(
)
)
macro_rules! from_homogeneous_impl(
macro_rules! vec_from_homogeneous_impl(
($t: ident, $t2: ident, $extra: ident, $comp0: ident $(,$compN: ident)*) => (
impl<N: Clone + Div<N, N> + One + Zero> FromHomogeneous<$t2<N>> for $t<N> {
fn from(v: &$t2<N>) -> $t<N> {

View File

@ -195,13 +195,19 @@ pub trait PntAsVec<V> {
/// Converts a reference to this point to a reference to its associated vector.
fn as_vec<'a>(&'a self) -> &'a V;
// NOTE: this is used in some places to overcome some limitations untill the trait reform is
// done on rustc.
/// Sets the coordinates of this point to match those of a given vector.
fn set_coords(&mut self, coords: V);
}
/// Trait grouping most common operations on points.
// 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.
pub trait AnyPnt<N, V>:
PntAsVec<V> + Dim + Sub<Self, V> + Orig + Neg<Self> + PartialEq + Mul<N, Self> + Div<N, Self> {
PntAsVec<V> + Dim + Sub<Self, V> + Orig + Neg<Self> + PartialEq + Mul<N, Self> +
Div<N, Self> + Add<V, Self> { // FIXME: + Sub<V, Self>
}
/// Trait of points with components implementing the `Float` trait.
@ -230,7 +236,7 @@ pub trait PntExt<N, V>: AnyPnt<N, V> + Indexable<uint, N> + Iterable<N> +
pub trait FloatPntExt<N: Float, V: Norm<N>> : FloatPnt<N, V> + PntExt<N, V> { }
impl<N, V, P: PntAsVec<V> + Dim + Sub<P, V> + Orig + Neg<P> + PartialEq + Mul<N, P> + Div<N, P>>
impl<N, V, P: PntAsVec<V> + Dim + Sub<P, V> + Add<V, P> + Orig + Neg<P> + PartialEq + Mul<N, P> + Div<N, P>>
AnyPnt<N, V> for P { }
impl<N: Float, V: Norm<N>, P: AnyPnt<N, V>> FloatPnt<N, V> for P { }
impl<N, V, P: AnyPnt<N, V> + Indexable<uint, N> + Iterable<N> + ScalarAdd<N> + ScalarSub<N> + Bounded>