本文整理汇总了PHP中Math::pointDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::pointDiff方法的具体用法?PHP Math::pointDiff怎么用?PHP Math::pointDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::pointDiff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isHit
/**
* @param CannonBall|Point $object
* @return bool
*/
public function isHit($object)
{
if ($object instanceof CannonBall) {
$index = 0;
foreach ($object->pixels as $pixel) {
$pixelPosition = new Point($object->position->x + $pixel->x, $object->position->y + $pixel->y);
$am = Math::pointDiff($this->a, $pixelPosition);
$dot_am_ab = Math::dotProduct($am, $this->ab);
$dot_am_ac = Math::dotProduct($am, $this->ac);
if (0 < $dot_am_ab && $dot_am_ab < $this->dot_ab && (0 < $dot_am_ac && $dot_am_ac < $this->dot_ac)) {
unset($object->pixels[$index]);
return $pixelPosition;
}
$index++;
}
return false;
}
$point_m = $object;
$am = Math::pointDiff($this->a, $point_m);
$dot_am_ab = Math::dotProduct($am, $this->ab);
$dot_am_ac = Math::dotProduct($am, $this->ac);
if (0 < $dot_am_ab && $dot_am_ab < $this->dot_ab && (0 < $dot_am_ac && $dot_am_ac < $this->dot_ac)) {
return $point_m;
}
return false;
}
示例2: isHit
/**
* @param CannonBall $object
* @return bool
*/
public function isHit($object)
{
if ($object instanceof CannonBall) {
foreach ($object->pixels as $pixel) {
if (!$pixel->destroyedLocation) {
$currentPosition = Math::pointSum($object->position, $pixel);
$previousPosition = Math::pointSum($object->previousPosition, $pixel);
if (!$this->triggered && ($currentPosition->x >= $this->position->x && $previousPosition->x <= $this->position->x)) {
$diff = Math::pointDiff($currentPosition, $previousPosition);
$slope = 0;
if ($diff->x != 0) {
$slope = -1 * ($diff->y / $diff->x);
}
$intercept = $this->position->y - $previousPosition->y;
$intersectPoint = new Point($this->position->x, $this->position->y + ($slope * ($this->position->x - $previousPosition->x) - $intercept));
if ($intersectPoint->y >= $this->position->y && $intersectPoint->y <= $this->position->y + 13) {
$this->triggered = true;
$this->powerCordColor = Color::WHITE;
return $this->triggered;
}
}
}
}
}
return false;
}