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


C++ Triangle类代码示例

本文整理汇总了C++中Triangle的典型用法代码示例。如果您正苦于以下问题:C++ Triangle类的具体用法?C++ Triangle怎么用?C++ Triangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Point

/**
 * \brief Transform from current triangle to the target triangle
 */
Transform	Triangle::to(const Triangle& target) const {
	double	rotation = rotate_to(target);
	double	scale = scale_to(target);
	Transform	result(rotation, Point(), scale);
	Point	translation = target.basepoint() - result(basepoint());
	result = result + translation;
	return result;
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:11,代码来源:Triangle.cpp

示例2: getMeshBoundingBox

std::pair<PointCGAL,PointCGAL> getMeshBoundingBox(MeshData &meshData)
{
	std::list<Triangle> meshTriangles = meshData.first;
	std::list<PointCGAL> pointsInMesh;
	std::list<Triangle>::iterator triangleIter;
	for(triangleIter = meshTriangles.begin(); triangleIter != meshTriangles.end(); ++triangleIter)
	{
		Triangle t = *triangleIter;
		pointsInMesh.push_back(t.vertex(0));
		pointsInMesh.push_back(t.vertex(1));
		pointsInMesh.push_back(t.vertex(2));
	}

	Kernel::Iso_cuboid_3 isoCuboid = CGAL::bounding_box(pointsInMesh.begin(), pointsInMesh.end());

	return std::pair<PointCGAL,PointCGAL>(isoCuboid.min(), isoCuboid.max());
}
开发者ID:Sunwinds,项目名称:larmor-physx,代码行数:17,代码来源:DelaunayVoronoi.cpp

示例3:

BaseBuilding::BaseBuilding(const Triangle& t, const unsigned int& typeCentre, const double& heightMax)
{
	listPoints.push_back(t[0]);
	listPoints.push_back(t[1]);
	listPoints.push_back(t[2]);
	airMin = t.Area()*0.3;
	setBuildingInfo(typeCentre, heightMax);
}
开发者ID:khcao,项目名称:CSE-167-Final-Project,代码行数:8,代码来源:BaseBuilding.cpp

示例4: main

int main(void)
{
   Rectangle Rect;
   Triangle  Tri;

   Rect.setWidth(5);
   Rect.setHeight(7);
   // Print the area of the object.
   cout << "Total Rectangle area: " << Rect.getArea() << endl;

   Tri.setWidth(5);
   Tri.setHeight(7);
   // Print the area of the object.
   cout << "Total Triangle area: " << Tri.getArea() << endl;

   return 0;
}
开发者ID:VicPopescu,项目名称:Cpp,代码行数:17,代码来源:main.cpp

示例5: main

int main(){
	
	double x1,y1,x2,y2,x3,y3;

    const double pi = acos(-1);

    while ( scanf("%lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3) != EOF ){

        Triangle t = Triangle(Point(x1,y1),Point(x2,y2),Point(x3,y3));

        double circun = 2.0 *  t.circumradius() * pi;

        printf("%.2lf\n", circun);
    }

	return 0;
}
开发者ID:gutioliveira,项目名称:Algorithms,代码行数:17,代码来源:438.cpp

示例6:

Batiment::Batiment(const Triangle& t, const unsigned int& typeCentre, const double& hauteurMax)
{
	listePoints.push_back(t[0]);
	listePoints.push_back(t[1]);
	listePoints.push_back(t[2]);
	airMin = t.Area()*0.3;
	setBatimentInfos(typeCentre, hauteurMax);
}
开发者ID:carlos-felipe88,项目名称:City-procedural-modeling,代码行数:8,代码来源:Batiment.cpp

示例7: findIntersection

// the function for finding the intersection point between traingle and ray
// Solve the equation: t = -(Po . N + d) / (V . N) and P = Po + tV
Point findIntersection(Point init , Point v , Triangle triangle){
  
  Point p1 = triangle.getX();
  Point p2 = triangle.getY();
  Point p3 = triangle.getZ();
  
  Point p12 = pointDifference(p1,p2);
  Point p13 = pointDifference(p1,p3);
    
  Point normal = crossProduct(p12 , p13);
  
  double t = (normal.getX() * p1.getX() + normal.getY() * p1.getY() + normal.getZ() * p1.getZ() - normal.getX() * init.getX() - normal.getY() * init.getY() - normal.getZ() * init.getZ())/(normal.getX()*v.getX() + normal.getY() * v.getY() + normal.getZ() * v.getZ());
  
  Point result( init.getX() + t * v.getX() , init.getY() + t * v.getY() , init.getZ() + t * v.getZ() ); 
  
  return result;
}
开发者ID:asadzia,项目名称:PLY-File-Parser,代码行数:19,代码来源:Main.cpp

示例8: gen_pseudo_random

Triangle gen_pseudo_random() {
	int k;
	long long t, mod;
	Triangle r;
	
	//Init
	t = 0;
	mod = 1048576;
	
	for(k = 1; k <= 500500; k++) {
		t = (615949 * t + 797807) % mod;
		
		r.push_back(t - 524288);
	}
	
	return r;
}
开发者ID:IamLupo,项目名称:Project-Euler,代码行数:17,代码来源:main.cpp

示例9: cast

	QModelIndex cast( NifModel * nif, const QModelIndex & index )
	{
		if ( nif->isArray( index ) )
		{
			QVector<Triangle> tris = nif->getArray<Triangle>( index );
			for ( int t = 0; t < tris.count(); t++ )
				tris[t].flip();
			nif->setArray<Triangle>( index, tris );
		}
		else
		{
			Triangle t = nif->get<Triangle>( index );
			t.flip();
			nif->set<Triangle>( index, t );
		}
		return index;
	}
开发者ID:Alphax,项目名称:nifskope,代码行数:17,代码来源:mesh.cpp

示例10: isTriangleInTriangle

bool isTriangleInTriangle(Triangle& trig1, Triangle& trig2) 
{
	if(trig1.isPointInsideFigure(trig2.getFstEdge()) && trig1.isPointInsideFigure(trig2.getSndEdge()) && trig1.isPointInsideFigure(trig2.getThrdEdge()))
		return true;
		
	if(trig2.isPointInsideFigure(trig1.getFstEdge()) && trig2.isPointInsideFigure(trig1.getSndEdge()) && trig2.isPointInsideFigure(trig1.getThrdEdge()))
		return true;
		
	return false;
}
开发者ID:HarisonP,项目名称:OOP-exams-and-homeworks,代码行数:10,代码来源:Source.cpp

示例11: while

void FractureObject::ExpandComponent(FractureComponent * comp, Triangle * start)
{
    std::queue<Triangle *> procList;
    procList.push(start);

    while(procList.size() > 0) {
        //Pop the next triangle from the queue
        Triangle * t = procList.front(); procList.pop();
        //Check that its still valid(not visited) and if so, add to component
        //and indicate that its visited
        if(t->IsVisited())
            continue;
        comp->AddTriangle(t);
        t->SetIsVisited(true);
        t->SetFractureGroup(comp->compId);

        //Now check to see if it can add any of its neighbors
        for(unsigned int i = 0; i < 3; i++) {
            //Check that there's a triangle adjacent to this and that the edge is not
            //a fracture edge
            if(t->GetEdge(i)->GetRefCount() > 1 &&
                t->GetEdge(i)->IsFracture() == false) {
                    //(t->GetEdge(i)->GetVertex(0)->GetFracture() == false ||
                    //t->GetEdge(i)->GetVertex(1)->GetFracture() == false)) {
                    const Triangle * next = t->GetEdge(i)->GetOtherTriangle(t);
                    if(!next->IsVisited())
                        procList.push((Triangle *)next);
            }
        }
    }
}
开发者ID:TLCasella,项目名称:FractureUtility,代码行数:31,代码来源:Fractures.cpp

示例12: if

//=============================================================================
// That we're passing in a visitation key is actually a sign that there's
// a more fundamental bug going on.
SurfaceMesh::Vertex* SurfaceMesh::Edge::FindAdjacentVertex( VertexType vertexType, int visitationKey ) const
{
	// Which vertex are we pivoting about?
	Vertex* pivotVertex = 0;
	if( vertexType == CCW_VERTEX )
		pivotVertex = vertex[0];
	else if( vertexType == CW_VERTEX )
		pivotVertex = vertex[1];
	assert->Condition( pivotVertex != 0, "Null pivot vertex!" );

	// Find the last triangle we can find while winding about that vertex
	// in the desired direction.
	bool windingTriangleFound = false;
	Triangle* windingTriangle = triangle;
	do
	{
		if( windingTriangle->visitationKey == visitationKey )
			break;
		windingTriangle->visitationKey = visitationKey;
		int vertexIndex = windingTriangle->FindVertexIndex( pivotVertex );
		int triangleIndex = -1;
		if( vertexType == CCW_VERTEX )
			triangleIndex = ( vertexIndex + 2 ) % 3;
		else if( vertexType == CW_VERTEX )
			triangleIndex = vertexIndex;
		Triangle* adjacentTriangle = windingTriangle->adjacentTriangle[ triangleIndex ];
		if( !adjacentTriangle )
			windingTriangleFound = true;
		else
			windingTriangle = adjacentTriangle;
	}
	while( !windingTriangleFound );
	
	// Return null if the edge doesn't have such a vertex.
	if( !windingTriangleFound )
		return 0;

	// Return the correct vertex of the found triangle.
	int vertexIndex = windingTriangle->FindVertexIndex( pivotVertex );
	if( vertexType == CCW_VERTEX )
		vertexIndex = ( vertexIndex + 2 ) % 3;
	else if( vertexType == CW_VERTEX )
		vertexIndex = ( vertexIndex + 1 ) % 3;
	return windingTriangle->vertex[ vertexIndex ];
}
开发者ID:spencerparkin,项目名称:GAVisTool,代码行数:48,代码来源:SurfaceMesh.cpp

示例13: main

int main()
{
	//circle tests
	Circle newCircle = Circle(2);
	cout << "newCircle radius is: " << newCircle.getRadius() << endl;
	newCircle.incSides(3);
	cout << "newCircle radius is: " << newCircle.getRadius() << endl;
	std::cin.get();

	//rectangle tests
	Rectangle newRectangle = Rectangle(2, 3);
	cout << "newRectangle side1, side2: " << newRectangle.getSide1() << " , " << newRectangle.getSide2() << endl;
	newRectangle.incSides(3);
	cout << "newRectangle side1, side2: " << newRectangle.getSide1() << " , " << newRectangle.getSide2() << endl;
	std::cin.get();

	//triangle tests
	Triangle newTriangle = Triangle(5, 5, 5);
	cout << "newTriangle side1, side2, side3: " << newTriangle.getSide1() << " , " << newTriangle.getSide2() << " , " << newTriangle.getSide3() << endl;
	cout << "newTriangle's area: " << newTriangle.area() << endl;
	newTriangle.incSides(3);
	cout << "newTriangle side1, side2, side3: " << newTriangle.getSide1() << " , " << newTriangle.getSide2() << " , " << newTriangle.getSide3() << endl;
	std::cin.get();

	return 0;
}
开发者ID:giorosati,项目名称:CS199_Proj02_Inheritance_Recursion,代码行数:26,代码来源:proj2.cpp

示例14: Incircle

bool Sweep::Legalize(SweepContext& tcx, Triangle& t)
{
  // To legalize a triangle we start by finding if any of the three edges
  // violate the Delaunay condition
  for (int i = 0; i < 3; i++) {
    if (t.delaunay_edge[i])
      continue;

    Triangle* ot = t.GetNeighbor(i);

    if (ot) {
      Point* p = t.GetPoint(i);
      Point* op = ot->OppositePoint(t, *p);
      int oi = ot->Index(op);

      // If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)
      // then we should not try to legalize
      if (ot->constrained_edge[oi] || ot->delaunay_edge[oi]) {
        t.constrained_edge[i] = ot->constrained_edge[oi];
        continue;
      }

      bool inside = Incircle(*p, *t.PointCCW(*p), *t.PointCW(*p), *op);

      if (inside) {
        // Lets mark this shared edge as Delaunay
        t.delaunay_edge[i] = true;
        ot->delaunay_edge[oi] = true;

        // Lets rotate shared edge one vertex CW to legalize it
        RotateTrianglePair(t, *p, *ot, *op);

        // We now got one valid Delaunay Edge shared by two triangles
        // This gives us 4 new edges to check for Delaunay

        // Make sure that triangle to node mapping is done only one time for a specific triangle
        bool not_legalized = !Legalize(tcx, t);
        if (not_legalized) {
          tcx.MapTriangleToNodes(t);
        }

        not_legalized = !Legalize(tcx, *ot);
        if (not_legalized)
          tcx.MapTriangleToNodes(*ot);

        // Reset the Delaunay edges, since they only are valid Delaunay edges
        // until we add a new triangle or point.
        // XXX: need to think about this. Can these edges be tried after we
        //      return to previous recursive level?
        t.delaunay_edge[i] = false;
        ot->delaunay_edge[oi] = false;

        // If triangle have been legalized no need to check the other edges since
        // the recursive legalization will handles those so we can end here.
        return true;
      }
    }
  }
  return false;
}
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:60,代码来源:sweep.cpp

示例15: Zero

//=============================================================================
void SurfaceMesh::PathConnectedComponent::CalculateVertexNormals( void )
{
	for( Vertex* vertex = ( Vertex* )vertexList.LeftMost(); vertex; vertex = ( Vertex* )vertex->Right() )
	{
		Zero( vertex->normal );
		double triangleCount = 0.0;
		for( Triangle* triangle = ( Triangle* )triangleList.LeftMost(); triangle; triangle = ( Triangle* )triangle->Right() )
		{
			if( triangle->FindVertexIndex( vertex ) != -1 )
			{
				triangleCount += 1.0;
				Add( vertex->normal, vertex->normal, triangle->normal );
			}
		}
		Scale( vertex->normal, vertex->normal, 1.0 / triangleCount );
		Normalize( vertex->normal, vertex->normal );
	}
}
开发者ID:spencerparkin,项目名称:GAVisTool,代码行数:19,代码来源:SurfaceMesh.cpp


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