本文整理汇总了PHP中Point::x方法的典型用法代码示例。如果您正苦于以下问题:PHP Point::x方法的具体用法?PHP Point::x怎么用?PHP Point::x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::x方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: push
public function push(Point $point)
{
if (!isset($this->boundary[0]) || $this->boundary[0] > $point->x()) {
$this->boundary[0] = $point->x();
}
if (!isset($this->boundary[1]) || $this->boundary[1] > $point->y()) {
$this->boundary[1] = $point->y();
}
if (!isset($this->boundary[2]) || $this->boundary[2] < $point->x()) {
$this->boundary[2] = $point->x();
}
if (!isset($this->boundary[3]) || $this->boundary[3] < $point->y()) {
$this->boundary[3] = $point->y();
}
return $this;
}
示例2: encodePoint
/**
* @return string geohash
* @param Point $point
* @author algorithm based on code by Alexander Songe <a@songe.me>
* @see https://github.com/asonge/php-geohash/issues/1
*/
private function encodePoint($point, $precision = NULL)
{
if ($precision === NULL) {
$lap = strlen($point->y()) - strpos($point->y(), ".");
$lop = strlen($point->x()) - strpos($point->x(), ".");
$precision = pow(10, -max($lap - 1, $lop - 1, 0)) / 2;
}
$minlat = -90;
$maxlat = 90;
$minlon = -180;
$maxlon = 180;
$latE = 90;
$lonE = 180;
$i = 0;
$error = 180;
$hash = '';
while ($error >= $precision) {
$chr = 0;
for ($b = 4; $b >= 0; --$b) {
if ((1 & $b) == (1 & $i)) {
// even char, even bit OR odd char, odd bit...a lon
$next = ($minlon + $maxlon) / 2;
if ($point->x() > $next) {
$chr |= pow(2, $b);
$minlon = $next;
} else {
$maxlon = $next;
}
$lonE /= 2;
} else {
// odd char, even bit OR even char, odd bit...a lat
$next = ($minlat + $maxlat) / 2;
if ($point->y() > $next) {
$chr |= pow(2, $b);
$minlat = $next;
} else {
$maxlat = $next;
}
$latE /= 2;
}
}
$hash .= $this->table[$chr];
$i++;
$error = min($latE, $lonE);
}
return $hash;
}
示例3: fromVector
/**
* construct point from vector (pointing towards the point).
*/
public static function fromVector(Vector $vector)
{
$point = new Point();
$point->x($vector->x);
$point->y($vector->y);
$point->z($vector->z);
return $point;
}
示例4: contains
/**
* Checks whether the given point/pixel is in- or outside
* of this outline based on the PointPolygonTest of OpenCV.
*
* @see docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=pointpolygontest#pointpolygontest
*
* @param Point $point the point/pixel to check.
*
* @return integer whether the point/pixel is in- (1) or oudsite (2) or on the outline (0).
*
*/
public function contains(Point $point)
{
$intersections = 0;
$v2 = $this->outline[$this->size - 1];
for ($i = 0; $i < $this->size; $i++) {
$v1 = $v2;
$v2 = $this->outline[$i];
if ($v1->y() <= $point->y() && $v2->y() <= $point->y() || $v1->y() > $point->y() && $v2->y() > $point->y() || $v1->x() < $point->x() && $v2->x() < $point->x()) {
if ($point->y() == $v2->y() && ($point->x() == $v2->x() || $point->y() == $v1->y() && ($v1->x() <= $point->x() && $point->x() <= $v2->x() || $v2->x() <= $point->x() && $point->x() <= $v1->x()))) {
return 0;
}
continue;
}
$dist = ($point->y() - $v1->y()) * ($v2->x() - $v1->x()) - ($point->x() - $v1->x()) * ($v2->y() - $v1->y());
if ($dist == 0) {
return 0;
}
if ($v2->y() < $v1->y()) {
$dist = -$dist;
}
$intersections += $dist > 0;
}
// If the number of edges we passed through is odd, then it's in the polygon.
return $intersections % 2 == 0 ? -1 : 1;
}
示例5: cellAt
public function cellAt(Point $point) : Cell
{
return $this->cells[$point->y()][$point->x()];
}
示例6: getWeatherAlert
/**
* Get set of weather alerts for the given Point
*
* <strong>Only Polish area</strong>
* @param Point $point location coordinates
* @return WeatherAlert set of weather alerts
*/
public function getWeatherAlert(Point $point) : WeatherAlert
{
$dto = $this->client->ostrzezenia_pogodowe($point->y(), $point->x(), $this->apiKey);
return (new WeatherAlert())->withAlert('frost', new Alert($dto->mroz, $dto->mroz_od_dnia, $dto->mroz_do_dnia))->withAlert('heat', new Alert($dto->upal, $dto->upal_od_dnia, $dto->upal_do_dnia))->withAlert('wind', new Alert($dto->wiatr, $dto->wiatr_od_dnia, $dto->wiatr_do_dnia))->withAlert('storm', new Alert($dto->burza, $dto->burza_od_dnia, $dto->burza_do_dnia))->withAlert('tornado', new Alert($dto->traba, $dto->traba_od_dnia, $dto->traba_do_dnia))->withAlert('precipitation', new Alert($dto->opad, $dto->opad_od_dnia, $dto->opad_do_dnia));
}
示例7: equals
/**
* @param Point $point
* @return boolean
*/
public function equals(Point $point)
{
return $this->x() == $point->x() && $this->y() == $point->y();
}
示例8: fromPoints
public static function fromPoints(Point $point_a, Point $point_b)
{
$vector = new Vector();
$vector->xyz($point_b->x() - $point_a->x(), $point_b->y() - $point_a->y(), $point_b->z() - $point_a->z());
return $vector;
}