/** * \brief ND Normal law * \param x a pointer to double, location where to calculate the output value * \param mu a pointer double, array of centers of the Gaussian * \param cov a pointer to MyMatrix, covariance matrix * \return a double, value of the Gaussian at x * * Returns the value of the ND Normal law at the input location */ double normalMultivariate(double* x, double* mu, MyMatrix* cov){ int i; double* xmu; MyMatrix* cov1; double* cov1_times_xmu; double det; double arg; /* calculate the vector x - mu */ xmu = malloc(cov->N*sizeof(double)); for(i = 0; i < cov->N; i++){ xmu[i] = x[i] - mu[i]; } /* inverse the covariance matrix */ cov1 = InvMat(cov, &det); /* cov-1 * (x-mu) */ cov1_times_xmu = MatVectProd(cov1, xmu); /* (x-mu) * cov-1 * (x-mu) */ arg = VectVectProd(cov->N, xmu, cov1_times_xmu); free(xmu); for(i = 0; i < cov1->N; i++) free(cov1->m[i]); free(cov1->m); free(cov1); free(cov1_times_xmu); return exp(-0.5*arg)/(sqrt(det)*pow(2.*M_PI, cov->N)); }
//----------------------------------------------------------------------------------------------- void CRenderCamera::RebuildMatrices() { m4x4 mToInvert = m_TM; m4x4 m = i4x4; InvMat( mToInvert, m_InvTM ); m_worldToClip = m_InvTM * m_projectionMatrix; }
//------------------------------------------------------------------------------------------ void CSkeleton::ComputeBonesDefaultInvMat() { for( u32 i=0; i<m_bones.Size(); i++ ) { CBone* bone = m_bones[i]; m4x4 defaultModelTM = i4x4; bone->GetDefaultModelTM( defaultModelTM ); InvMat( defaultModelTM, bone->m_invDefaultModelTM ); } }