当前位置: 首页>>代码示例>>PHP>>正文


PHP Point::distance方法代码示例

本文整理汇总了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;
 }
开发者ID:AlgorithmsNYC,项目名称:AlgorithmsNYC,代码行数:7,代码来源:point.class.php

示例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++;
         }
     }
 }
开发者ID:AlgorithmsNYC,项目名称:AlgorithmsNYC,代码行数:32,代码来源:graph.class.php

示例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);
开发者ID:Nisaiy,项目名称:DeveloperClub,代码行数:31,代码来源:Point.php

示例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;
 }
开发者ID:AlgorithmsNYC,项目名称:AlgorithmsNYC,代码行数:14,代码来源:polygon.class.php

示例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>
开发者ID:keypointt,项目名称:516hws,代码行数:22,代码来源:use_point.php


注:本文中的Point::distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。