本文整理汇总了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;
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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 ];
}
示例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;
}
示例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;
}
示例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 );
}
}