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


C++ Triangle::Area方法代码示例

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


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

示例1: Area

/*virtual*/ bool Triangle::CalculateSurfacePoint(const Scene::Ray& ray, const Scene& scene, Scene::SurfacePoint& surfacePoint) const
{
	Plane plane;
	plane.center = vertex[0];
	plane.normal = c3ga::unit( c3ga::gp( c3ga::op( vertex[1] - vertex[0], vertex[2] - vertex[0] ), c3ga::I3 ) );

	if( !plane.CalculateSurfacePoint( ray, scene, surfacePoint ) )
		return false;

	double area = Area();
	double totalSubArea = 0.0;

	for( int i = 0; i < 3; i++ )
	{
		Triangle subTriangle;
		c3ga::vectorE3GA* vertexPtr = subTriangle.vertex;
		*vertexPtr++ = surfacePoint.point;
		for( int j = 0; j < 3; j++ )
			if( j != i )
				*vertexPtr++ = vertex[j];

		double subArea = subTriangle.Area();
		totalSubArea += subArea;
	}

	double eps = 1e-4;
	if( fabs( totalSubArea - area ) < eps )
		return true;

	return false;
}
开发者ID:spencerparkin,项目名称:ImageGenerator,代码行数:31,代码来源:Triangle.cpp

示例2:

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

示例3:

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

示例4: main

int main() {
	int 		i;
	double		a[2]	= { 0.0, 0.0 };
	double		b[2]	= { 0.0, 2.0 };
	double		c[2]	= { 2.0, 0.0 };
	Triangle* 	tri 	= new Triangle( a, b, c, TRI_ORDER );

	cout << "triangle area: " << tri->Area() << endl;

	cout << "triangle vertices: " << endl;
	cout << "[" << tri->a[0] << "," << tri->a[1] << "]" << endl;
	cout << "[" << tri->b[0] << "," << tri->b[1] << "]" << endl;
	cout << "[" << tri->c[0] << "," << tri->c[1] << "]" << endl;

	cout << "quadrature coords: " << endl;
	for( i = 0; i < tri->nq; i++ ) {
		cout << "[" << tri->qi[i][0] << "," << tri->qi[i][1] << "]" << endl;
	}

	return 1;
}
开发者ID:davelee2804,项目名称:cdg,代码行数:21,代码来源:TriangleTest.cpp


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