Skip to content

Commit

Permalink
Merge pull request #443 from brendanzab/v0.16
Browse files Browse the repository at this point in the history
Release v0.16
  • Loading branch information
brendanzab committed Jan 5, 2018
2 parents d1cda89 + ae9164d commit 863d21b
Show file tree
Hide file tree
Showing 25 changed files with 1,437 additions and 691 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.16.0] - 2018-01-03

### Added

- Add `InnerSpace::project_on`
- Add `Array::len`
- Re-export `Bounded` and implement for vectors, points, and angles
- Add vector subtraction to `EuclideanSpace`
- Add swizzle functions behinde that `"swizzle"` feature
- Add `Matrix4::look_at_dir`

### Changed

- Return `Option` from cast functions

## [v0.15.0] - 2017-07-30

### Added
Expand Down Expand Up @@ -274,7 +289,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## v0.0.1 - 2014-06-24

[Unreleased]: https://github.com/brendanzab/cgmath/compare/v0.15.0...HEAD
[Unreleased]: https://github.com/brendanzab/cgmath/compare/v0.16.0...HEAD
[v0.16.0]: https://github.com/brendanzab/cgmath/compare/v0.15.0...v0.16.0
[v0.15.0]: https://github.com/brendanzab/cgmath/compare/v0.14.1...v0.15.0
[v0.14.1]: https://github.com/brendanzab/cgmath/compare/v0.14.0...v0.14.1
[v0.14.0]: https://github.com/brendanzab/cgmath/compare/v0.13.1...v0.14.0
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
@@ -1,7 +1,7 @@
[package]

name = "cgmath"
version = "0.15.0"
version = "0.16.0"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>"]
license = "Apache-2.0"
description = "A linear algebra and mathematics library for computer graphics."
Expand All @@ -22,12 +22,12 @@ swizzle = []

[dependencies]
approx = "0.1"
mint = { version = "0.4.1", optional = true }
mint = { version = "0.5", optional = true }
num-traits = "0.1"
rand = "0.4"
serde = { version = "1.0", features = ["serde_derive"], optional = true }
simd = { version = "0.2", optional = true }

[dev-dependencies]
glium = "0.17"
glium = "0.19"
serde_json = "1.0"
28 changes: 21 additions & 7 deletions benches/construction.rs
Expand Up @@ -15,16 +15,17 @@

#![feature(test)]

extern crate cgmath;
extern crate rand;
extern crate test;
extern crate cgmath;

use rand::{IsaacRng, Rng};
use test::Bencher;
use cgmath::*;

#[path="common/macros.rs"]
#[macro_use] mod macros;
#[path = "common/macros.rs"]
#[macro_use]
mod macros;

fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
const LEN: usize = 1 << 13;
Expand All @@ -39,7 +40,8 @@ fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
i = (i + 1) & (LEN - 1);

unsafe {
let res: T = Rotation3::from_axis_angle(*axis.get_unchecked(i), *angle.get_unchecked(i));
let res: T =
Rotation3::from_axis_angle(*axis.get_unchecked(i), *angle.get_unchecked(i));
test::black_box(res)
}
})
Expand All @@ -55,7 +57,19 @@ fn _bench_rot3_from_axisangle(bh: &mut Bencher) {
bench_from_axis_angle::<Basis3<f32>>(bh)
}

bench_construction!(_bench_rot2_from_axisangle, Basis2<f32>, Basis2::from_angle [ angle: Rad<f32> ]);
bench_construction!(
_bench_rot2_from_axisangle,
Basis2<f32>,
Basis2::from_angle[angle: Rad<f32>]
);

bench_construction!(_bench_quat_from_euler_angles, Quaternion<f32>, Quaternion::from [src: Euler<Rad<f32>>]);
bench_construction!(_bench_rot3_from_euler_angles, Basis3<f32>, Basis3::from [src: Euler<Rad<f32>>]);
bench_construction!(
_bench_quat_from_euler_angles,
Quaternion<f32>,
Quaternion::from[src: Euler<Rad<f32>>]
);
bench_construction!(
_bench_rot3_from_euler_angles,
Basis3<f32>,
Basis3::from[src: Euler<Rad<f32>>]
);
7 changes: 4 additions & 3 deletions benches/mat.rs
Expand Up @@ -15,18 +15,19 @@

#![feature(test)]

extern crate cgmath;
extern crate rand;
extern crate test;
extern crate cgmath;

use rand::{IsaacRng, Rng};
use std::ops::*;
use test::Bencher;

use cgmath::*;

#[path="common/macros.rs"]
#[macro_use] mod macros;
#[path = "common/macros.rs"]
#[macro_use]
mod macros;

bench_binop!(_bench_matrix2_mul_m, Matrix2<f32>, Matrix2<f32>, mul);
bench_binop!(_bench_matrix3_mul_m, Matrix3<f32>, Matrix3<f32>, mul);
Expand Down
7 changes: 4 additions & 3 deletions benches/quat.rs
Expand Up @@ -15,18 +15,19 @@

#![feature(test)]

extern crate cgmath;
extern crate rand;
extern crate test;
extern crate cgmath;

use rand::{IsaacRng, Rng};
use std::ops::*;
use test::Bencher;

use cgmath::*;

#[path="common/macros.rs"]
#[macro_use] mod macros;
#[path = "common/macros.rs"]
#[macro_use]
mod macros;

bench_binop!(_bench_quat_add_q, Quaternion<f32>, Quaternion<f32>, add);
bench_binop!(_bench_quat_sub_q, Quaternion<f32>, Quaternion<f32>, sub);
Expand Down
7 changes: 4 additions & 3 deletions benches/vec.rs
Expand Up @@ -15,18 +15,19 @@

#![feature(test)]

extern crate cgmath;
extern crate rand;
extern crate test;
extern crate cgmath;

use rand::{IsaacRng, Rng};
use std::ops::*;
use test::Bencher;

use cgmath::*;

#[path="common/macros.rs"]
#[macro_use] mod macros;
#[path = "common/macros.rs"]
#[macro_use]
mod macros;

bench_binop!(_bench_vector2_add_v, Vector2<f32>, Vector2<f32>, add);
bench_binop!(_bench_vector3_add_v, Vector3<f32>, Vector3<f32>, add);
Expand Down
10 changes: 8 additions & 2 deletions src/angle.rs
Expand Up @@ -45,14 +45,20 @@ pub struct Rad<S>(pub S);
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Deg<S>(pub S);

impl<S> From<Rad<S>> for Deg<S> where S: BaseFloat {
impl<S> From<Rad<S>> for Deg<S>
where
S: BaseFloat,
{
#[inline]
fn from(rad: Rad<S>) -> Deg<S> {
Deg(rad.0 * cast(180.0 / f64::consts::PI).unwrap())
}
}

impl<S> From<Deg<S>> for Rad<S> where S: BaseFloat {
impl<S> From<Deg<S>> for Rad<S>
where
S: BaseFloat,
{
#[inline]
fn from(deg: Deg<S>) -> Rad<S> {
Rad(deg.0 * cast(f64::consts::PI / 180.0).unwrap())
Expand Down
21 changes: 12 additions & 9 deletions src/euler.rs
Expand Up @@ -75,8 +75,7 @@ use num::BaseFloat;
/// [gimbal lock]: https://en.wikipedia.org/wiki/Gimbal_lock#Gimbal_lock_in_applied_mathematics
/// [convert]: #defining-rotations-using-euler-angles
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[derive(PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Euler<A: Angle> {
/// The angle to apply around the _x_ axis. Also known at the _pitch_.
Expand Down Expand Up @@ -162,23 +161,27 @@ impl<A: Angle> ApproxEq for Euler<A> {

#[inline]
fn relative_eq(&self, other: &Self, epsilon: A::Epsilon, max_relative: A::Epsilon) -> bool {
A::relative_eq(&self.x, &other.x, epsilon, max_relative) &&
A::relative_eq(&self.y, &other.y, epsilon, max_relative) &&
A::relative_eq(&self.z, &other.z, epsilon, max_relative)
A::relative_eq(&self.x, &other.x, epsilon, max_relative)
&& A::relative_eq(&self.y, &other.y, epsilon, max_relative)
&& A::relative_eq(&self.z, &other.z, epsilon, max_relative)
}

#[inline]
fn ulps_eq(&self, other: &Self, epsilon: A::Epsilon, max_ulps: u32) -> bool {
A::ulps_eq(&self.x, &other.x, epsilon, max_ulps) &&
A::ulps_eq(&self.y, &other.y, epsilon, max_ulps) &&
A::ulps_eq(&self.z, &other.z, epsilon, max_ulps)
A::ulps_eq(&self.x, &other.x, epsilon, max_ulps)
&& A::ulps_eq(&self.y, &other.y, epsilon, max_ulps)
&& A::ulps_eq(&self.z, &other.z, epsilon, max_ulps)
}
}

impl<A: Angle + Rand> Rand for Euler<A> {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> Euler<A> {
Euler { x: rng.gen(), y: rng.gen(), z: rng.gen() }
Euler {
x: rng.gen(),
y: rng.gen(),
z: rng.gen(),
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Expand Up @@ -58,8 +58,8 @@ extern crate approx;
#[cfg(feature = "mint")]
pub extern crate mint;

pub extern crate num_traits;
extern crate rand;
pub extern crate num_traits;

#[cfg(feature = "serde")]
#[macro_use]
Expand All @@ -76,7 +76,7 @@ pub use structure::*;

pub use matrix::{Matrix2, Matrix3, Matrix4};
pub use quaternion::Quaternion;
pub use vector::{Vector1, Vector2, Vector3, Vector4, dot, vec1, vec2, vec3, vec4};
pub use vector::{dot, Vector1, Vector2, Vector3, Vector4, vec1, vec2, vec3, vec4};

pub use angle::{Deg, Rad};
pub use euler::Euler;
Expand Down

0 comments on commit 863d21b

Please sign in to comment.