当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix3::Transpose方法代码示例

本文整理汇总了C++中Matrix3::Transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3::Transpose方法的具体用法?C++ Matrix3::Transpose怎么用?C++ Matrix3::Transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix3的用法示例。


在下文中一共展示了Matrix3::Transpose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

Matrix3 Matrix3::Adjoint ()
{
	/* Find the Adjoint
	 * http://www.mathwords.com/a/adjoint.htm
	 */

	Matrix3 temp;

	// CoFactor(Mirror of minors)
	temp._data[0] = this->_data[4]*this->_data[8] - this->_data[5]*this->_data[7];
	temp._data[1] = this->_data[3]*this->_data[8] - this->_data[5]*this->_data[6];
	temp._data[2] = this->_data[3]*this->_data[7] - this->_data[4]*this->_data[6];

	temp._data[3] = this->_data[1]*this->_data[8] - this->_data[2]*this->_data[7];
	temp._data[4] = this->_data[0]*this->_data[8] - this->_data[2]*this->_data[6];
	temp._data[5] = this->_data[0]*this->_data[7] - this->_data[1]*this->_data[6];

	temp._data[6] = this->_data[1]*this->_data[5] - this->_data[2]*this->_data[4];
	temp._data[7] = this->_data[0]*this->_data[5] - this->_data[2]*this->_data[3];
	temp._data[8] = this->_data[0]*this->_data[4] - this->_data[1]*this->_data[3];

	// Matrix of cofactors
	// + - +
	// - + -
	// + - +
	for(int i=1;i<9;i+=2)
		temp._data[i] *= -1;

	// Finally the adjoint of A is the transpose of the cofactor matrix
	temp = temp.Transpose();

	return temp;
}
开发者ID:cdrandin,项目名称:Graphics-OpenGL,代码行数:33,代码来源:Matrix3.cpp

示例2: view_matrix

Matrix4 Camera::view_matrix() {	
	if (!view_needs_rebuild_) { return view_matrix_; }

	// http://stackoverflow.com/questions/12777675/view-matrix-from-quaternion
	// http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-4-geometry/conventions-again-row-major-vs-column-major-vector/
	// TODO Might need to revist this if this doesn't work out. 
	// Figure out what the transpose does.

	view_matrix_ = Matrix4::IDENTITY;

	// This is most efficiently done using 3x3 Matrices
	Matrix3 rotation;
	orientation_.ToRotationMatrix(rotation);

	// Make the translation relative to new axes
	Matrix3 transposeRotation = rotation.Transpose();
	Vector3 trans = -transposeRotation * position_;

	// Make final matrix
	view_matrix_ = transposeRotation; // fills upper 3x3
	view_matrix_[0][3] = trans.x;
	view_matrix_[1][3] = trans.y;
	view_matrix_[2][3] = trans.z;	

	view_needs_rebuild_ = false;

	return view_matrix_;
}
开发者ID:davidhuynh,项目名称:ludi,代码行数:28,代码来源:Camera.cpp

示例3: SetParameter

 void SpriteShader::SetParameter(const std::string &parameterName, const Matrix3 &value)
 {
     if(pimpl->uniforms.find(parameterName) == pimpl->uniforms.end())
         throw std::runtime_error("Couldn't find the named SpriteEffect parameter: " + parameterName);
     
     auto &uniformData = pimpl->uniforms[parameterName];
     
     if(uniformData.type != GL_FLOAT_MAT3)
         throw std::runtime_error("Type mismatch for named SpriteEffect paramater: " + parameterName);
     
     glUniformMatrix3fv(uniformData.location, 1, GL_FALSE, value.Transpose());
 }
开发者ID:ThirdPartyNinjas,项目名称:NinjaParty,代码行数:12,代码来源:SpriteShader.cpp

示例4: GetInverseInertialTensor

Matrix3 RigidBody::GetInverseInertialTensor() const
{
	Vector3 diagonal = GetLocalInverseInertialTensor();
	Matrix3 localInverseTensor = Matrix3::ZERO;
	localInverseTensor[0][0] = diagonal.x;
	localInverseTensor[1][1] = diagonal.y;
	localInverseTensor[2][2] = diagonal.z;

	Matrix3 rotation;
	GetTransformation().extract3x3Matrix(rotation);

	return rotation.Transpose() * localInverseTensor * rotation;
}
开发者ID:siqihuang,项目名称:rigidbody-simulation,代码行数:13,代码来源:RigidBody.cpp

示例5:

void GLSLProgram<real>::SetupCamera()
{
	RenderState<real>* glState = RenderState<real>::Get();
	Camera<real>* camera = glState->GetCamera();
	Matrix4<float> projectionMatrix = camera->GetProjectionMatrix();
	Matrix4<float> viewMatrix = camera->GetGlobalToLocal();
	Matrix4<float> modelMatrix = glState->GetModelMatrix();
	Matrix4<float> modelViewProjectionMatrix = projectionMatrix * viewMatrix * modelMatrix;
	Matrix3<float> normalMatrix = modelMatrix.SubMatrix3( 0, 0 );
	normalMatrix.Inverse();
	normalMatrix.Transpose();

	// Model, view and projection matrices, camera position
	glUniformMatrix4fv( mModelMatrixLocation, 1, true, modelMatrix.GetArray() );
	glUniformMatrix4fv( mViewMatrixLocation, 1, true, viewMatrix.GetArray() );
	glUniformMatrix4fv( mProjectionMatrixLocation, 1, true, projectionMatrix.GetArray() );
	glUniformMatrix4fv( mModelViewProjectionMatrixLocation, 1, true, modelViewProjectionMatrix.GetArray() );
	glUniformMatrix3fv( mNormalMatrixLocation, 1, true, normalMatrix.GetArray() );
	Vector3<float> cameraPosition = camera->GetGlobalPosition();
	glUniform3fv( mCameraPositionLocation, 1, (float*)&cameraPosition );
}
开发者ID:gnuvince,项目名称:ift3355-tp2,代码行数:21,代码来源:GLSLProgram.cpp

示例6: makeViewMatrix

	//---------------------------------------------------------------------
	Matrix4 Math::makeViewMatrix(const Vector3& position, const Quaternion& orientation, 
		const Matrix4* reflectMatrix)
	{
		Matrix4 viewMatrix;

		// View matrix is:
		//
		//  [ Lx  Uy  Dz  Tx  ]
		//  [ Lx  Uy  Dz  Ty  ]
		//  [ Lx  Uy  Dz  Tz  ]
		//  [ 0   0   0   1   ]
		//
		// Where T = -(Transposed(Rot) * Pos)

		// This is most efficiently done using 3x3 Matrices
		Matrix3 rot;
		orientation.ToRotationMatrix(rot);

		// Make the translation relative to new axes
		Matrix3 rotT = rot.Transpose();
		Vector3 trans = -rotT * position;

		// Make final matrix
		viewMatrix = Matrix4::IDENTITY;
		viewMatrix = rotT; // fills upper 3x3
		viewMatrix[0][3] = trans.x;
		viewMatrix[1][3] = trans.y;
		viewMatrix[2][3] = trans.z;

		// Deal with reflections
		if (reflectMatrix)
		{
			viewMatrix = viewMatrix * (*reflectMatrix);
		}

		return viewMatrix;

	}
开发者ID:ttnghia,项目名称:signed-distance-field-generator,代码行数:39,代码来源:OgreMath.cpp

示例7: are

/* Take increments in strain and calculate new Particle: strains, rotation strain,
		stresses, strain energy,
	dvij are (gradient rates X time increment) to give deformation gradient change
	For Axisymmetry: x->R, y->Z, z->theta, np==AXISYMMEtRIC_MPM, otherwise dvzz=0
	This material tracks pressure and stores deviatoric stress only in particle stress tensor
 */
void ClampedNeohookean::MPMConstitutiveLaw(MPMBase *mptr,Matrix3 du,double delTime,int np,void *properties,
										   ResidualStrains *res,int historyOffset) const
{
	// Update total deformation gradient, and calculate trial B
    Tensor Btrial;
	double detDF = IncrementDeformation(mptr,du,&Btrial,np);
    
	// global J
	double J = detDF * mptr->GetHistoryDble(J_History,historyOffset);
	mptr->SetHistoryDble(J_History,J,historyOffset);
	
	// convert Btrial to matrix to get eigenvalues and check for clamping
	Matrix3 Belas(Btrial.xx,Btrial.xy,Btrial.xz,
				  Btrial.xy,Btrial.yy,Btrial.yz,
				  Btrial.xz,Btrial.yz,Btrial.zz);
	if(np!=THREED_MPM) Belas.setIs2D(true);
		
	// get Eigenvalues and Eigenvectors
	Vector lam2 = Belas.Eigenvalues();
	
	// clamp eigenvalues if needed
	bool clamped = false;
	if(lam2.x<lamMin2 || lam2.x>lamMax2 || lam2.y<lamMin2 || lam2.y>lamMax2 || lam2.z<lamMin2 || lam2.z>lamMax2)
		clamped = true;
	
	// Get Je and Jp, adjusting if clamped
	double Je,Jp;
	Matrix3 Ucol;
	if(clamped)
	{	// Find Belas = U.LAM.UT
		Ucol = Belas.Eigenvectors(lam2);
		// clamp values now
		if(lam2.x<lamMin2)
			lam2.x = lamMin2;
		else if(lam2.x>lamMax2)
			lam2.x = lamMax2;
		if(lam2.y<lamMin2)
			lam2.y = lamMin2;
		else if(lam2.y>lamMax2)
			lam2.y = lamMax2;
		if(lam2.z<lamMin2)
			lam2.z = lamMin2;
		else if(lam2.z>lamMax2)
			lam2.z = lamMax2;
		Matrix3 UcolT = Ucol.Transpose();
		Matrix3 Lam(lam2.x,0.,0.,lam2.y,lam2.z);
		Matrix3 LamUcolT = Lam*UcolT;
		Belas = Ucol*LamUcolT;
		
		// get Je and Jp
		Je = sqrt(lam2.x*lam2.y*lam2.z);
		Jp = J/Je;
		mptr->SetHistoryDble(JP_HISTORY,Jp,historyOffset);
	}
	else
	{	Jp = mptr->GetHistoryDble(JP_HISTORY,historyOffset);
		Je = J/Jp;
		if(elasticModel==ELASTIC_DISNEY)
			Ucol = Belas.Eigenvectors(lam2);
	}
	
	// store B elastic
	Tensor *sp=mptr->GetStressTensor();
    Tensor *B = mptr->GetAltStrainTensor();
	B->xx = Belas(0,0);
	B->yy = Belas(1,1);
	B->zz = Belas(2,2);
	B->xy = Belas(0,1);
	if(np==THREED_MPM)
	{	B->xz = Belas(0,2);
		B->yz = Belas(1,2);
	}
	
	// change mechanical properties by hardening
	double arg = exp(hardening*(1.-Jp));
	double altGsp = pr.Gsp*arg;
	double altLamesp = pr.Lamesp*arg;

	// account for residual stresses
	double dJres = GetIncrementalResJ(mptr,res);
	double Jres = dJres*mptr->GetHistoryDble(J_History+1,historyOffset);
	mptr->SetHistoryDble(J_History+1,Jres,historyOffset);
	double resStretch = pow(Jres,1./3.);
	double Jres23 = resStretch*resStretch;
		
	// account for residual stresses relative to elastic J
	double Jeff = Je/Jres;
		
	// for incremental energy, store initial stress and pressure
	Tensor *sporig=mptr->GetStressTensor();
	Tensor st0 = *sporig;
	double Pfinal,p0=mptr->GetPressure();
	
	if(elasticModel==ELASTIC_DISNEY)
//.........这里部分代码省略.........
开发者ID:nairnj,项目名称:nairn-mpm-fea,代码行数:101,代码来源:ClampedNeohookean.cpp

示例8:

/*
============
Matrix3::InertiaRotate
============
*/
Matrix3 Matrix3::InertiaRotate( const Matrix3 &rotation ) const {
	// NOTE: the rotation matrix is stored column-major
	return rotation.Transpose() * (*this) * rotation;
}
开发者ID:S-V,项目名称:SummerTraining,代码行数:9,代码来源:Matrix3x3.cpp

示例9: DoRender


//.........这里部分代码省略.........
  {
    normalLoc = program.GetAttribLocation(Program::ATTRIB_NORMAL);
    if( Program::ATTRIB_UNKNOWN != normalLoc )
    {
      mContext->VertexAttribPointer( normalLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->nX );
      mContext->EnableVertexAttributeArray( normalLoc );
    }
  }
  else if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() )  // Normals & color are mutually exclusive
  {
    colorLoc = program.GetAttribLocation(Program::ATTRIB_COLOR);
    if( Program::ATTRIB_UNKNOWN != colorLoc)
    {
      mContext->VertexAttribPointer( colorLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->vertexR );
      mContext->EnableVertexAttributeArray( colorLoc );
    }
  }

  material.SetUniforms( mRenderMaterialUniforms, program, shaderType );

  if( mAffectedByLighting )
  {
    // Set light parameters
    location = mCustomUniform[ shaderType ][ 3 ].GetUniformLocation( program, "uNumberOfLights" );
    if( Program::UNIFORM_UNKNOWN != location )
    {
      program.SetUniform1i( location, mLightController->GetNumberOfLights() );
    }

    // Model View IT matrix required for vertex normal lighting calculation
    location = mCustomUniform[ shaderType ][ 4 ].GetUniformLocation( program, "uModelViewIT" );
    if( Program::UNIFORM_UNKNOWN != location )
    {
      Matrix3 modelViewInverseTranspose = modelViewMatrix;
      modelViewInverseTranspose.Invert();
      modelViewInverseTranspose.Transpose();

      program.SetUniformMatrix3fv( location, 1, modelViewInverseTranspose.AsFloat() );
    }

    // only one active light supported at the moment (due to performance)
    //if( numberOfLights > 0 )
    {
      Vector2 tempVector2;
      Vector3 tempVector3;

      Node& lightNode = mLightController->GetLight( 0 );

      LightAttachment& light = dynamic_cast< LightAttachment& >( lightNode.GetAttachment() );

      location = mCustomUniform[ shaderType ][ 5 ].GetUniformLocation( program, "uLight0.mType" );
      if( Program::UNIFORM_UNKNOWN != location )
      {
        program.SetUniform1i( location, (GLint)light.GetType() );
      }

      location = mCustomUniform[ shaderType ][ 6 ].GetUniformLocation( program, "uLight0.mFallOff" );
      if( Program::UNIFORM_UNKNOWN != location )
      {
        tempVector2 = light.GetFallOff();
        program.SetUniform2f( location, tempVector2.x, tempVector2.y );
      }

      location = mCustomUniform[ shaderType ][ 7 ].GetUniformLocation( program, "uLight0.mSpotAngle" );
      if( Program::UNIFORM_UNKNOWN != location )
      {
开发者ID:Tarnyko,项目名称:dali-core,代码行数:67,代码来源:scene-graph-mesh-renderer.cpp


注:本文中的Matrix3::Transpose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。