#include <math.h>#include <cmath>#include "ExCVertex.h"#include "ExCMesh.h"#include "ExCVec3D.h"#include "ExCVec2D.h"#include "ExCMatrix4x4.h"#include "ExCMatrix3x3.h"#include "ExQuaternion.h"#include "ExCFrustum.h"#include "cos.h"#include "sin.h"Go to the source code of this file.
Functions | |
| 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) |
|
|
Definition at line 48 of file ExMath.h. Referenced by ExCModel::Draw(), ExCCameraChase::Draw(), ExCCamera::Draw(), and GetQuaternionFromEuler().
00049 {return deg * PI/180.0f;}
|
|
|
Definition at line 190 of file ExMath.cpp. References ExCVec3D::GetVectorLenght(), ExQuaternion::qx, ExQuaternion::qy, ExQuaternion::qz, and ExCVec3D::SetValue().
|
|
||||||||||||
|
Definition at line 37 of file ExMath.cpp. References ExCVec3D::m_Vector. Referenced by ExCModel::Draw().
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 }
|
|
||||||||||||
|
Definition at line 32 of file ExMath.cpp. References ExCVec3D::m_Vector.
|
|
||||||||||||||||
|
Definition at line 131 of file ExMath.cpp. References A, B, C, D, Guard, and ExCMatrix4x4::m_Matrix. Referenced by ExCComposed::Draw().
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 }
|
|
|
Definition at line 54 of file ExMath.cpp. References ExCMatrix4x4::m_Matrix, ExQuaternion::qw, ExQuaternion::qx, ExQuaternion::qy, and 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 }
|
|
||||||||||||||||||||
|
Definition at line 202 of file ExMath.cpp. References 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 }
|
|
||||||||||||||||
|
Definition at line 101 of file ExMath.cpp. References DegreesToRadians(), ExQuaternion::qw, ExQuaternion::qx, ExQuaternion::qy, and ExQuaternion::qz. Referenced by ExCComposed::Draw(), and 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 }
|
|
|
Definition at line 46 of file ExMath.cpp. References ExCVec3D::GetVectorLenght().
00047 {
00048 ExCVec3D VecNorm;
00049 VecNorm=Vec1;
00050 VecNorm=VecNorm/VecNorm.GetVectorLenght();
00051 return VecNorm;
00052 }
|
|
||||||||||||
|
Definition at line 26 of file ExMath.cpp.
00027 {
00028 ExCMatrix4x4 RetMat;
00029 return RetMat;
00030 }
|
|
||||||||||||
|
Definition at line 179 of file ExMath.cpp. Referenced by 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 }
|
|
|
Definition at line 49 of file ExMath.h. References PI.
00049 {return deg * PI/180.0f;}
|
1.3-rc1