// Using the FD points package library use PhpGeometry\FDPoints; // Define two points $point1 = new Point(0, 0); $point2 = new Point(3, 4); // Calculate the distance between the two points $distance = FDPoints::distance($point1, $point2); // Output the distance echo "The distance between the two points is: " . $distance;
// Using the FD points package library use PhpGeometry\FDPoints; // Define two points $point1 = new Point(0, 0); $point2 = new Point(6, 8); // Calculate the midpoint of the line segment $midpoint = FDPoints::midpoint($point1, $point2); // Output the midpoint echo "The midpoint of the line segment is: " . $midpoint->getX() . "," . $midpoint->getY();Package library: PhpGeometry\FDPoints