changed point/vector to not take tuples in
This commit is contained in:
@@ -4,14 +4,14 @@ extern crate approx;
|
||||
use std::f32;
|
||||
|
||||
type PointVector = (f32, f32, f32, f32);
|
||||
type Dimensions = (f32, f32, f32);
|
||||
|
||||
fn point(dims: Dimensions) -> PointVector {
|
||||
(dims.0, dims.1, dims.2, 1.0)
|
||||
fn point(x: f32, y: f32, z: f32) -> PointVector {
|
||||
(x, y, z, 1.0)
|
||||
}
|
||||
|
||||
fn vector(dims: Dimensions) -> PointVector {
|
||||
(dims.0, dims.1, dims.2, 0.0)
|
||||
|
||||
fn vector(x: f32, y: f32, z: f32) -> PointVector {
|
||||
(x, y, z, 0.0)
|
||||
}
|
||||
|
||||
fn tuple_x(tuple: PointVector) -> f32 {
|
||||
@@ -58,7 +58,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn create_point() {
|
||||
let point = point((4.0, -4.0, 3.0));
|
||||
let point = point(4.0, -4.0, 3.0);
|
||||
assert_eq!(true, tuple_is_point(point));
|
||||
}
|
||||
|
||||
@@ -75,28 +75,28 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn create_vector() {
|
||||
let vector = vector((4.0, -4.0, 3.0));
|
||||
let vector = vector(4.0, -4.0, 3.0);
|
||||
assert_eq!(true, tuple_is_vector(vector));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuples_equal() {
|
||||
let lhs = point((1.0, 2.0, 3.0));
|
||||
let rhs = point((1.0, 2.0, 3.0));
|
||||
let lhs = point(1.0, 2.0, 3.0);
|
||||
let rhs = point(1.0, 2.0, 3.0);
|
||||
assert_eq!(true, tuple_equals(lhs, rhs));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuples_relative_equal() {
|
||||
let lhs = point((1.0000001, 2.0, 3.0));
|
||||
let rhs = point((1.0, 2.0, 3.0));
|
||||
let lhs = point(1.0000001, 2.0, 3.0);
|
||||
let rhs = point(1.0, 2.0, 3.0);
|
||||
assert_eq!(true, tuple_equals(lhs, rhs));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuples_not_equal() {
|
||||
let lhs = point((1.0, 2.0, 3.0));
|
||||
let rhs = vector((1.0, 2.0, 3.0));
|
||||
let lhs = point(1.0, 2.0, 3.0);
|
||||
let rhs = vector(1.0, 2.0, 3.0);
|
||||
assert_eq!(false, tuple_equals(lhs, rhs));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user