float IndexedTriangle::Compacity(const Point* verts) const
{
	if(!verts)	return 0.0f;
	float P = Perimeter(verts);
	if(P==0.0f)	return 0.0f;
	return (4.0f*PI*Area(verts)/(P*P));
}
Beispiel #2
0
//--------------------------------------------------------------------
Real ZFace::Area (const ZVectorCacheArray& v)
// Returns the area of the face
   {
   Real* ss = Sides(v); 
   Real p = Perimeter(v)/2;
   // Heron's formula
   return sqrt (p*(p-ss[0])*(p-ss[1])*(p-ss[2]));
   }
Beispiel #3
0
//--------------------------------------------------------
double Area(const Point& a, const Point& b,const Point& p)
{
	double A, B, C;
	A = Length(a, b);
	B = Length(b, p);
	C = Length(p, a);	
	double Per = Perimeter(A, B, C) / 2;
	return sqrt(Per * (Per - A) * (Per - B) * (Per - C));//шукаєм площу
}
Beispiel #4
0
//--------------------------------------------------------------------
Real ZFace::Density (const ZVectorCacheArray& v)
// Returns the Density of the face, which is the fraction of an 
// enclosing circle that it fills
   {
   Real c = Perimeter(v);
   Real a = Area(v);
   Real r = c/2/GmatMathConstants::PI;
   Real pir2 = GmatMathConstants::PI*r*r;
   return a/pir2;
   }
Beispiel #5
0
float3 Polygon::PointOnEdge(float normalizedDistance) const
{
	if (p.empty())
		return float3::nan;
	if (p.size() < 2)
		return p[0];
	normalizedDistance = Frac(normalizedDistance); // Take modulo 1 so we have the range [0,1[.
	float perimeter = Perimeter();
	float d = normalizedDistance * perimeter;
	for(int i = 0; i < NumVertices(); ++i)
	{
		LineSegment edge = Edge(i);
		float len = edge.Length();
		assume(len != 0.f && "Degenerate Polygon detected!");
		if (d <= len)
			return edge.GetPoint(d / len);
		d -= len;
	}
	mathassert(false && "Polygon::PointOnEdge reached end of loop which shouldn't!");
	return p[0];
}
Beispiel #6
0
 /// radius of its inscribed circle
 double Triangle::InRadius() const
 {
     // r = 2*area/perimeter
     return 2*Area()/Perimeter();
 }
Beispiel #7
0
//------------------------------------------------------------------------------
//  Функции вычисления периметра прямоугольника-специализации
double Perimeter(FigRectangle& fr) {
    Rectangle& r = fr._spec;
    return Perimeter(r);
}
Beispiel #8
0
void Compute(void) {
    qsort(horizontal, P, sizeof(LINE), compare);
    qsort(vertical, P, sizeof(LINE), compare);
    L = Perimeter(horizontal) + Perimeter(vertical);
}