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


C++ Matrix3x3::inverse方法代码示例

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


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

示例1: SetPMat

void PPC::SetPMat(){
	Matrix3x3 cam;
	cam.setColumn(0, a);
	cam.setColumn(1, b);
	cam.setColumn(2, c);
	pMat = cam.inverse();
}
开发者ID:ehissey,项目名称:CS434-1,代码行数:7,代码来源:ppc.cpp

示例2: lookAt

void Node::lookAt( const math::Vector3& target, const math::Vector3& up )
{
	assert( Math::abs(up.length()-1.f) < 1e-3f ); // Up direction must be normalized

	// src parent->world space
	Matrix4x4 parentToWorld = Matrix4x4(1);
	const Node* parent = this->parent();
	while ( parent )
	{
		parentToWorld = parent->transform() * parentToWorld;
		parent = parent->parent();
	}

	// src->world space
	Matrix4x4 sourceToWorld = parentToWorld * transform();

	// src -> target (world space)
	Vector3 sourceRotZ = target - sourceToWorld.translation();
	if ( sourceRotZ.lengthSquared() > Float::MIN_VALUE )
	{
		// src->target direction (world space)
		sourceRotZ = sourceRotZ.normalize();

		// src rotation (world space)
		Vector3 sourceRotX = up.cross( sourceRotZ );
		if ( sourceRotX.lengthSquared() > Float::MIN_VALUE )
			sourceRotX = sourceRotX.normalize();
		else
			sourceRotX = Vector3(1,0,0);
		Vector3 sourceRotY = sourceRotZ.cross( sourceRotX );
		Matrix3x3 sourceRot;
		sourceRot.setColumn( 0, sourceRotX );
		sourceRot.setColumn( 1, sourceRotY );
		sourceRot.setColumn( 2, sourceRotZ );

		// src world space rotation back to src parent space
		Matrix3x3 parentToWorldRot = parentToWorld.rotation();
		Matrix3x3 rot = sourceRot * parentToWorldRot.inverse();
		setRotation( rot );
	}
}
开发者ID:TheRyaz,项目名称:c_reading,代码行数:41,代码来源:Node.cpp

示例3: zero

std::vector<Line2D> generateCrossSectionBounds(int edge,int frame,const Compound* compound,const Matrix3x3& polyBasisToStdBasis,bool symmetrize)
{
    Line refEdge=compound->getPolyhedron(frame)->getEdgeLine(edge);
    Point midpoint=refEdge.getMidpoint();
    Matrix3x3 stdBasisToPolyBasis=polyBasisToStdBasis.inverse();
    Plane z0=planeThroughPointPerpendicularToLine(midpoint, refEdge);
    
    Point zero(0,0,0);
    Line zeroLine(zero,zero);
    
    //make vectors containing cross section lines
    std::vector<Line2D> crossSection2D; //cross section lines expressed in poly basis (in 2D, z-component is ignored since the cross section is the same along the axis of the edge)
    double compoundCylinder=compound->computeWidth();
    
    for (int i=0;i<compound->getNumberOfPolyhedra();i++)
    {
        if (i==frame) {continue;}
        const Polyhedron* poly=compound->getPolyhedron(i);
        for (int j=0;j<poly->getEdgeNum();j++)
        {
            Line edge=poly->getEdgeLine(j);
            Line closeApproach=lineOfClosestApproach(edge, refEdge);
            if (closeApproach==zeroLine) {continue;} //REDO THIS: closest approach occurs outside the line segments + oa buffers
            
            Point mid=closeApproach.getMidpoint();
            Plane thePlane=planeThroughPointPerpendicularToLine(mid, closeApproach); //plane separating the two line segments
            Line intersection=planePlaneIntersection(z0, thePlane); //intersection of this plane with the xy-plane of the poly basis
            
            if (intersection==zeroLine) {continue;} //the two planes are parallel
            
            Point v1=intersection.getPointA()-midpoint;
            Point v2=intersection.getPointB()-midpoint;
            Point basis1=vectorInBasis(stdBasisToPolyBasis, v1);
            Point basis2=vectorInBasis(stdBasisToPolyBasis, v2);
            Line basisLine=Line(basis1,basis2); //find the intersection line in poly basis
            
            Line2D basisLine2d=lineToLine2D(basisLine); //intersection line in poly basis without z-component (z should be 0 anyway)
            if (closeApproach.getDistance()<compoundCylinder)
            {
                std::cout << "Error: cross section line is closer than cylinder radius. oa most likely too large\n";
                double closeDist=segmentSegmentDist(edge, refEdge);
                std::string different=(fabs(closeDist-closeApproach.getDistance())>EPS)?"???":"";
                std::cout << i << " " << j << " ";
                std::cout << lineOfClosestApproach(edge, refEdge,true).getDistance() << " ";
                std::cout << closeDist << " ";
                std::cout << different << " ";
                std::cout << basisLine2d.toString() << "\n\n";
            }
            
            crossSection2D.push_back(lineToLine2D(basisLine));
            if (symmetrize)
            {
                double newm=-1*basisLine2d.getSlope();
                double newb=basisLine2d.getYIntercept();
                Line2D reflect(newm,newb);
                crossSection2D.push_back(reflect);
            }
        }
    }
    return crossSection2D;
}
开发者ID:apfitzen,项目名称:Wireframes-Calc,代码行数:61,代码来源:PPHAlgorithms.cpp

示例4: Render

void TMesh::Render(PPC * ppc, FrameBuffer *fb, PointLight *pl, bool wireframe, Envmap *env){
	if(trisN == 0 && vertsN != 0){
		RenderPoints(ppc,fb,3);
		return;
	}else if(trisN == 0 && vertsN == 0){
		return;
	}
	
	Vector3D *projVerts = new Vector3D[vertsN];

	for(int i = 0; i < vertsN; i++){
		projVerts[i] = Vector3D(FLT_MAX, FLT_MAX, FLT_MAX);
		ppc->Project(verts[i], projVerts[i]);
	}

	for(int i = 0; i < trisN; i++){
		int currTri = i;

		unsigned int vinds[3];
		vinds[0] = tris[3*i+0];
		vinds[1] = tris[3*i+1];
		vinds[2] = tris[3*i+2];

		if(wireframe){
			for(int j = 0; j < 3; j++){
				fb->DrawSegment(projVerts[vinds[j]], projVerts[vinds[(j+1)%3]], cols[vinds[j]], cols[vinds[(j+1)%3]]);
			}

			continue;
		}

		//Setup Rasterization

		//Create AABB
		AABB aabb = AABB(projVerts[vinds[0]]);
		aabb.AddPoint(projVerts[vinds[1]]);
		aabb.AddPoint(projVerts[vinds[2]]);

		if(!aabb.Clip(fb->w, fb->h)){
			continue;
		}

		int top = (int) (0.5f + aabb.corners[0][1]);
		int left = (int) (0.5f + aabb.corners[0][0]);
		int bottom = (int) (-0.5f + aabb.corners[1][1]);
		int right = (int) (-0.5f + aabb.corners[1][0]);

		//Edge equations
		Vector3D eeqs[3];

		for(int i = 0; i < 3; i++){
			int _i = (i+1)%3;

			eeqs[i][0] = projVerts[vinds[_i]][1] - projVerts[vinds[i]][1];
			eeqs[i][1] = projVerts[vinds[i]][0] - projVerts[vinds[_i]][0];
			eeqs[i][2] = projVerts[vinds[i]][1] * (-eeqs[i][1]) - projVerts[vinds[i]][0] * eeqs[i][0];

			int _i2 = (i+2)%3;

			Vector3D v3 = Vector3D(projVerts[vinds[_i2]][0], projVerts[vinds[_i2]][1], 1.0f);

			if(v3*eeqs[i] < 0){
				eeqs[i] = -1.0f * eeqs[i];
			}
		}

		//Screen Space Interpolation
		Matrix3x3 ssii = Matrix3x3();
		ssii[0] = projVerts[vinds[0]]; ssii[0][2] = 1.0f;
		ssii[1] = projVerts[vinds[1]]; ssii[1][2] = 1.0f;
		ssii[2] = projVerts[vinds[2]]; ssii[2][2] = 1.0f;
		ssii = ssii.inverse();

		//Color interpolation
		Matrix3x3 tcols = Matrix3x3();
		tcols[0] = cols[vinds[0]];
		tcols[1] = cols[vinds[1]];
		tcols[2] = cols[vinds[2]];

		if(gouraud){ //Apply lighting before creating interpolation matrix
			Vector3D toPL;
			Vector3D norm;

			Vector3D eyeV;
			Vector3D reflectedToPL;

			for(int i = 0; i < 3; i++){
				toPL = (pl->pos - verts[vinds[i]]).normalize();
				norm = (normals[vinds[i]]).normalize();

				eyeV = (ppc->C - verts[vinds[i]]).normalize();
				reflectedToPL = (2.0f * norm * (norm * toPL) - toPL).normalize();

				kdiff = toPL * norm;
				if(kdiff < 0.0f){
					kdiff = 0.0f;
				}

				float temp = reflectedToPL * eyeV;

//.........这里部分代码省略.........
开发者ID:ehissey,项目名称:CS434-1,代码行数:101,代码来源:tmesh.cpp


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