本文整理汇总了PHP中Point::distance方法的典型用法代码示例。如果您正苦于以下问题:PHP Point::distance方法的具体用法?PHP Point::distance怎么用?PHP Point::distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::distance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aireTriangle
static function aireTriangle($pointA, $pointB, $pointC)
{
$AB = Point::distance($pointA, $pointB);
$BC = Point::distance($pointB, $pointC);
$AC = Point::distance($pointC, $pointA);
return sqrt(($AB + $BC + $AC) * (-$AB + $BC + $AC) * ($AB - $BC + $AC) * ($AB + $BC - $AC)) / 4;
}
示例2: random_point_generation_disk
public function random_point_generation_disk($sizeX, $minDist, $maxDist)
{
$sizeY = $sizeX;
// Initial point generation
$this->add_point(new Point(round($sizeX / 2), round($sizeY / 2), '0'));
$initialPoint = reset($this->vertices);
for ($i = 65; $i < 91; $i++) {
$letters[] = chr($i);
}
for ($i = 97; $i < 123; $i++) {
$letters[] = chr($i);
}
$i = 0;
// Point creation procedure
$maxMissedPoints = 1000;
$missedPointCount = 0;
while ($missedPointCount < $maxMissedPoints) {
$x = rand(0, $sizeX - 1);
$y = rand(0, $sizeY - 1);
$point = new Point($x, $y, $letters[$i]);
$pointCreationFlag = false;
if (Point::distance($point, $initialPoint) <= $sizeX / 2) {
$pointCreationFlag = $this->add_point($point, $minDist, $maxDist);
}
if ($pointCreationFlag) {
$missedPointCount = 0;
$i++;
} else {
$missedPointCount++;
}
}
}
示例3: __get
$this->y = $this->validate($y);
}
public function __get($name)
{
return $this->{$name};
}
public function __set($name, $value)
{
$this->{$name} = $this->validate($value);
}
public function distance(Point $other)
{
return hypot($this->x - $other->x, $this->y - $other->y);
}
public function __toString()
{
return sprintf("(%g, %g)", $this->x, $this->y);
}
}
function compare($x, $y)
{
if ($x == $y) {
echo $x . " is equal to " . $y . PHP_EOL;
} else {
echo $x . " is not equal to " . $y . PHP_EOL;
}
}
$object = new Point(1, "a");
$object1 = new Point(6, 0);
echo $object->distance($object1) . PHP_EOL;
var_dump($object);
示例4: getPerimeter
public function getPerimeter()
{
$return = null;
if (count($this->points) >= 2) {
$perimeterPoints = $this->points;
$perimeterPoints[] = $perimeterPoints[0];
$perimeter = 0;
for ($i = 0; $i < count($this->points); $i++) {
$perimeter += Point::distance($perimeterPoints[$i], $perimeterPoints[$i + 1]);
}
$return = $perimeter;
}
return $return;
}
示例5: Point
<!DOCTYPE HTML>
<html>
<body>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
?>
<?php
# this code could go into a file named use_point.php
include "Point.php";
$p1 = new Point(0.0, 0.0);
$p2 = 3;
print "Distance between {$p1} and {$p2} is " . $p1->distance($p2) . "\n\n";
var_dump($p2);
# var_dump prints detailed state of an object
?>
</body>
</html>