#include <math.h>#include <cmath>#include "Math/ExCVec3D.h"#include "Math/ExCVec2D.h"#include "Math/ExCMatrix4x4.h"#include "Math/ExCMatrix3x3.h"#include "Math/ExQuaternion.h"#include "Math/ExCFrustum.h"#include "Math/cos.h"#include "Math/sin.h"Aller au code source de ce fichier.
Fonctions | |
| ExCMatrix4x4 | MatriceByVec3D (const ExCMatrix4x4 &m, const ExCVec3D &v) |
| float | GetDotProduct (const ExCVec3D &Vec1, const ExCVec3D &Vec2) |
| ExCVec3D | GetCrossProduct (const ExCVec3D &Vec1, const ExCVec3D &Vec2) |
| ExCVec3D | GetVecNormale (const ExCVec3D &Vec1) |
| ExCMatrix4x4 | GetMatrixFromQuaternion (const ExQuaternion &Q) |
| ExCMatrix4x4 | GetMatrixFromEuler (float roll, float pitch, float yaw) |
| ExQuaternion | GetQuaternionFromEuler (float x, float y, float z) |
| void | NormalizePlane (float Plane[6][4], int side) |
| float | DegreesToRadians (float deg) |
| float | RadiansToDegrees (float rad) |
| ExCVec3D | GetAxisFromQuaternion (const ExQuaternion &Q) |
| ExCVec3D | GetNewVecFromEuler (ExCVec3D force, float roll, float pitch, float yaw) |
| void | ProjectPointOnPlane (ExCVec3D dst, const ExCVec3D p, const ExCVec3D normal) |
| void | PerpendicularVector (ExCVec3D dst, const ExCVec3D src) |
| float | getRandomMinMax (float fMin, float fMax) |
| ExCVec3D | getRandomVector (void) |
| float | DistanceBeteweenTwoPoint (ExCVec3D p1, ExCVec3D p2) |
|
|
Définition à la ligne 47 du fichier ExMath.h. Références PI. Référencé par ExCCameraFlight::Draw(), ExCCameraFirst::Draw(), ExCCameraChase::Draw(), ExCCamera::Draw(), et GetQuaternionFromEuler().
00047 {return deg * PI/180.0f;}
|
|
||||||||||||
|
Définition à la ligne 313 du fichier ExMath.cpp. Références ExCVec3D::GetX(), ExCVec3D::GetY(), et ExCVec3D::GetZ(). Référencé par ExCMeshLOD3ds::Draw().
|
|
|
Définition à la ligne 190 du fichier ExMath.cpp. Références ExCVec3D::GetVectorLenght(), ExQuaternion::qx, ExQuaternion::qy, ExQuaternion::qz, et ExCVec3D::SetValue().
|
|
||||||||||||
|
Définition à la ligne 37 du fichier ExMath.cpp. Références ExCVec3D::m_Vector.
00038 {
00039 ExCVec3D CrossProduct;
00040 CrossProduct.m_Vector[0]=((Vec1.m_Vector[1]*Vec2.m_Vector[2])-(Vec1.m_Vector[2]*Vec2.m_Vector[1]));
00041 CrossProduct.m_Vector[1]=((Vec1.m_Vector[2]*Vec2.m_Vector[0])-(Vec1.m_Vector[0]*Vec2.m_Vector[2]));
00042 CrossProduct.m_Vector[2]=((Vec1.m_Vector[0]*Vec2.m_Vector[1])-(Vec1.m_Vector[1]*Vec2.m_Vector[0]));
00043 return CrossProduct;
00044 }
|
|
||||||||||||
|
Définition à la ligne 32 du fichier ExMath.cpp. Références ExCVec3D::m_Vector. Référencé par ProjectPointOnPlane().
|
|
||||||||||||||||
|
Définition à la ligne 131 du fichier ExMath.cpp. Références A, B, C, Cos, D, Guard, ExCMatrix4x4::m_Matrix, Sin, et UnGuard.
00132 {
00133 Guard(ExCMatrix4x4 GetMatrixFromEuler(float roll,float pitch,float yaw))
00134 ExCMatrix4x4 RetMatrix;
00135
00136 float A,B,C,D,E,F,AD,BD;
00137
00138 A=Cos[(int)roll];
00139 //cout<<"cos roll "<<A<<endl;
00140 B=Sin[(int)roll];
00141 //cout<<"sin roll "<<B<<endl;
00142 C=Cos[(int)pitch];
00143 //cout<<"cos pitch "<<C<<endl;
00144 D=Sin[(int)pitch];
00145 //cout<<"sin pitch "<<D<<endl;
00146 E=Cos[(int)yaw];
00147 //cout<<"cos yaw "<<E<<endl;
00148 F=Sin[(int)yaw];
00149 //cout<<"sin yaw "<<F<<endl;
00150
00151 AD=A*D;
00152 BD=B*D;
00153
00154
00155 RetMatrix.m_Matrix[0] = C*E;
00156 RetMatrix.m_Matrix[1] =-C*F;
00157 RetMatrix.m_Matrix[2] =-D;
00158 RetMatrix.m_Matrix[3] =0.0;
00159
00160 RetMatrix.m_Matrix[4] =-BD * E + A * F;
00161 RetMatrix.m_Matrix[5] = BD * F + A * E;
00162 RetMatrix.m_Matrix[6] =-B * C;
00163 RetMatrix.m_Matrix[7] =0.0;
00164
00165 RetMatrix.m_Matrix[8] = AD * E + B * F;
00166 RetMatrix.m_Matrix[9] =-AD * F + B * E;
00167 RetMatrix.m_Matrix[10]= A * C;
00168 RetMatrix.m_Matrix[11]=0.0;
00169
00170 RetMatrix.m_Matrix[12]=0.0;
00171 RetMatrix.m_Matrix[13]=0.0;
00172 RetMatrix.m_Matrix[14]=0.0;
00173 RetMatrix.m_Matrix[15]=1.0;
00174
00175 return RetMatrix;
00176 UnGuard
00177 }
|
|
|
Définition à la ligne 54 du fichier ExMath.cpp. Références ExCMatrix4x4::m_Matrix, ExQuaternion::qw, ExQuaternion::qx, ExQuaternion::qy, et ExQuaternion::qz.
00055 {
00056 ExCMatrix4x4 RetMatrix;
00057
00058 float w=Q.qw;
00059 float x=Q.qx;
00060 float y=Q.qy;
00061 float z=Q.qz;
00062
00063
00064 float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
00065
00066
00067 // calculate coefficients
00068 x2 = Q.qx + Q.qx; y2 = Q.qy + Q.qy;
00069 z2 = Q.qz + Q.qz;
00070 xx = Q.qx * x2; xy = Q.qx * y2; xz = Q.qx * z2;
00071 yy = Q.qy * y2; yz = Q.qy * z2; zz = Q.qz * z2;
00072 wx = Q.qw * x2; wy = Q.qw * y2; wz = Q.qw * z2;
00073
00074
00075 RetMatrix.m_Matrix[0] = 1.0 - (yy + zz);
00076 RetMatrix.m_Matrix[1] = xy - wz;
00077 RetMatrix.m_Matrix[2] = xz + wy;
00078 RetMatrix.m_Matrix[3] = 0.0;
00079
00080 RetMatrix.m_Matrix[4] = xy + wz;
00081 RetMatrix.m_Matrix[5] = 1.0 - (xx + zz);
00082 RetMatrix.m_Matrix[6] = yz - wx;
00083 RetMatrix.m_Matrix[7] = 0.0;
00084
00085
00086 RetMatrix.m_Matrix[8] = xz - wy;
00087 RetMatrix.m_Matrix[9] = yz + wx;
00088 RetMatrix.m_Matrix[10] = 1.0 - (xx + yy);
00089 RetMatrix.m_Matrix[11] = 0.0;
00090
00091
00092 RetMatrix.m_Matrix[12] = 0;
00093 RetMatrix.m_Matrix[13] = 0;
00094 RetMatrix.m_Matrix[14] = 0;
00095 RetMatrix.m_Matrix[15] = 1;
00096
00097
00098 return RetMatrix;
00099 }
|
|
||||||||||||||||||||
|
Définition à la ligne 202 du fichier ExMath.cpp. Références ExCVec3D::m_Vector.
00203 {
00204 ExCVec3D Result,VecX,VecY,VecZ;
00205
00206 //roll angle x
00207 //pitch angle y
00208 //yaw angle z
00209
00210 // calcul new vec pour x
00211 /*VecX.m_Vector[0]=force.m_Vector[0]*cos(pitch);
00212 VecX.m_Vector[1]=0.0f;
00213 VecX.m_Vector[2]=force.m_Vector[0]*sin(pitch);
00214 */
00215 VecY.m_Vector[0]=0.0f;
00216 VecY.m_Vector[1]=force.m_Vector[1]*sin(roll);
00217 VecY.m_Vector[2]=force.m_Vector[1]*cos(roll);
00218
00219 VecZ.m_Vector[0]=force.m_Vector[2]*cos(yaw);
00220 VecZ.m_Vector[1]=force.m_Vector[2]*sin(yaw);
00221 VecZ.m_Vector[2]=0.0f;
00222
00223 Result=VecX+VecY+VecZ;
00224
00225 //std::cout<<"leng of result:"<<Result.GetVectorLenght()<<std::endl;
00226 //std::cout<<"leng of force:"<<force.GetVectorLenght()<<std::endl;
00227
00228 //std::cout<<"Result:"<<Result<<std::endl;
00229 //std::cout<<"Force:"<<force<<std::endl;
00230 return Result;
00231 }
|
|
||||||||||||||||
|
Définition à la ligne 101 du fichier ExMath.cpp. Références DegreesToRadians(), ExQuaternion::qw, ExQuaternion::qx, ExQuaternion::qy, et ExQuaternion::qz. Référencé par ExCObject3D::Rotate().
00102 {
00103 ExQuaternion QResult;
00104 double roll= DegreesToRadians(x);
00105 double pitch = DegreesToRadians(y);
00106 double yaw = DegreesToRadians(z);
00107
00108 double cyaw,cpitch,croll,syaw,spitch,sroll;
00109 double cyawcpitch,syawspitch,cyawspitch,syawcpitch;
00110
00111 cyaw = cos(0.5f * yaw);
00112 cpitch = cos(0.5f * pitch);
00113 croll = cos(0.5f * roll);
00114 syaw = sin(0.5f * yaw);
00115 spitch = sin(0.5f * pitch);
00116 sroll = sin(0.5f * roll);
00117
00118 cyawcpitch = cyaw*cpitch;
00119 syawspitch = syaw*pitch;
00120 cyawspitch = cyaw*spitch;
00121 syawcpitch = syaw*cpitch;
00122
00123
00124 QResult.qw=(float)(cyawcpitch * croll + syawspitch * sroll);
00125 QResult.qx=(float)(cyawcpitch * sroll - syawspitch * croll);
00126 QResult.qy=(float)(cyawspitch * croll + syawcpitch * sroll);
00127 QResult.qz=(float)(cyawcpitch * croll - cyawspitch * sroll);
00128 return QResult;
00129 }
|
|
||||||||||||
|
Définition à la ligne 287 du fichier ExMath.cpp. Référencé par getRandomVector().
00288 {
00289 float fRandNum = (float)rand () / RAND_MAX;
00290 return fMin + (fMax - fMin) * fRandNum;
00291 }
|
|
|
Définition à la ligne 293 du fichier ExMath.cpp. Références getRandomMinMax(), ExCVec3D::m_Vector, et PI.
00294 {
00295 ExCVec3D Vec;
00296
00297 // Pick a random Z between -1.0f and 1.0f.
00298 Vec.m_Vector[2] = getRandomMinMax( -1.0f, 1.0f );
00299
00300 // Get radius of this circle
00301 float radius = (float)sqrt(1 - Vec.m_Vector[2] * Vec.m_Vector[2]);
00302
00303 // Pick a random point on a circle.
00304 float t = getRandomMinMax( -PI, PI );
00305
00306 // Compute matching X and Y for our Z.
00307 Vec.m_Vector[0] = (float)cosf(t) * radius;
00308 Vec.m_Vector[1]= (float)sinf(t) * radius;
00309
00310 return Vec;
00311 }
|
|
|
Définition à la ligne 46 du fichier ExMath.cpp. Références ExCVec3D::GetVectorLenght().
00047 {
00048 ExCVec3D VecNorm;
00049 VecNorm=Vec1;
00050 VecNorm=VecNorm/VecNorm.GetVectorLenght();
00051 return VecNorm;
00052 }
|
|
||||||||||||
|
Définition à la ligne 26 du fichier ExMath.cpp.
00027 {
00028 ExCMatrix4x4 RetMat;
00029 return RetMat;
00030 }
|
|
||||||||||||
|
Définition à la ligne 179 du fichier ExMath.cpp. Référencé par ExCFrustum::CalculateFrustum().
00180 {
00181 float magnitude = (float)sqrt( Plane[side][0] * Plane[side][0] +
00182 Plane[side][1] * Plane[side][1] +
00183 Plane[side][2] * Plane[side][2] );
00184 Plane[side][0] /= magnitude;
00185 Plane[side][1] /= magnitude;
00186 Plane[side][2] /= magnitude;
00187 Plane[side][3] /= magnitude;
00188 }
|
|
||||||||||||
|
Définition à la ligne 255 du fichier ExMath.cpp. Références ExCVec3D::GetVecNormale(), ExCVec3D::m_Vector, ProjectPointOnPlane(), et ExCVec3D::SetValue().
00256 {
00257 int pos;
00258 int i;
00259 float minelem = 1.0F;
00260 ExCVec3D tempvec;
00261
00262 /*
00263 ** find the smallest magnitude axially aligned vector
00264 */
00265 for ( pos = 0, i = 0; i < 3; i++ )
00266 {
00267 if ( fabs( src.m_Vector[i] ) < minelem )
00268 {
00269 pos = i;
00270 minelem = fabs( src.m_Vector[i] );
00271 }
00272 }
00273 tempvec.SetValue(0.0f,0.0f,0.0f);
00274 tempvec.m_Vector[pos] = 1.0F;
00275
00276 /*
00277 ** project the point onto the plane defined by src
00278 */
00279 ProjectPointOnPlane( dst, tempvec, src );
00280
00281 /*
00282 ** normalize the result
00283 */
00284 dst.GetVecNormale();
00285 }
|
|
||||||||||||||||
|
Définition à la ligne 233 du fichier ExMath.cpp. Références GetDotProduct(), et ExCVec3D::m_Vector. Référencé par PerpendicularVector().
00234 {
00235 float d;
00236 ExCVec3D n;
00237 float inv_denom;
00238
00239 inv_denom = 1.0F / GetDotProduct( normal, normal );
00240
00241 d = GetDotProduct( normal, p ) * inv_denom;
00242
00243 n.m_Vector[0] = normal.m_Vector[0] * inv_denom;
00244 n.m_Vector[1] = normal.m_Vector[1] * inv_denom;
00245 n.m_Vector[2] = normal.m_Vector[2] * inv_denom;
00246
00247 dst.m_Vector[0] = p.m_Vector[0] - d * n.m_Vector[0];
00248 dst.m_Vector[1] = p.m_Vector[1] - d * n.m_Vector[1];
00249 dst.m_Vector[2] = p.m_Vector[2] - d * n.m_Vector[2];
00250 }
|
|
|
Définition à la ligne 48 du fichier ExMath.h. Références PI.
00048 {return rad * 180.0f /PI;}
|
1.3.4