commit
182f7b41dc
40 changed files with 213 additions and 181 deletions
|
@ -26,3 +26,6 @@ after_script:
|
|||
# the doc directory needs to be in the root for rust-ci
|
||||
- mv target/doc doc
|
||||
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
|
||||
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
sudo: false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ macro_rules! bench_binop(
|
|||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
|
||||
let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect();
|
||||
let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect();
|
||||
let elems1: Vec<$t1> = (0..LEN).map(|_| rng.gen::<$t1>()).collect();
|
||||
let elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect();
|
||||
let mut i = 0;
|
||||
|
||||
bh.iter(|| {
|
||||
|
@ -44,8 +44,8 @@ macro_rules! bench_binop_deref(
|
|||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
|
||||
let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect();
|
||||
let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect();
|
||||
let elems1: Vec<$t1> = (0..LEN).map(|_| rng.gen::<$t1>()).collect();
|
||||
let elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect();
|
||||
let mut i = 0;
|
||||
|
||||
bh.iter(|| {
|
||||
|
@ -67,7 +67,7 @@ macro_rules! bench_unop(
|
|||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
|
||||
let mut elems: Vec<$t> = range(0, LEN).map(|_| rng.gen::<$t>()).collect();
|
||||
let mut elems: Vec<$t> = (0..LEN).map(|_| rng.gen::<$t>()).collect();
|
||||
let mut i = 0;
|
||||
|
||||
bh.iter(|| {
|
||||
|
@ -89,7 +89,7 @@ macro_rules! bench_construction(
|
|||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
|
||||
$(let $args: Vec<$types> = range(0, LEN).map(|_| rng.gen::<$types>()).collect();)*
|
||||
$(let $args: Vec<$types> = (0..LEN).map(|_| rng.gen::<$types>()).collect();)*
|
||||
let mut i = 0;
|
||||
|
||||
bh.iter(|| {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@ extern crate test;
|
|||
extern crate cgmath;
|
||||
|
||||
use rand::{IsaacRng, Rng};
|
||||
use std::iter;
|
||||
use test::Bencher;
|
||||
use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad};
|
||||
|
||||
|
@ -32,8 +31,8 @@ fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
|
|||
|
||||
let mut rng = IsaacRng::new_unseeded();
|
||||
|
||||
let axis: Vec<_> = iter::range(0, LEN).map(|_| rng.gen::<Vector3<f32>>()).collect();
|
||||
let angle: Vec<_> = iter::range(0, LEN).map(|_| rng.gen::<Rad<f32>>()).collect();
|
||||
let axis: Vec<_> = (0..LEN).map(|_| rng.gen::<Vector3<f32>>()).collect();
|
||||
let angle: Vec<_> = (0..LEN).map(|_| rng.gen::<Rad<f32>>()).collect();
|
||||
let mut i = 0;
|
||||
|
||||
bh.iter(|| {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -201,8 +201,7 @@ impl<S: BaseNum> fmt::Debug for Aabb3<S> {
|
|||
|
||||
impl<S: BaseFloat> Intersect<Option<Point2<S>>> for (Ray2<S>, Aabb2<S>) {
|
||||
fn intersection(&self) -> Option<Point2<S>> {
|
||||
match *self {
|
||||
(ref ray, ref aabb) => {
|
||||
let (ref ray, ref aabb) = *self;
|
||||
|
||||
let mut tmin: S = Float::neg_infinity();
|
||||
let mut tmax: S = Float::infinity();
|
||||
|
@ -239,8 +238,6 @@ impl<S: BaseFloat> Intersect<Option<Point2<S>>> for (Ray2<S>, Aabb2<S>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat + 'static> Bound<S> for Aabb3<S> {
|
||||
fn relate_plane(&self, plane: &Plane<S>) -> Relation {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013 The OMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
10
src/line.rs
10
src/line.rs
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -38,11 +38,11 @@ impl<S: BaseNum, V: Vector<S>, P: Point<S, V>> Line<P> {
|
|||
pub type Line2<S> = Line<Point2<S>>;
|
||||
pub type Line3<S> = Line<Point3<S>>;
|
||||
|
||||
/// Determines if an intersection between a ray and a line segments is found.
|
||||
/// Determines if an intersection between a ray and a line segment is found.
|
||||
impl<S: BaseFloat> Intersect<Option<Point2<S>>> for (Ray2<S>, Line2<S>) {
|
||||
fn intersection(&self) -> Option<Point2<S>> {
|
||||
match *self {
|
||||
(ref ray, ref line) => {
|
||||
let (ref ray, ref line) = *self;
|
||||
|
||||
let p = ray.origin;
|
||||
let q = line.origin;
|
||||
let r = ray.direction;
|
||||
|
@ -89,5 +89,3 @@ impl<S: BaseFloat> Intersect<Option<Point2<S>>> for (Ray2<S>, Line2<S>) {
|
|||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -1344,8 +1344,8 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
|||
// http://www.cs.ucr.edu/~vbz/resources/quatut.pdf
|
||||
let trace = self.trace();
|
||||
let half: S = cast(0.5f64).unwrap();
|
||||
match () {
|
||||
() if trace >= zero::<S>() => {
|
||||
|
||||
if trace >= zero::<S>() {
|
||||
let s = (one::<S>() + trace).sqrt();
|
||||
let w = half * s;
|
||||
let s = half / s;
|
||||
|
@ -1353,8 +1353,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
|||
let y = (self[2][0] - self[0][2]) * s;
|
||||
let z = (self[0][1] - self[1][0]) * s;
|
||||
Quaternion::new(w, x, y, z)
|
||||
}
|
||||
() if (self[0][0] > self[1][1]) && (self[0][0] > self[2][2]) => {
|
||||
} else if (self[0][0] > self[1][1]) && (self[0][0] > self[2][2]) {
|
||||
let s = (half + (self[0][0] - self[1][1] - self[2][2])).sqrt();
|
||||
let w = half * s;
|
||||
let s = half / s;
|
||||
|
@ -1362,8 +1361,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
|||
let y = (self[2][0] - self[0][2]) * s;
|
||||
let z = (self[1][2] - self[2][1]) * s;
|
||||
Quaternion::new(w, x, y, z)
|
||||
}
|
||||
() if self[1][1] > self[2][2] => {
|
||||
} else if self[1][1] > self[2][2] {
|
||||
let s = (half + (self[1][1] - self[0][0] - self[2][2])).sqrt();
|
||||
let w = half * s;
|
||||
let s = half / s;
|
||||
|
@ -1371,8 +1369,7 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
|||
let y = (self[1][2] - self[2][1]) * s;
|
||||
let z = (self[2][0] - self[0][2]) * s;
|
||||
Quaternion::new(w, x, y, z)
|
||||
}
|
||||
() => {
|
||||
} else {
|
||||
let s = (half + (self[2][2] - self[0][0] - self[1][1])).sqrt();
|
||||
let w = half * s;
|
||||
let s = half / s;
|
||||
|
@ -1383,7 +1380,6 @@ impl<S: BaseFloat + 'static> ToQuaternion<S> for Matrix3<S> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseNum> fmt::Debug for Matrix2<S> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -111,15 +111,13 @@ impl<S: BaseFloat> Plane<S> {
|
|||
|
||||
impl<S: BaseFloat> Intersect<Option<Point3<S>>> for (Plane<S>, Ray3<S>) {
|
||||
fn intersection(&self) -> Option<Point3<S>> {
|
||||
match *self {
|
||||
(ref p, ref r) => {
|
||||
let (ref p, ref r) = *self;
|
||||
|
||||
let t = -(p.d + r.origin.dot(&p.n)) / r.direction.dot(&p.n);
|
||||
if t < Zero::zero() { None }
|
||||
else { Some(r.origin.add_v(&r.direction.mul_s(t))) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> Intersect<Option<Ray3<S>>> for (Plane<S>, Plane<S>) {
|
||||
fn intersection(&self) -> Option<Ray3<S>> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directionectory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -132,7 +132,7 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
|
|||
/// angle. We can accomplish this quite easily with a two-dimensional rotation
|
||||
/// matrix:
|
||||
///
|
||||
/// ~~~ignore
|
||||
/// ```no_run
|
||||
/// use cgmath::rad;
|
||||
/// use cgmath::Vector2;
|
||||
/// use cgmath::{Matrix, ToMatrix2};
|
||||
|
@ -160,7 +160,7 @@ pub trait Rotation3<S: BaseNum>: Rotation<S, Vector3<S>, Point3<S>>
|
|||
/// let rot_half: Basis2<f64> = Rotation2::from_angle(rad(0.25f64 * f64::consts::PI));
|
||||
/// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x);
|
||||
/// assert!(unit_y3.approx_eq(&unit_y2));
|
||||
/// ~~~
|
||||
/// ```
|
||||
#[derive(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Basis2<S> {
|
||||
mat: Matrix2<S>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -31,8 +31,8 @@ pub struct Sphere<S> {
|
|||
|
||||
impl<S: BaseFloat> Intersect<Option<Point3<S>>> for (Sphere<S>, Ray3<S>) {
|
||||
fn intersection(&self) -> Option<Point3<S>> {
|
||||
match *self {
|
||||
(ref s, ref r) => {
|
||||
let (ref s, ref r) = *self;
|
||||
|
||||
let l = s.center.sub_p(&r.origin);
|
||||
let tca = l.dot(&r.direction);
|
||||
if tca < zero() { return None; }
|
||||
|
@ -42,8 +42,6 @@ impl<S: BaseFloat> Intersect<Option<Point3<S>>> for (Sphere<S>, Ray3<S>) {
|
|||
Some(r.origin.add_v(&r.direction.mul_s(tca - thc)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseFloat + 'static> Bound<S> for Sphere<S> {
|
||||
fn relate_plane(&self, plane: &Plane<S>) -> Relation {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ fn macro_assert_approx_eq_eps() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[should_panic]
|
||||
fn macro_assert_approx_eq_eps_fail() {
|
||||
assert_approx_eq_eps!(1.0f32, 1.02, 0.01);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ fn macro_assert_approx_eq() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[should_fail]
|
||||
#[should_panic]
|
||||
fn macro_assert_approx_eq_fail() {
|
||||
assert_approx_eq!(1.0f64 / 3.0, 0.333);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
43
tests/rotation.rs
Normal file
43
tests/rotation.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2015 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
extern crate cgmath;
|
||||
|
||||
use cgmath::*;
|
||||
|
||||
mod rotation {
|
||||
use super::cgmath::*;
|
||||
|
||||
pub fn a2<R: Rotation2<f64>>() -> R {
|
||||
Rotation2::from_angle(deg(30.0).to_rad())
|
||||
}
|
||||
|
||||
pub fn a3<R: Rotation3<f64>>() -> R {
|
||||
let axis = Vector3::new(1.0, 1.0, 0.0).normalize();
|
||||
Rotation3::from_axis_angle(&axis, deg(30.0).to_rad())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invert_basis2() {
|
||||
let a: Basis2<_> = rotation::a2();
|
||||
assert!(a.concat(&a.invert()).as_matrix2().is_identity());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invert_basis3() {
|
||||
let a: Basis3<_> = rotation::a3();
|
||||
assert!(a.concat(&a.invert()).as_matrix3().is_identity());
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
// refer to the Cargo.toml file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
|
Loading…
Reference in a new issue