Move contents of geom and core modules into new math module

Having these two modules separate made more sense when the library was divided into lmath and cgmath. Now that the two have been combined, it makes more sense to bundle these types in one module (I think).
This commit is contained in:
Brendan Zabarauskas 2013-07-14 11:44:50 +10:00
parent 3ce6578d56
commit d5514fc982
25 changed files with 101 additions and 84 deletions

View file

@ -22,7 +22,7 @@ SRC_CRATE = $(TARGET).rs
EXTERN_DIR = $(ROOT_DIR)/extern
BUILD_DIR = $(ROOT_DIR)/lib
CFG = --cfg=bounds --cfg=color --cfg=geom --cfg=noise --cfg=transform --cfg=space
CFG = --cfg=bounds --cfg=color --cfg=noise --cfg=transform --cfg=space
TEST = $(TARGET)
TEST_BUILD_DIR = $(ROOT_DIR)/test

View file

@ -15,8 +15,7 @@
//! Axis-aligned bounding boxes
use core::*;
use geom::*;
use math::*;
#[deriving(Clone, Eq)]
pub struct AABB2<T> {

View file

@ -13,6 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Bounding volumes
pub use self::aabb::{AABB2, AABB3};
pub use self::frustum::{Frustum, FrustumPoints};
pub use self::sphere::Sphere;

View file

@ -13,4 +13,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Bounding boxes
//! Oriented bounding boxes
use math::*;
#[deriving(Clone, Eq)]
pub struct Box2<T> {
center: Point2<T>,
axis: Vec2<T>,
extents: Vec2<T>,
}
#[deriving(Clone, Eq)]
pub struct Box3<T> {
center: Point3<T>,
axis: Vec3<T>,
extents: Vec3<T>,
}

View file

@ -13,4 +13,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Bounding cylinder
//! Oriented bounding cylinder
use math::*;
#[deriving(Clone, Eq)]
pub struct Cylinder3<T> {
center: Point3<T>,
axis: Vec3<T>,
radius: T,
}

View file

@ -13,8 +13,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::*;
use geom::*;
//! View frustum for visibility determination
use math::*;
#[deriving(Clone, Eq)]
pub struct Frustum<T> {

View file

@ -15,7 +15,7 @@
//! Bounding sphere
use geom::*;
use math::*;
#[deriving(Clone, Eq)]
pub struct Sphere<T> {

View file

@ -16,7 +16,7 @@
use std::num;
use std::cast;
use core::*;
use math::*;
use color::{Color, FloatColor};
use color::{Channel, FloatChannel};

View file

@ -16,7 +16,7 @@
use std::num;
use std::cast;
use core::*;
use math::*;
use color::{Color, FloatColor};
use color::{Channel, FloatChannel};

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::*;
use math::*;
#[deriving(Clone, Eq)]
pub struct SRGB<T> { r: T, g: T, b: T }

View file

@ -15,7 +15,7 @@
// http://en.wikipedia.org/wiki/YCbCr
use core::*;
use math::*;
#[deriving(Clone, Eq)]
pub struct YCbCr<T> { y: T, cb: T, cr: T }

View file

@ -1,24 +0,0 @@
// Copyright 2013 The Lmath Developers. For a full listing of the authors,
// refer to the AUTHORS 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.
pub use self::plane::Plane3;
pub use self::point::Point;
pub use self::point::{Point2, AsPoint2};
pub use self::point::{Point3, AsPoint3};
pub use self::ray::{Ray2, Ray3};
pub mod plane;
pub mod point;
pub mod ray;

View file

@ -26,11 +26,11 @@
// Macros
mod macros;
#[path = "core/macros.rs"]
mod core_macros;
#[path = "math/macros.rs"]
mod math_macros;
#[path = "core/core.rs"]
pub mod core;
#[path = "math/math.rs"]
pub mod math;
#[cfg(bounds)]
#[path = "bounds/bounds.rs"]
@ -40,10 +40,6 @@ pub mod bounds;
#[path = "color/color.rs"]
pub mod color;
#[cfg(geom)]
#[path = "geom/geom.rs"]
pub mod geom;
#[cfg(noise)]
#[path = "noise/noise.rs"]
pub mod noise;

View file

@ -13,9 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::{Dimensional, Swap};
use core::{Quat, ToQuat};
use core::{Vec2, Vec3, Vec4};
//! Matrix types
use math::{Dimensional, Swap};
use math::{Quat, ToQuat};
use math::{Vec2, Vec3, Vec4};
pub trait Mat<T,Vec,Slice>: Dimensional<Vec,Slice> + Swap {
pub fn col<'a>(&'a self, i: uint) -> &'a Vec;
@ -330,8 +332,8 @@ impl<T:Clone + Float> FloatMat<T,Vec3<T>,[Vec3<T>,..3]> for Mat2<T> {
#[cfg(test)]
mod mat2_tests{
use core::mat::*;
use core::vec::*;
use math::mat::*;
use math::vec::*;
static A: Mat2<float> = Mat2 { x: Vec2 { x: 1.0, y: 3.0 },
y: Vec2 { x: 2.0, y: 4.0 } };
@ -950,8 +952,8 @@ impl<T:Clone + Float> FloatMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat3<T> {
#[cfg(test)]
mod mat3_tests{
use core::mat::*;
use core::vec::*;
use math::mat::*;
use math::vec::*;
static A: Mat3<float> = Mat3 { x: Vec3 { x: 1.0, y: 4.0, z: 7.0 },
y: Vec3 { x: 2.0, y: 5.0, z: 8.0 },
@ -1546,8 +1548,8 @@ impl<T:Clone + Float> FloatMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat4<T> {
#[cfg(test)]
mod mat4_tests {
use core::mat::*;
use core::vec::*;
use math::mat::*;
use math::vec::*;
static A: Mat4<float> = Mat4 { x: Vec4 { x: 1.0, y: 5.0, z: 9.0, w: 13.0 },
y: Vec4 { x: 2.0, y: 6.0, z: 10.0, w: 14.0 },

View file

@ -26,10 +26,20 @@ pub use self::vec::{Vec2, ToVec2, AsVec2};
pub use self::vec::{Vec3, ToVec3, AsVec3};
pub use self::vec::{Vec4, ToVec4, AsVec4};
pub use self::plane::Plane3;
pub use self::point::Point;
pub use self::point::{Point2, AsPoint2};
pub use self::point::{Point3, AsPoint3};
pub use self::ray::{Ray2, Ray3};
pub mod mat;
pub mod quat;
pub mod vec;
pub mod plane;
pub mod point;
pub mod ray;
pub trait Dimensional<T,Slice> {
pub fn index<'a>(&'a self, i: uint) -> &'a T;
pub fn index_mut<'a>(&'a mut self, i: uint) -> &'a mut T;

View file

@ -13,11 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::*;
//! Three-dimensional plane type
use geom::Point;
use geom::Point3;
use geom::Ray3;
use math::{Vec3, Vec4, Mat3};
use math::{Point, Point3};
use math::Ray3;
/// A plane formed from the equation: `Ax + Bx + Cx + D = 0`
///
@ -157,8 +157,8 @@ impl<T> ToStr for Plane3<T> {
#[cfg(test)]
mod tests {
use geom::plane::*;
use geom::point::*;
use math::plane::*;
use math::point::*;
#[test]
fn test_from_3p() {

View file

@ -22,10 +22,12 @@
use std::cast;
use core::*;
use geom::Ray2;
use geom::Ray3;
use math::{Dimensional, Swap};
use math::{Mat2, Mat3, Quat};
use math::{Ray2, Ray3};
use math::{Vec2, ToVec2, AsVec2};
use math::{Vec3, ToVec3, AsVec3};
use math::{Vec4, ToVec4};
/// A geometric point
pub trait Point<T, Vec, Ray>: Eq
@ -174,7 +176,7 @@ impl<T> ToStr for Point2<T> {
#[cfg(test)]
mod test_point2 {
use geom::point::*;
use math::point::*;
#[test]
fn test_to_str() {
@ -317,7 +319,7 @@ impl<T> ToStr for Point3<T> {
#[cfg(test)]
mod test_point3 {
use geom::point::*;
use math::point::*;
#[test]
fn test_to_str() {

View file

@ -13,9 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::{Dimensional, Swap};
use core::{Mat3, ToMat3};
use core::Vec3;
//! Quaternion type
use math::{Dimensional, Swap};
use math::{Mat3, ToMat3};
use math::Vec3;
// GLSL-style type aliases
@ -306,9 +308,9 @@ impl<T:Clone + Float> Quat<T> {
#[cfg(test)]
mod tests {
use core::mat::*;
use core::quat::*;
use core::vec::*;
use math::mat::*;
use math::quat::*;
use math::vec::*;
#[test]
fn test_from_angle_axis() {

View file

@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::*;
//! Ray types
use geom::Point2;
use geom::Point3;
use math::{Point2, Point3};
use math::{Vec2, Vec3};
#[deriving(Clone, Eq)]
pub struct Ray2<T> {

View file

@ -13,7 +13,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::{Dimensional, Swap};
//! Abstract vector types
use math::{Dimensional, Swap};
pub trait Vec<T,Slice>: Dimensional<T,Slice> + Swap {}
@ -495,7 +497,7 @@ impl<T:Not<T>> Not<Vec2<T>> for Vec2<T> {
#[cfg(test)]
mod vec2_tests {
use core::vec::*;
use math::vec::*;
static A: Vec2<float> = Vec2 { x: 1.0, y: 2.0 };
static B: Vec2<float> = Vec2 { x: 3.0, y: 4.0 };
@ -1086,7 +1088,7 @@ impl<T:Not<T>> Not<Vec3<T>> for Vec3<T> {
#[cfg(test)]
mod vec3_tests{
use core::vec::*;
use math::vec::*;
static A: Vec3<float> = Vec3 { x: 1.0, y: 2.0, z: 3.0 };
static B: Vec3<float> = Vec3 { x: 4.0, y: 5.0, z: 6.0 };
@ -1705,7 +1707,7 @@ impl<T:Not<T>> Not<Vec4<T>> for Vec4<T> {
#[cfg(test)]
mod vec4_tests {
use core::vec::*;
use math::vec::*;
static A: Vec4<float> = Vec4 { x: 1.0, y: 2.0, z: 3.0, w: 4.0 };
static B: Vec4<float> = Vec4 { x: 5.0, y: 6.0, z: 7.0, w: 8.0 };

View file

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use geom::{Point2, Point3};
use math::{Point2, Point3};
pub struct Perlin<T>;

View file

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::Vec4;
use geom::{Point2, Point3};
use math::Vec4;
use math::{Point2, Point3};
pub struct Simplex<T>;

View file

@ -14,8 +14,8 @@
// limitations under the License.
use bounds::Frustum;
use core::Mat4;
use geom::Plane3;
use math::Mat4;
use math::Plane3;
///
/// Create a perspective projection matrix

View file

@ -15,7 +15,7 @@
pub use self::projection::{Projection, Perspective, PerspectiveFOV, Ortho};
use core::{Vec3, Quat};
use math::{Vec3, Quat};
pub mod projection;