Changeset 2822 for trunk/packages/vizservers/nanovis/Vector4.h
- Timestamp:
- Mar 7, 2012, 12:21:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Vector4.h
r2798 r2822 17 17 #define _VECTOR4_H_ 18 18 19 #include <stdio.h> 20 #include <Trace.h> 19 #include "Trace.h" 21 20 22 21 class Vector4 … … 25 24 float x, y, z, w; 26 25 27 Vector4(void) { 28 /*empty*/ 29 } 30 Vector4(float x_val, float y_val, float z_val, float w_val) { 31 set(x_val, y_val, z_val, w_val); 32 } 33 void perspective_devide(void) { 34 /* Divide vector by w */ 35 x /= w, y /= w, z /= w, w = 1.; 26 Vector4() 27 {} 28 29 Vector4(float x_val, float y_val, float z_val, float w_val) 30 { 31 set(x_val, y_val, z_val, w_val); 36 32 } 37 33 38 void print(void) { 39 TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w); 34 void set(float x_val, float y_val, float z_val, float w_val) 35 { 36 x = x_val, y = y_val, z = z_val, w = w_val; 40 37 } 41 38 42 Vector4 operator +(Vector4 &op2){ 43 return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w); 39 void perspective_divide() 40 { 41 /* Divide vector by w */ 42 x /= w, y /= w, z /= w, w = 1.; 44 43 } 45 44 46 Vector4 operator -(Vector4 &op2){ 47 return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w); 45 void print() const 46 { 47 TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w); 48 48 } 49 49 50 float operator *(Vector4 &op2) { 51 return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w); 50 Vector4 operator +(const Vector4& op2) const 51 { 52 return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w); 52 53 } 53 54 54 Vector4 operator *(float op2){ 55 return Vector4(x * op2, y * op2, z * op2, w * op2); 55 Vector4 operator -(const Vector4& op2) const 56 { 57 return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w); 56 58 } 57 59 58 Vector4 operator /(float op2) { 59 return Vector4(x / op2, y / op2, z / op2, w / op2); 60 float operator *(const Vector4& op2) const 61 { 62 return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w); 60 63 } 61 64 62 void operator <(Vector4 &op2) { 63 set(op2.x, op2.y, op2.z, op2.w); 65 Vector4 operator *(float op2) const 66 { 67 return Vector4(x * op2, y * op2, z * op2, w * op2); 64 68 } 65 void set(float x_val, float y_val, float z_val, float w_val) { 66 x = x_val, y = y_val, z = z_val, w = w_val; 69 70 Vector4 operator /(float op2) const 71 { 72 return Vector4(x / op2, y / op2, z / op2, w / op2); 67 73 } 68 74 };
Note: See TracChangeset
for help on using the changeset viewer.