Moved all the 3d math stuff into its own module.
This commit is contained in:
parent
b9d0860957
commit
e239f5aaaf
|
@ -1,10 +1,6 @@
|
||||||
mod math;
|
mod math;
|
||||||
mod lerp;
|
mod lerp;
|
||||||
mod float4;
|
mod float4;
|
||||||
mod vector;
|
|
||||||
mod point;
|
|
||||||
mod normal;
|
|
||||||
mod matrix;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
mod vector;
|
||||||
|
mod normal;
|
||||||
|
mod point;
|
||||||
|
mod matrix;
|
||||||
|
|
||||||
|
pub use self::vector::Vector;
|
||||||
|
pub use self::normal::Normal;
|
||||||
|
pub use self::point::Point;
|
||||||
|
pub use self::matrix::Matrix4x4;
|
||||||
|
|
||||||
/// Trait for calculating dot products.
|
/// Trait for calculating dot products.
|
||||||
pub trait DotProduct
|
pub trait DotProduct
|
||||||
{
|
{
|
|
@ -4,9 +4,10 @@ use std::ops::{Index, IndexMut, Add, Sub, Mul, Div};
|
||||||
use std::cmp::PartialEq;
|
use std::cmp::PartialEq;
|
||||||
|
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use math::{DotProduct, CrossProduct};
|
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
use matrix::Matrix4x4;
|
|
||||||
|
use super::{DotProduct, CrossProduct};
|
||||||
|
use super::Matrix4x4;
|
||||||
|
|
||||||
/// A surface normal in 3d homogeneous space.
|
/// A surface normal in 3d homogeneous space.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -138,9 +139,8 @@ impl CrossProduct for Normal {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use math::*;
|
use super::super::{Matrix4x4, CrossProduct, DotProduct};
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use matrix::Matrix4x4;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add() {
|
fn add() {
|
|
@ -5,8 +5,9 @@ use std::cmp::PartialEq;
|
||||||
|
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
use vector::Vector;
|
|
||||||
use matrix::Matrix4x4;
|
use super::Vector;
|
||||||
|
use super::Matrix4x4;
|
||||||
|
|
||||||
/// A position in 3d homogeneous space.
|
/// A position in 3d homogeneous space.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -96,9 +97,8 @@ impl Lerp for Point {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use vector::Vector;
|
use super::super::{Vector, Matrix4x4};
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use matrix::Matrix4x4;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn norm() {
|
fn norm() {
|
|
@ -4,9 +4,10 @@ use std::ops::{Index, IndexMut, Add, Sub, Mul, Div};
|
||||||
use std::cmp::PartialEq;
|
use std::cmp::PartialEq;
|
||||||
|
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use math::{DotProduct, CrossProduct};
|
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
use matrix::Matrix4x4;
|
|
||||||
|
use super::{DotProduct, CrossProduct};
|
||||||
|
use super::Matrix4x4;
|
||||||
|
|
||||||
/// A direction vector in 3d homogeneous space.
|
/// A direction vector in 3d homogeneous space.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -138,9 +139,8 @@ impl CrossProduct for Vector {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use math::*;
|
use super::super::{Matrix4x4, CrossProduct, DotProduct};
|
||||||
use lerp::Lerp;
|
use lerp::Lerp;
|
||||||
use matrix::Matrix4x4;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add() {
|
fn add() {
|
Loading…
Reference in New Issue
Block a user