Пример #1
0
void TriangleMesh::Updata_Object_Area ()
{
	area = 0;

	for ( size_t i = 0; i < num_of_triangle; i++ )
		area += GetTriangleArea( i );

	//	return area;
}
Пример #2
0
static Vec3 BarycentricInterpolation (const Vec3& vertex0, const Vec3& vertex1, const Vec3& vertex2,
									   const Vec3& value0, const Vec3& value1, const Vec3& value2,
									   const Vec3& interpolationVertex)
{
	double edge0 = Distance (vertex0, vertex1);
	double edge1 = Distance (vertex1, vertex2);
	double edge2 = Distance (vertex2, vertex0);

	double distance0 = Distance (vertex0, interpolationVertex);
	double distance1 = Distance (vertex1, interpolationVertex);
	double distance2 = Distance (vertex2, interpolationVertex);

	double area = GetTriangleArea (edge0, edge1, edge2);
	if (IsZero (area)) {
		return value0;
	}

	double area0 = GetTriangleArea (edge0, distance0, distance1);
	double area1 = GetTriangleArea (edge1, distance1, distance2);
	double area2 = GetTriangleArea (edge2, distance0, distance2);

	Vec3 interpolated = (value0 * area1 + value1 * area2 + value2 * area0) / area;
	return interpolated;
}