本文整理汇总了PHP中Math::sqrt方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::sqrt方法的具体用法?PHP Math::sqrt怎么用?PHP Math::sqrt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::sqrt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pickSizes
public function pickSizes($t)
{
$w = $t->get_width();
$h = $t->get_height();
$v = $t->getCellView();
$csv = new coopy_Csv(null);
$sizes = new _hx_array(array());
$row = -1;
$total = $w - 1;
$_g = 0;
while ($_g < $w) {
$x = $_g++;
$m = 0;
$m2 = 0;
$mmax = 0;
$mmostmax = 0;
$mmin = -1;
$_g1 = 0;
while ($_g1 < $h) {
$y = $_g1++;
$txt = $this->getText($x, $y, false);
if ($txt === "@@" && $row === -1) {
$row = $y;
}
$len = strlen($txt);
if ($y === $row) {
$mmin = $len;
}
$m += $len;
$m2 += $len * $len;
if ($len > $mmax) {
$mmax = $len;
}
unset($y, $txt, $len);
}
unset($_g1);
$mean = $m / $h;
$stddev = Math::sqrt($m2 / $h - $mean * $mean);
$most = Std::int($mean + $stddev * 2 + 0.5);
$_g11 = 0;
while ($_g11 < $h) {
$y1 = $_g11++;
$txt1 = $this->getText($x, $y1, false);
$len1 = strlen($txt1);
if ($len1 <= $most) {
if ($len1 > $mmostmax) {
$mmostmax = $len1;
}
}
unset($y1, $txt1, $len1);
}
unset($_g11);
$full = $mmax;
$most = $mmostmax;
if ($mmin !== -1) {
if ($most < $mmin) {
$most = $mmin;
}
}
$sizes->push($most);
$total += $most;
unset($x, $stddev, $most, $mmostmax, $mmin, $mmax, $mean, $m2, $m, $full);
}
if ($total > 130) {
return null;
}
return $sizes;
}
示例2: getMoonTimes
static function getMoonTimes($date, $lat, $lng, $inUTC = null)
{
if ($inUTC === null) {
$inUTC = false;
}
if ($inUTC) {
$this1 = datetime__DateTime_DateTime_Impl_::utc(suncalc_SunCalc_0($date, $inUTC, $lat, $lng));
$date = Date::fromTime(($this1 - 62135596800.0) * 1000);
$date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
} else {
$date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
}
$hc = 0.133 * suncalc_SunCalc::$rad;
$h0 = suncalc_SunCalc::getMoonPosition($date, $lat, $lng)->altitude - $hc;
$h1 = null;
$h2 = null;
$rise = 0.0;
$set = 0.0;
$a = null;
$b = null;
$xe = null;
$ye = 0.0;
$d = null;
$roots = null;
$x1 = 0.0;
$x2 = 0.0;
$dx = null;
$i = 1;
while ($i <= 24) {
$h1 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i), $lat, $lng)->altitude - $hc;
$h2 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i + 1), $lat, $lng)->altitude - $hc;
$a = ($h0 + $h2) / 2 - $h1;
$b = ($h2 - $h0) / 2;
$xe = -$b / (2 * $a);
$ye = ($a * $xe + $b) * $xe + $h1;
$d = $b * $b - 4 * $a * $h1;
$roots = 0;
if ($d >= 0) {
$dx = Math::sqrt($d) / (Math::abs($a) * 2);
$x1 = $xe - $dx;
$x2 = $xe + $dx;
if (Math::abs($x1) <= 1) {
$roots++;
}
if (Math::abs($x2) <= 1) {
$roots++;
}
if ($x1 < -1) {
$x1 = $x2;
}
}
if ($roots === 1) {
if ($h0 < 0) {
$rise = $i + $x1;
} else {
$set = $i + $x1;
}
} else {
if ($roots === 2) {
$rise = $i + ($ye < 0 ? $x2 : $x1);
$set = $i + ($ye < 0 ? $x1 : $x2);
}
}
if (!_hx_equal($rise, 0) && !_hx_equal($set, 0)) {
break;
}
$h0 = $h2;
$i += 2;
}
$result = new haxe_ds_StringMap();
if (!_hx_equal($rise, 0)) {
$v = suncalc_SunCalc::hoursLater($date, $rise);
$result->set("rise", $v);
$v;
}
if (!_hx_equal($set, 0)) {
$v1 = suncalc_SunCalc::hoursLater($date, $set);
$result->set("set", $v1);
$v1;
}
if (_hx_equal($rise, 0) && _hx_equal($set, 0)) {
$result->set($ye > 0 ? "alwaysUp" : "alwaysDown", true);
true;
}
return $result;
}