- Timestamp:
- Nov 21, 2005, 9:59:09 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/matrix.cc
r5673 r5675 19 19 20 20 21 Vector Matrix::getEigenValues() const21 int Matrix::getEigenValues(Vector& eigenValues) const 22 22 { 23 Vector eigVl; 24 23 int retVal = -1; 25 24 float a = 0; 26 25 float b = 0; … … 61 60 float p = sqrt((b/2.0)*(b/2.0) - Q); 62 61 63 eig Vl.x = c[2]/3.0 + 2 * pow(p, 1/3.0) * cos(psi/3.0);64 eig Vl.y = c[2]/3.0 - pow(p, 1/3.0) * (cos(psi/3.0)62 eigenValues.x = c[2]/3.0 + 2 * pow(p, 1/3.0) * cos(psi/3.0); 63 eigenValues.y = c[2]/3.0 - pow(p, 1/3.0) * (cos(psi/3.0) 65 64 + sqrt(3.0) * sin(psi/3.0)); 66 eig Vl.z = c[2]/3.0 - pow(p, 1/3.0) * (cos(psi/3.0)65 eigenValues.z = c[2]/3.0 - pow(p, 1/3.0) * (cos(psi/3.0) 67 66 - sqrt(3.0) * sin(psi/3.0)); 68 67 retVal = 3; 69 68 } 70 69 // 2 Distinct Roots 71 70 else if (Q == 0) 72 71 { 73 eig Vl.x= c[2]/3.0 + pow(b/2.0, 1.0/3.0);74 eig Vl.y = c[2]/3.0 +pow(b/2.0, 1.0/3.0);75 eigVl.z = c[2]/3.0 + 2* pow(b/2.0, 1.0/3.0);72 eigenValues.x = eigenValues.y = c[2]/3.0 + pow(b/2.0, 1.0/3.0); 73 eigenValues.z = c[2]/3.0 + 2* pow(b/2.0, 1.0/3.0); 74 retVal = 2; 76 75 } 77 76 // 1 Root (not calculating anything.) 78 77 else if (Q > 0) 79 78 { 80 printf("This Matrix is a multiple of the Identity matrix (lambda * I3))\n");81 eigVl.x = eigVl.y = eigVl.z= 1;79 eigenValues.x = eigenValues.y = eigenValues.z = 1; 80 retVal = 1; 82 81 } 83 return eigVl;82 return retVal; 84 83 } 85 84 86 void Matrix::getEigenVectors(Vector& a, Vector& b, Vector& c) const85 void Matrix::getEigenVectors(Vector& eigVc1, Vector& eigVc2, Vector& eigVc3) const 87 86 { 88 Vector eigVl = this->getEigenValues(); 87 Vector eigenValues; 88 int eigenValuesCount = this->getEigenValues(eigenValues); 89 89 90 float eigVal[3] = { eigVl.x, eigVl.y, eigVl.z }; 90 /* eigenvec creation */ 91 eigVc1.x = -1/this->m13*(this->m33 - eigenValues.x) + 92 (this->m32*(-this->m31*this->m32 + this->m12*this->m33 - this->m12*eigenValues.x)) / 93 this->m13*(-this->m13*this->m22 - this->m12*this->m23 + this->m13*eigenValues.x); 91 94 92 Vector eigVc[3]; 93 /* eigenvec test */ 94 for(int i = 0; i < 2; i++) 95 { 96 eigVc[i].x = -1/this->m13*(this->m33 - eigVal[i]) + (this->m32*(-this->m31*this->m32 + this->m12*this->m33 - this->m12*eigVal[i])) / 97 this->m13*(-this->m13*this->m22 - this->m12*this->m23 + this->m13*eigVal[i]); 95 eigVc1.y = -( -this->m13*this->m23 + this->m12*this->m33 - this->m12*eigenValues.x) / 96 (-this->m31*this->m22 + this->m12*this->m23 + this->m13*eigenValues.x); 98 97 99 eigVc[i].y = -( -this->m13*this->m23 + this->m12*this->m33 - this->m12*eigVal[i]) / 100 (-this->m31*this->m22 + this->m12*this->m23 + this->m13*eigVal[i]); 98 eigVc1.z = 1.0f; 101 99 102 eigVc[i].z = 1.0f; 100 eigVc2.x = -1/this->m13*(this->m33 - eigenValues.y) + 101 (this->m32*(-this->m31*this->m32 + this->m12*this->m33 - this->m12*eigenValues.y)) / 102 this->m13*(-this->m13*this->m22 - this->m12*this->m23 + this->m13*eigenValues.y); 103 103 104 eigVc[i] /= eigVc[i].len(); 105 } 106 eigVc[2] = eigVc[0].cross(eigVc[1]); 104 eigVc2.y = -( -this->m13*this->m23 + this->m12*this->m33 - this->m12*eigenValues.y) / 105 (-this->m31*this->m22 + this->m12*this->m23 + this->m13*eigenValues.y); 107 106 108 a = eigVc[0]; 109 b = eigVc[1]; 110 c = eigVc[2]; 107 eigVc2.z = 1.0f; 108 109 eigVc3 = eigVc1.cross(eigVc2); 110 111 eigVc1.normalize(); 112 eigVc2.normalize(); 113 eigVc3.normalize(); 111 114 } 112 115 -
trunk/src/lib/math/matrix.h
r5673 r5675 58 58 } 59 59 60 Vector getEigenValues() const;60 int getEigenValues(Vector& eigenVectors) const; 61 61 void getEigenVectors(Vector& a, Vector& b, Vector& c) const; 62 62 -
trunk/src/world_entities/weapons/laser.cc
r5512 r5675 41 41 this->setClassID(CL_LASER, "Laser"); 42 42 43 float modelSize = .3; 44 this->loadModel("models/projectiles/laser.obj"); 43 this->loadModel("models/projectiles/blue_laser.obj"); 45 44 46 45 this->energyMin = 1;
Note: See TracChangeset
for help on using the changeset viewer.