aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: 0e6674d57665d8777c5dffee68b06e00c958db9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pub mod core;
pub mod camera;
pub mod render;
pub mod world;
pub mod trace;
pub mod sample;
pub mod material;

use std::ops::{Add, Sub, Mul, DivAssign, AddAssign, Neg, Div};
use std::cmp;
use std::fmt;
use std::f64::consts::PI;

/// Trait used to implement generics
///
/// This is used in Bound and Vectors
pub trait Number:
    Copy +
    cmp::PartialOrd +
    Sub<Output = Self> +
    Add<Output = Self> +
    Mul<Output = Self> +
    Neg<Output = Self> + 
    Div<Output = Self> +
    DivAssign +
    AddAssign +
    fmt::Display
{}

impl Number for i32 {}
impl Number for f32 {}
impl Number for f64 {}

/// Used for representing floating point values throughout the program
/// 
/// A higher precision type will require more ram
pub type Float = f64;

pub const M_PI: Float = PI;
pub const NEAR_ZERO: Float = 1e-8;
pub const INFTY: Float = f64::INFINITY;