本文整理汇总了PHP中pocketmine\math\Vector3::subtract方法的典型用法代码示例。如果您正苦于以下问题:PHP Vector3::subtract方法的具体用法?PHP Vector3::subtract怎么用?PHP Vector3::subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\math\Vector3
的用法示例。
在下文中一共展示了Vector3::subtract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isInside
/**
* Checks whether the passed {@link Vector3} is included in this {@link Space}.<br>
* Floating point vectors are accepted.<br>
* <br>
* The contents of this function are based on <a
* href="http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html">Wolfram|MathWorld: Point-Lne Distance
* (3-Dimensional)</a>, whereas {@code X0 = $v, X1 = $this->baseCenter, X2 = $this->topCenter}.
*
* @param Vector3 $v the coordinates to check.
*
* @return bool whether <code> $v</code> is inside the space.
*/
public function isInside(Vector3 $v)
{
if (!$this->isValid()) {
return false;
}
if ($v instanceof Position and $v->getLevel()->getName() !== $this->levelName) {
return false;
}
$distSquared = $v->subtract($this->baseCenter)->cross($v->subtract($this->topCenter))->lengthSquared() / $this->topCenter->subtract($this->baseCenter)->lengthSquared();
// |---|
return $distSquared <= $this->radiusSquared;
// |(X0 - X1) x (X0 - X2)| / |X2 - X1|
}