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)); }
//-------------------------------------------------------------------- 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])); }
//-------------------------------------------------------- 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));//шукаєм площу }
//-------------------------------------------------------------------- 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; }
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]; }
/// radius of its inscribed circle double Triangle::InRadius() const { // r = 2*area/perimeter return 2*Area()/Perimeter(); }
//------------------------------------------------------------------------------ // Функции вычисления периметра прямоугольника-специализации double Perimeter(FigRectangle& fr) { Rectangle& r = fr._spec; return Perimeter(r); }
void Compute(void) { qsort(horizontal, P, sizeof(LINE), compare); qsort(vertical, P, sizeof(LINE), compare); L = Perimeter(horizontal) + Perimeter(vertical); }