Changeset 819 for trunk/vizservers
- Timestamp:
- Nov 26, 2007, 11:29:55 AM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/Vector3.cpp
r226 r819 14 14 */ 15 15 #include "Vector3.h" 16 #include "Mat4x4.h" 16 17 #include <math.h> 17 18 #include <stdio.h> … … 47 48 y*op2.y + 48 49 z*op2.z; 50 } 51 52 float Vector3::dot(const Vector3& vec) const 53 { 54 return x*vec.x + 55 y*vec.y + 56 z*vec.z; 49 57 } 50 58 … … 144 152 } 145 153 146 float Vector3::distance(Vector3 &another){ 154 float Vector3::distance(Vector3 &another) const 155 { 147 156 return sqrtf( (x - another.x) * (x - another.x) 148 157 + (y - another.y) * (y - another.y) … … 150 159 } 151 160 161 float Vector3::distanceSquare(Vector3 &another) const 162 { 163 return ( (x - another.x) * (x - another.x) 164 + (y - another.y) * (y - another.y) 165 + (z - another.z) * (z - another.z) ); 166 } 167 168 float Vector3::distanceSquare(float vx, float vy, float vz) const 169 { 170 return ( (x - vx) * (x - vx) 171 + (y - vy) * (y - vy) 172 + (z - vz) * (z - vz) ); 173 } 174 175 void Vector3::transform(const Vector3& v, const Mat4x4& mat) 176 { 177 const float* m = mat.m; 178 x = m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12]; 179 y = m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13]; 180 z = m[2] * v.x + m[6] * v.y + m[10] * v.z + m[14]; 181 } 152 182 153 183 184 float Vector3::length() const 185 { 186 187 return sqrt(x * x + y * y + z * z); 188 } -
trunk/vizservers/nanovis/Vector3.h
r226 r819 15 15 #ifndef _VECTOR3_H_ 16 16 #define _VECTOR3_H_ 17 18 class Mat4x4; 17 19 18 20 class Vector3{ … … 38 40 void set(float newx, float newy, float newz); 39 41 void print(); 40 float distance(Vector3 &another); //compute distance 42 float distance(Vector3 &another) const; //compute distance 43 float distanceSquare(Vector3 &another) const; //compute distance 44 float distanceSquare(float vx, float vy, float vz) const; //compute distance 41 45 42 46 //fast version 43 47 Vector3 cross(Vector3 op2); 48 49 float dot(const Vector3& vec) const; 50 51 void transform(const Vector3& vec, const Mat4x4& mat); 52 float length() const; 44 53 }; 45 54 -
trunk/vizservers/nanovis/Vector4.cpp
r226 r819 89 89 w = op2.w; 90 90 } 91 92 void Vector4::set(float x1, float y1, float z1, float w1) 93 { 94 x = x1; 95 y = y1; 96 z = z1; 97 w = w1; 98 } -
trunk/vizservers/nanovis/Vector4.h
r226 r819 33 33 Vector4 operator/(float op2); //mul per component 34 34 void operator <(Vector4 &op2); //assign 35 36 void set(float x1, float y1, float z1, float w1); 35 37 }; 36 38
Note: See TracChangeset
for help on using the changeset viewer.