A convex polygon is a simple polygon in which no line segment between two points on the boundary ever goes outside the polygon
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
getArea();
}
echo "Area of the polygon:\n";
echo $sum . "\n";
}
class Triangle {
public $A, $B, $C;
public $a, $b, $c;
public function __construct(Point $A, Point $B, Point $C) {
$this->A = $A;
$this->B = $B;
$this->C = $C;
$this->a = $B->distanceFrom($C);
$this->b = $C->distanceFrom($A);
$this->c = $A->distanceFrom($B);
}
public function getArea() {
$z = ($this->a + $this->b + $this->c) / 2;
return sqrt($z * ($z - $this->a) * ($z - $this->b) * ($z - $this->c));
}
}
class Point {
public $x, $y;
public function __construct($x, $y) {
$this->x = $x;
$this->y = $y;
}
public function distanceFrom(Point $p) {
$dx = $this->x - $p->x;
$dy = $this->y - $p->y;
return sqrt($dx * $dx + $dy * $dy);
}
}
?>
Sample Input:
1.0, 0.0
0.0, 0.0
1.0, 1.0
2.0, 0.0
-1.0, 1.0
Sample Output:
Area of the polygon: 1.5
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال

