Ejemplo n.º 1
0
/*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;
}
Ejemplo n.º 2
0
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);
}
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);
}
Ejemplo n.º 4
0
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;
}