Add pub
attributes
This commit is contained in:
parent
3df7d557bd
commit
bf144110b7
4 changed files with 94 additions and 94 deletions
96
src/mat.rs
96
src/mat.rs
|
@ -9,7 +9,7 @@ use vec::*;
|
|||
//
|
||||
// NxN Matrix
|
||||
//
|
||||
trait Matrix<T, V> {
|
||||
pub trait Matrix<T, V> {
|
||||
pure fn rows() -> uint;
|
||||
pure fn cols() -> uint;
|
||||
pure fn is_col_major() -> bool;
|
||||
|
@ -42,7 +42,7 @@ trait Matrix<T, V> {
|
|||
//
|
||||
// 3x3 Matrix
|
||||
//
|
||||
trait Matrix3<V3> {
|
||||
pub trait Matrix3<V3> {
|
||||
pure fn scale(&&vec:V3) -> self;
|
||||
pure fn to_Mat4() -> Mat4;
|
||||
pure fn to_Quat() -> Quat;
|
||||
|
@ -51,7 +51,7 @@ trait Matrix3<V3> {
|
|||
//
|
||||
// 4x4 Matrix
|
||||
//
|
||||
trait Matrix4<V3, V4> {
|
||||
pub trait Matrix4<V3, V4> {
|
||||
pure fn scale(&&vec:V3) -> self; // I don't like the use of `Vec3` here
|
||||
pure fn translate(&&vec:V3) -> self;
|
||||
}
|
||||
|
@ -64,35 +64,35 @@ trait Matrix4<V3, V4> {
|
|||
//
|
||||
// Mat2: A 2x2, column major matrix
|
||||
//
|
||||
struct Mat2 { data:[Vec2 * 2] }
|
||||
pub struct Mat2 { data:[Vec2 * 2] }
|
||||
|
||||
const mat2_zero :Mat2 = Mat2 { data: [ vec2_zero,
|
||||
vec2_zero ] };
|
||||
const mat2_identity :Mat2 = Mat2 { data: [ vec2_unit_x,
|
||||
vec2_unit_y ] };
|
||||
pub const mat2_zero :Mat2 = Mat2 { data: [ vec2_zero,
|
||||
vec2_zero ] };
|
||||
pub const mat2_identity :Mat2 = Mat2 { data: [ vec2_unit_x,
|
||||
vec2_unit_y ] };
|
||||
|
||||
//
|
||||
// Mat2 Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Mat2(m00:float, m01:float,
|
||||
m10:float, m11:float) -> Mat2 {
|
||||
pub pure fn Mat2(m00:float, m01:float,
|
||||
m10:float, m11:float) -> Mat2 {
|
||||
Mat2 { data: [ Vec2(m00, m01),
|
||||
Vec2(m10, m11) ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Construct Mat2 from column vectors
|
||||
// Conpub struct Mat2 from column vectors
|
||||
//
|
||||
#[inline]
|
||||
pure fn mat2_v(col0:Vec2, col1:Vec2) -> Mat2 {
|
||||
pub pure fn Mat2_v(col0:Vec2, col1:Vec2) -> Mat2 {
|
||||
Mat2 { data: [ col0, col1 ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Matrix2x2 Implementation
|
||||
//
|
||||
impl Mat2: Matrix<float, Vec2> {
|
||||
pub impl Mat2: Matrix<float, Vec2> {
|
||||
#[inline]
|
||||
pure fn rows() -> uint { 2 }
|
||||
|
||||
|
@ -120,12 +120,12 @@ impl Mat2: Matrix<float, Vec2> {
|
|||
|
||||
#[inline]
|
||||
pure fn neg() -> Mat2 {
|
||||
mat2_v(-self[0], -self[1])
|
||||
Mat2_v(-self[0], -self[1])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pure fn mul_f(&&value:float) -> Mat2 {
|
||||
mat2_v(self[0].mul_f(value),
|
||||
Mat2_v(self[0].mul_f(value),
|
||||
self[1].mul_f(value))
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,13 @@ impl Mat2: Matrix<float, Vec2> {
|
|||
|
||||
#[inline]
|
||||
pure fn add_m(&&other:Mat2) -> Mat2 {
|
||||
mat2_v(self[0].add_v(other[0]),
|
||||
Mat2_v(self[0].add_v(other[0]),
|
||||
self[1].add_v(other[1]))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pure fn sub_m(&&other:Mat2) -> Mat2 {
|
||||
mat2_v(self[0].sub_v(other[0]),
|
||||
Mat2_v(self[0].sub_v(other[0]),
|
||||
self[1].sub_v(other[1]))
|
||||
}
|
||||
|
||||
|
@ -214,39 +214,39 @@ impl Mat2: Matrix<float, Vec2> {
|
|||
//
|
||||
// Mat3: A 3x3, column major matrix
|
||||
//
|
||||
struct Mat3 { data:[Vec3 * 3] }
|
||||
pub struct Mat3 { data:[Vec3 * 3] }
|
||||
|
||||
const mat3_zero :Mat3 = Mat3 { data: [ vec3_zero,
|
||||
vec3_zero,
|
||||
vec3_zero ] };
|
||||
const mat3_identity :Mat3 = Mat3 { data: [ vec3_unit_x,
|
||||
vec3_unit_y,
|
||||
vec3_unit_z ] };
|
||||
pub const mat3_zero :Mat3 = Mat3 { data: [ vec3_zero,
|
||||
vec3_zero,
|
||||
vec3_zero ] };
|
||||
pub const mat3_identity :Mat3 = Mat3 { data: [ vec3_unit_x,
|
||||
vec3_unit_y,
|
||||
vec3_unit_z ] };
|
||||
|
||||
//
|
||||
// Mat3 Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Mat3(m00:float, m01:float, m02:float,
|
||||
m10:float, m11:float, m12:float,
|
||||
m20:float, m21:float, m22:float) -> Mat3 {
|
||||
pub pure fn Mat3(m00:float, m01:float, m02:float,
|
||||
m10:float, m11:float, m12:float,
|
||||
m20:float, m21:float, m22:float) -> Mat3 {
|
||||
Mat3 { data: [ Vec3(m00, m01, m02),
|
||||
Vec3(m10, m11, m12),
|
||||
Vec3(m20, m21, m22) ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Construct Mat3 from column vectors
|
||||
// Conpub struct Mat3 from column vectors
|
||||
//
|
||||
#[inline]
|
||||
pure fn mat3_v(col0:Vec3, col1:Vec3, col2:Vec3) -> Mat3 {
|
||||
pub pure fn Mat3_v(col0:Vec3, col1:Vec3, col2:Vec3) -> Mat3 {
|
||||
Mat3 { data: [ col0, col1, col2 ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Matrix3x3 Implementation
|
||||
//
|
||||
impl Mat3: Matrix<float, Vec3> {
|
||||
pub impl Mat3: Matrix<float, Vec3> {
|
||||
#[inline]
|
||||
pure fn rows() -> uint { 3 }
|
||||
|
||||
|
@ -275,12 +275,12 @@ impl Mat3: Matrix<float, Vec3> {
|
|||
|
||||
#[inline]
|
||||
pure fn neg() -> Mat3 {
|
||||
mat3_v(-self[0], -self[1], -self[2])
|
||||
Mat3_v(-self[0], -self[1], -self[2])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pure fn mul_f(&&value:float) -> Mat3 {
|
||||
mat3_v(self[0].mul_f(value),
|
||||
Mat3_v(self[0].mul_f(value),
|
||||
self[1].mul_f(value),
|
||||
self[2].mul_f(value))
|
||||
}
|
||||
|
@ -294,14 +294,14 @@ impl Mat3: Matrix<float, Vec3> {
|
|||
|
||||
#[inline]
|
||||
pure fn add_m(&&other:Mat3) -> Mat3 {
|
||||
mat3_v(self[0].add_v(other[0]),
|
||||
Mat3_v(self[0].add_v(other[0]),
|
||||
self[1].add_v(other[1]),
|
||||
self[2].add_v(other[2]))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pure fn sub_m(&&other:Mat3) -> Mat3 {
|
||||
mat3_v(self[0].sub_v(other[0]),
|
||||
Mat3_v(self[0].sub_v(other[0]),
|
||||
self[1].sub_v(other[1]),
|
||||
self[2].sub_v(other[2]))
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ impl Mat3: Matrix<float, Vec3> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Mat3: Matrix3<Vec3> {
|
||||
pub impl Mat3: Matrix3<Vec3> {
|
||||
#[inline]
|
||||
pure fn scale(&&vec:Vec3) -> Mat3 {
|
||||
self.mul_m(Mat3(vec.x(), 0f, 0f,
|
||||
|
@ -451,13 +451,13 @@ impl Mat3: Matrix3<Vec3> {
|
|||
//
|
||||
// Mat4: A 4x4, column major matrix
|
||||
//
|
||||
struct Mat4 { data:[Vec4 * 4] }
|
||||
pub struct Mat4 { data:[Vec4 * 4] }
|
||||
|
||||
const mat4_zero :Mat4 = Mat4 { data: [ vec4_zero,
|
||||
pub const mat4_zero :Mat4 = Mat4 { data: [ vec4_zero,
|
||||
vec4_zero,
|
||||
vec4_zero,
|
||||
vec4_zero ] };
|
||||
const mat4_identity :Mat4 = Mat4 { data: [ vec4_unit_x,
|
||||
pub const mat4_identity :Mat4 = Mat4 { data: [ vec4_unit_x,
|
||||
vec4_unit_y,
|
||||
vec4_unit_z,
|
||||
vec4_unit_w ] };
|
||||
|
@ -466,7 +466,7 @@ const mat4_identity :Mat4 = Mat4 { data: [ vec4_unit_x,
|
|||
// Mat4 Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Mat4(m00:float, m01:float, m02:float, m03:float,
|
||||
pub pure fn Mat4(m00:float, m01:float, m02:float, m03:float,
|
||||
m10:float, m11:float, m12:float, m13:float,
|
||||
m20:float, m21:float, m22:float, m23:float,
|
||||
m30:float, m31:float, m32:float, m33:float) -> Mat4 {
|
||||
|
@ -477,17 +477,17 @@ pure fn Mat4(m00:float, m01:float, m02:float, m03:float,
|
|||
}
|
||||
|
||||
//
|
||||
// Construct Mat4 from column vectors
|
||||
// Conpub struct Mat4 from column vectors
|
||||
//
|
||||
#[inline]
|
||||
pure fn mat4_v(col0:Vec4, col1:Vec4, col2:Vec4, col3:Vec4) -> Mat4 {
|
||||
pub pure fn Mat4_v(col0:Vec4, col1:Vec4, col2:Vec4, col3:Vec4) -> Mat4 {
|
||||
Mat4 { data: [ col0, col1, col2, col3 ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Matrix4x4 Implementation
|
||||
//
|
||||
impl Mat4: Matrix<float, Vec4> {
|
||||
pub impl Mat4: Matrix<float, Vec4> {
|
||||
#[inline]
|
||||
pure fn rows() -> uint { 4 }
|
||||
|
||||
|
@ -517,12 +517,12 @@ impl Mat4: Matrix<float, Vec4> {
|
|||
|
||||
#[inline]
|
||||
pure fn neg() -> Mat4 {
|
||||
mat4_v(-self[0], -self[1], -self[2], -self[3])
|
||||
Mat4_v(-self[0], -self[1], -self[2], -self[3])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pure fn mul_f(&&value:float) -> Mat4 {
|
||||
mat4_v(self[0].mul_f(value),
|
||||
Mat4_v(self[0].mul_f(value),
|
||||
self[1].mul_f(value),
|
||||
self[2].mul_f(value),
|
||||
self[3].mul_f(value))
|
||||
|
@ -538,7 +538,7 @@ impl Mat4: Matrix<float, Vec4> {
|
|||
|
||||
#[inline]
|
||||
pure fn add_m(&&other:Mat4) -> Mat4 {
|
||||
mat4_v(self[0].add_v(other[0]),
|
||||
Mat4_v(self[0].add_v(other[0]),
|
||||
self[1].add_v(other[1]),
|
||||
self[2].add_v(other[2]),
|
||||
self[3].add_v(other[3]))
|
||||
|
@ -546,7 +546,7 @@ impl Mat4: Matrix<float, Vec4> {
|
|||
|
||||
#[inline]
|
||||
pure fn sub_m(&&other:Mat4) -> Mat4 {
|
||||
mat4_v(self[0].sub_v(other[0]),
|
||||
Mat4_v(self[0].sub_v(other[0]),
|
||||
self[1].sub_v(other[1]),
|
||||
self[2].sub_v(other[2]),
|
||||
self[3].sub_v(other[3]))
|
||||
|
@ -657,7 +657,7 @@ impl Mat4: Matrix<float, Vec4> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Mat4: Matrix4<Vec3, Vec4> {
|
||||
pub impl Mat4: Matrix4<Vec3, Vec4> {
|
||||
#[inline]
|
||||
pure fn scale(&&vec:Vec3) -> Mat4 {
|
||||
self.mul_m(Mat4(vec.x(), 0f, 0f, 0f,
|
||||
|
@ -668,7 +668,7 @@ impl Mat4: Matrix4<Vec3, Vec4> {
|
|||
|
||||
#[inline]
|
||||
pure fn translate(&&vec:Vec3) -> Mat4 {
|
||||
mat4_v(self[0],
|
||||
Mat4_v(self[0],
|
||||
self[1],
|
||||
self[2],
|
||||
Vec4(self[3][0] + vec.x(),
|
||||
|
|
10
src/omath.rc
10
src/omath.rc
|
@ -7,8 +7,8 @@
|
|||
|
||||
extern mod std;
|
||||
|
||||
mod mat;
|
||||
mod math;
|
||||
mod projection;
|
||||
mod quat;
|
||||
mod vec;
|
||||
pub mod mat;
|
||||
pub mod math;
|
||||
pub mod projection;
|
||||
pub mod quat;
|
||||
pub mod vec;
|
14
src/quat.rs
14
src/quat.rs
|
@ -11,7 +11,7 @@ use vec::Vec3;
|
|||
//
|
||||
// Quaternion
|
||||
//
|
||||
trait Quaternion<T> {
|
||||
pub trait Quaternion<T> {
|
||||
pure fn dim() -> uint;
|
||||
|
||||
pure fn index(&&index:uint) -> T;
|
||||
|
@ -52,23 +52,23 @@ trait Quaternion<T> {
|
|||
//
|
||||
// Quat struct definition
|
||||
//
|
||||
struct Quat { data:[float * 4] }
|
||||
pub struct Quat { data:[float * 4] }
|
||||
|
||||
const quat_zero :Quat = Quat { data: [ 0f, 0f, 0f, 0f ] };
|
||||
const quat_identity :Quat = Quat { data: [ 1f, 0f, 0f, 0f ] };
|
||||
pub const quat_zero :Quat = Quat { data: [ 0f, 0f, 0f, 0f ] };
|
||||
pub const quat_identity :Quat = Quat { data: [ 1f, 0f, 0f, 0f ] };
|
||||
|
||||
//
|
||||
// Quat Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Quat(w:float, x:float, y:float, z:float) -> Quat {
|
||||
pub pure fn Quat(w:float, x:float, y:float, z:float) -> Quat {
|
||||
Quat { data: [ w, x, y, z ] }
|
||||
}
|
||||
|
||||
//
|
||||
// Quaternion Implementation
|
||||
//
|
||||
impl Quat: Quaternion<float> {
|
||||
pub impl Quat: Quaternion<float> {
|
||||
#[inline]
|
||||
pure fn dim() -> uint { 4 }
|
||||
|
||||
|
@ -203,7 +203,7 @@ impl Quat: Quaternion<float> {
|
|||
//
|
||||
// Convert To String
|
||||
//
|
||||
impl Quat: ToStr {
|
||||
pub impl Quat: ToStr {
|
||||
fn to_str() -> ~str {
|
||||
fmt!("Quat[ %f, %f, %f, %f ]", self.w(), self.x(), self.y(), self.z())
|
||||
}
|
||||
|
|
68
src/vec.rs
68
src/vec.rs
|
@ -7,7 +7,7 @@ use to_str::ToStr;
|
|||
//
|
||||
// N-dimensional Vector
|
||||
//
|
||||
trait Vector<T> {
|
||||
pub trait Vector<T> {
|
||||
static pure fn dim() -> uint;
|
||||
|
||||
pure fn index(&&index:uint) -> T;
|
||||
|
@ -47,7 +47,7 @@ trait Vector<T> {
|
|||
|
||||
|
||||
|
||||
trait Vector2<T> {
|
||||
pub trait Vector2<T> {
|
||||
// static pure fn _new(x:float, y:float) -> self;
|
||||
|
||||
// This is where I wish rust had properties ;)
|
||||
|
@ -58,7 +58,7 @@ trait Vector2<T> {
|
|||
// static pure fn unit_y() -> self;
|
||||
}
|
||||
|
||||
trait Vector3<T> {
|
||||
pub trait Vector3<T> {
|
||||
// error: duplicate function definition
|
||||
// static pure fn _new(x:float, y:float, z:float) -> self;
|
||||
|
||||
|
@ -73,7 +73,7 @@ trait Vector3<T> {
|
|||
fn cross(&&other:self) -> self;
|
||||
}
|
||||
|
||||
trait Vector4<T> {
|
||||
pub trait Vector4<T> {
|
||||
// error: duplicate function definition
|
||||
// static pure fn _new(x:float, y:float, z:float, w:float) -> self;
|
||||
|
||||
|
@ -96,22 +96,22 @@ trait Vector4<T> {
|
|||
//
|
||||
// Vec2
|
||||
//
|
||||
struct Vec2 { data:[float * 2] }
|
||||
pub struct Vec2 { data:[float * 2] }
|
||||
|
||||
const vec2_zero :Vec2 = Vec2 { data: [ 0f, 0f ] };
|
||||
const vec2_unit_x :Vec2 = Vec2 { data: [ 1f, 0f ] };
|
||||
const vec2_unit_y :Vec2 = Vec2 { data: [ 0f, 1f ] };
|
||||
const vec2_identity :Vec2 = Vec2 { data: [ 1f, 1f ] };
|
||||
pub const vec2_zero :Vec2 = Vec2 { data: [ 0f, 0f ] };
|
||||
pub const vec2_unit_x :Vec2 = Vec2 { data: [ 1f, 0f ] };
|
||||
pub const vec2_unit_y :Vec2 = Vec2 { data: [ 0f, 1f ] };
|
||||
pub const vec2_identity :Vec2 = Vec2 { data: [ 1f, 1f ] };
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Vec2(x:float, y:float) -> Vec2 {
|
||||
pub pure fn Vec2(x:float, y:float) -> Vec2 {
|
||||
Vec2 { data: [ x, y ] }
|
||||
}
|
||||
|
||||
impl Vec2: Vector2<float> {
|
||||
pub impl Vec2: Vector2<float> {
|
||||
// #[inline]
|
||||
// static pure fn _new(x:float, y:float) -> Vec2 {
|
||||
// Vec2 { data: [ x, y ] }
|
||||
|
@ -125,7 +125,7 @@ impl Vec2: Vector2<float> {
|
|||
// #[inline] static pure fn unit_z() -> Vec2 { Vec2(0f, 0f) }
|
||||
}
|
||||
|
||||
impl Vec2: Vector<float> {
|
||||
pub impl Vec2: Vector<float> {
|
||||
#[inline]
|
||||
static pure fn dim() -> uint { 2 }
|
||||
|
||||
|
@ -242,7 +242,7 @@ impl Vec2: Vector<float> {
|
|||
#[inline] static pure fn identity() -> Vec2 { Vec2(1f, 1f) }
|
||||
}
|
||||
|
||||
impl Vec2: ToStr {
|
||||
pub impl Vec2: ToStr {
|
||||
fn to_str() -> ~str {
|
||||
fmt!("Vec2[ %f, %f ]", self[0], self[1])
|
||||
}
|
||||
|
@ -256,23 +256,23 @@ impl Vec2: ToStr {
|
|||
//
|
||||
// Vec3
|
||||
//
|
||||
struct Vec3 { data:[float * 3] }
|
||||
pub struct Vec3 { data:[float * 3] }
|
||||
|
||||
const vec3_zero :Vec3 = Vec3 { data: [ 0f, 0f, 0f ] };
|
||||
const vec3_unit_x :Vec3 = Vec3 { data: [ 1f, 0f, 0f ] };
|
||||
const vec3_unit_y :Vec3 = Vec3 { data: [ 0f, 1f, 0f ] };
|
||||
const vec3_unit_z :Vec3 = Vec3 { data: [ 0f, 0f, 1f ] };
|
||||
const vec3_identity :Vec3 = Vec3 { data: [ 1f, 1f, 1f ] };
|
||||
pub const vec3_zero :Vec3 = Vec3 { data: [ 0f, 0f, 0f ] };
|
||||
pub const vec3_unit_x :Vec3 = Vec3 { data: [ 1f, 0f, 0f ] };
|
||||
pub const vec3_unit_y :Vec3 = Vec3 { data: [ 0f, 1f, 0f ] };
|
||||
pub const vec3_unit_z :Vec3 = Vec3 { data: [ 0f, 0f, 1f ] };
|
||||
pub const vec3_identity :Vec3 = Vec3 { data: [ 1f, 1f, 1f ] };
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Vec3(x:float, y:float, z:float) -> Vec3 {
|
||||
pub pure fn Vec3(x:float, y:float, z:float) -> Vec3 {
|
||||
Vec3 { data: [ x, y, z ] }
|
||||
}
|
||||
|
||||
impl Vec3: Vector3<float> {
|
||||
pub impl Vec3: Vector3<float> {
|
||||
// #[inline]
|
||||
// static pure fn _new(x:float, y:float, z:float) -> Vec3 {
|
||||
// Vec2 { data: [ x, y, z ] }
|
||||
|
@ -294,7 +294,7 @@ impl Vec3: Vector3<float> {
|
|||
// #[inline] static pure fn unit_z() -> Vec3 { Vec3(0f, 0f, 1f) }
|
||||
}
|
||||
|
||||
impl Vec3: Vector<float> {
|
||||
pub impl Vec3: Vector<float> {
|
||||
#[inline]
|
||||
static pure fn dim() -> uint { 3 }
|
||||
|
||||
|
@ -424,7 +424,7 @@ impl Vec3: Vector<float> {
|
|||
#[inline] static pure fn identity() -> Vec3 { Vec3(1f, 1f, 1f) }
|
||||
}
|
||||
|
||||
impl Vec3: ToStr {
|
||||
pub impl Vec3: ToStr {
|
||||
fn to_str() -> ~str {
|
||||
fmt!("Vec3[ %f, %f, %f ]", self[0], self[1], self[2])
|
||||
}
|
||||
|
@ -438,24 +438,24 @@ impl Vec3: ToStr {
|
|||
//
|
||||
// Vec4
|
||||
//
|
||||
struct Vec4 { data:[float * 4] }
|
||||
pub struct Vec4 { data:[float * 4] }
|
||||
|
||||
const vec4_zero :Vec4 = Vec4 { data: [ 0f, 0f, 0f, 0f ] };
|
||||
const vec4_unit_x :Vec4 = Vec4 { data: [ 1f, 0f, 0f, 0f ] };
|
||||
const vec4_unit_y :Vec4 = Vec4 { data: [ 0f, 1f, 0f, 0f ] };
|
||||
const vec4_unit_z :Vec4 = Vec4 { data: [ 0f, 0f, 1f, 0f ] };
|
||||
const vec4_unit_w :Vec4 = Vec4 { data: [ 0f, 0f, 0f, 1f ] };
|
||||
const vec4_identity :Vec4 = Vec4 { data: [ 1f, 1f, 1f, 1f ] };
|
||||
pub const vec4_zero :Vec4 = Vec4 { data: [ 0f, 0f, 0f, 0f ] };
|
||||
pub const vec4_unit_x :Vec4 = Vec4 { data: [ 1f, 0f, 0f, 0f ] };
|
||||
pub const vec4_unit_y :Vec4 = Vec4 { data: [ 0f, 1f, 0f, 0f ] };
|
||||
pub const vec4_unit_z :Vec4 = Vec4 { data: [ 0f, 0f, 1f, 0f ] };
|
||||
pub const vec4_unit_w :Vec4 = Vec4 { data: [ 0f, 0f, 0f, 1f ] };
|
||||
pub const vec4_identity :Vec4 = Vec4 { data: [ 1f, 1f, 1f, 1f ] };
|
||||
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
#[inline]
|
||||
pure fn Vec4(x:float, y:float, z:float, w:float) -> Vec4 {
|
||||
pub pure fn Vec4(x:float, y:float, z:float, w:float) -> Vec4 {
|
||||
Vec4 { data: [ x, y, z, w ] }
|
||||
}
|
||||
|
||||
impl Vec4: Vector4<float> {
|
||||
pub impl Vec4: Vector4<float> {
|
||||
// #[inline]
|
||||
// static pure fn _new(x:float, y:float, z:float, w:float) -> Vec3 {
|
||||
// Vec2 { data: [ x, y, z, w ] }
|
||||
|
@ -472,7 +472,7 @@ impl Vec4: Vector4<float> {
|
|||
// #[inline] static pure fn unit_w() -> Vec4 { Vec4(0f, 0f, 0f, 1f) }
|
||||
}
|
||||
|
||||
impl Vec4: Vector<float> {
|
||||
pub impl Vec4: Vector<float> {
|
||||
#[inline]
|
||||
static pure fn dim() -> uint { 4 }
|
||||
|
||||
|
@ -615,7 +615,7 @@ impl Vec4: Vector<float> {
|
|||
#[inline] static pure fn identity() -> Vec4 { Vec4(1f, 1f, 1f, 1f) }
|
||||
}
|
||||
|
||||
impl Vec4: ToStr {
|
||||
pub impl Vec4: ToStr {
|
||||
fn to_str() -> ~str {
|
||||
fmt!("Vec4[ %f, %f, %f, %f ]", self[0], self[1], self[2], self[3])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue