本文整理汇总了PHP中atan函数的典型用法代码示例。如果您正苦于以下问题:PHP atan函数的具体用法?PHP atan怎么用?PHP atan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了atan函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: line
public static function line($x1, $y1, $x2, $y2, $chars = array('#'))
{
if ($x2 != $x1) {
if ($x2 < $x1) {
list($x1, $x2) = array($x2, $x1);
list($y2, $y1) = array($y1, $y2);
}
$slope = ($y2 - $y1) / ($x2 - $x1);
$radians = atan($slope);
} else {
$radians = pi() / 2;
}
$radians += 2 * pi();
$dist = sqrt(pow($x2 - $x1, 2) + pow($y2 - $y1, 2));
$last_x = false;
$last_y = false;
$j = 0;
$chars_length = count($chars);
for ($i = 0; $i <= abs(ceil($dist)); $i += 1) {
$x = round($i * cos($radians) + $x1);
$y = round($i * sin($radians) + $y1);
if ($x != $last_x || $last_y != $y) {
Output::string($chars[$j++ % $chars_length], $y, $x);
}
$last_x = $x;
$last_y = $y;
}
}
示例2: get_tile_nw
public static function get_tile_nw($xtile, $ytile, $zoom)
{
$n = pow(2, $zoom);
$lon = $xtile / $n * 360.0 - 180.0;
$lat = rad2deg(atan(sinh(pi() * (1 - 2 * $ytile / $n))));
return array($lat, $lon);
}
示例3: __construct
/**
* Create a Distance object
*
* @param string latitude of first point
* @param string longitude of first point
* @param string latitude2 of second point
* @param string longitude2 of second point
* @param bool True if the distance is in Kms, otherwise returns Miles
*/
function __construct($latitude = 0, $longitude = 0, $latitude2 = 0, $longitude2 = 0, $in_kms = TRUE)
{
$EARTH_RADIUS_MILES = 3963;
// Miles
$miles2kms = 1.609;
$dist = 0;
//convert degrees to radians
$latitude = $latitude * M_PI / 180;
$longitude = $longitude * M_PI / 180;
$latitude2 = $latitude2 * M_PI / 180;
$longitude2 = $longitude2 * M_PI / 180;
if ($latitude != $latitude2 || $longitude != $longitude2) {
//the two points are not the same
$dist = sin($latitude) * sin($latitude2) + cos($latitude) * cos($latitude2) * cos($longitude2 - $longitude);
// Special case to prevent division by zero
if ($dist == 1 || $dist == -1) {
// lim $dist -> 1 or -1 atan($dist / sqrt(1 - $dist*$dist)) == M_PI / 2
// This means that the equation below will evaluate to zero
$dist = 0;
} else {
$dist = $EARTH_RADIUS_MILES * (-1 * atan($dist / sqrt(1 - $dist * $dist)) + M_PI / 2);
}
}
if ($in_kms) {
$dist = $dist * $miles2kms;
}
$this->dist = round($dist, 2);
}
示例4: metersToLatLon
static function metersToLatLon($mx, $my)
{
$lng = $mx / self::originShift() * 180.0;
$lat = $my / self::originShift() * 180.0;
$lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
return new GoogleMapPoint($lat, $lng);
}
示例5: MetersToLatLon
public function MetersToLatLon($mx, $my)
{
$lon = $mx / $this->originShift * 180.0;
$lat = $my / $this->originShift * 180.0;
$lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
return array($lat, $lon);
}
示例6: solphy
function solphy($dj, &$lo, &$bo, &$p)
{
global $T2000, $DGRAD, $DPI;
$t = ($dj - $T2000) / 3652500;
$t2 = $t * $t;
$t3 = pow($t, 3);
$t4 = pow($t, 4);
$t5 = pow($t, 5);
$gi = 7.25 * $DGRAD;
$go = 73 + 40.0 / 60.0 + 50.25 / 3600 * ($dj - 2396758.5) / 365.25;
$gm = 112.766 + (2430000.5 - $dj) * 14.18439716 + 180;
$go = fmod($go * $DGRAD, $DPI);
$gm = fmod($gm * $DGRAD, $DPI);
$a1 = 2.18 - 3375.7 * $t + 0.36 * $t2;
$a2 = 3.51 + 125666.39 * $t + 0.1 * $t2;
$dpsi = 1.0E-7 * (-834 * sin($a1) - 64 * sin($a2));
$epsv = 0.4090928 + 1.0E-7 * (-226938 * $t - 75 * $t2 + 96926 * $t3 - 2491 * $t4 - 12104 * $t5 + 446 * cos($a1) + 28 * cos($a2));
$gla = lonsol($dj);
$gl = $gla - $dpsi;
$c = cos($gl - $go);
$s = sin($gl - $go);
//print "a1: $a1 a2: $a2 dpsi: $dpsi gla: $gla gl: $gl c: $c s: $s<BR>";
$lo = atan2(-$s * cos($gi), -$c) + $gm;
$lo = fmod($lo, $DPI);
if ($lo < 0) {
$lo += $DPI;
}
$bo = asin($s * sin($gi));
$x = atan(-cos($gla) * tan($epsv));
$y = atan(-$c * tan($gi));
$p = $x + $y;
}
示例7: gcBearingTo
function gcBearingTo($from, $to)
{
global $PI, $DEG2RAD, $RAD2DEG;
$x1 = $from["x"] * $DEG2RAD;
$y1 = $from["y"] * $DEG2RAD;
$x2 = $to["x"] * $DEG2RAD;
$y2 = $to["y"] * $DEG2RAD;
$a = cos($y2) * sin($x2 - $x1);
$b = cos($y1) * sin($y2) - sin($y1) * cos($y2) * cos($x2 - $x1);
if ($a == 0 && $b == 0) {
$bearing = 0;
return $bearing;
}
if ($b == 0) {
if ($a < 0) {
$bearing = 270;
} else {
$bearing = 90;
}
return $bearing;
}
if ($b < 0) {
$adjust = $PI;
} else {
if ($a < 0) {
$adjust = 2 * $PI;
} else {
$adjust = 0;
}
}
$bearing = (atan($a / $b) + $adjust) * $RAD2DEG;
return $bearing;
}
示例8: inverse
public function inverse($p)
{
$Y = $p->x - $this->x0;
$X = $p->y - $this->y0;
$rotI = $Y / $this->R;
$rotB = 2 * (atan(exp(X / $this->R)) - Sourcemap_Proj::PI / 4.0);
$b = asin(cos($this->b0) * sin($rotB) + sin($this->b0) * cos($rotB) * cos($rotI));
$I = atan(sin($rotI) / (cos($this->b0) * cos($rotI) - sin($this->b0) * tan($rotB)));
$lambda = $this->lambda0 + $I / $this->alpha;
$S = 0.0;
$phy = $b;
$prevPhy = -1000.0;
$iteration = 0;
while (abs($phy - $prevPhy) > 1.0E-7) {
if (++$iteration > 20) {
throw new Exception("Infinity...");
}
//S = log(tan(Sourcemap_Proj::PI / 4.0 + $phy / 2.0));
$S = 1.0 / $this->alpha * (log(tan(Sourcemap_Proj::PI / 4.0 + $b / 2.0)) - $this->K) + $this->e * log(tan(Sourcemap_Proj::PI / 4.0 + asin($this->e * sin($phy)) / 2.0));
$prevPhy = $phy;
$phy = 2.0 * atan(exp($S)) - Sourcemap_Proj::PI / 2.0;
}
$p->x = $lambda;
$p->y = $phy;
return $p;
}
示例9: getPoint
function getPoint($xtile, $ytile, $zoom)
{
$n = pow(2, $zoom);
$lon_deg = $xtile / $n * 360.0 - 180.0;
$lat_deg = rad2deg(atan(sinh(pi() * (1 - 2 * $ytile / $n))));
return $lon_deg . "," . $lat_deg;
}
示例10: __construct
/**
* Create a Distance object
*
* @param string latitude of first point
* @param string longitude of first point
* @param string latitude2 of second point
* @param string longitude2 of second point
* @param bool True if the distance is in Kms, otherwise returns Miles
*/
public function __construct($latitude = 0, $longitude = 0, $latitude2 = 0, $longitude2 = 0, $in_kms = TRUE)
{
$EARTH_RADIUS_MILES = 3963;
// Miles
$miles2kms = 1.609;
$dist = 0;
// Convert degrees to radians
$latitude = $latitude * M_PI / 180;
$longitude = $longitude * M_PI / 180;
$latitude2 = $latitude2 * M_PI / 180;
$longitude2 = $longitude2 * M_PI / 180;
if ($latitude != $latitude2 || $longitude != $longitude2) {
// The two points are not the same
$dist = sin($latitude) * sin($latitude2) + cos($latitude) * cos($latitude2) * cos($longitude2 - $longitude);
// Safety check
if ($dist > 0) {
$sqrt = sqrt(1 - $dist * $dist);
if ($sqrt > 0) {
$dist = $EARTH_RADIUS_MILES * (-1 * atan($dist / $sqrt) + M_PI / 2);
}
}
}
if ($in_kms) {
$dist = $dist * $miles2kms;
}
$this->dist = round($dist, 2);
}
示例11: anglePolar
static function anglePolar($pointA, $pointB, $pointC)
{
if (!isset(self::$anglePolarTable[$pointA->guid . ';' . $pointB->guid . ';' . $pointC->guid])) {
$Ax = $pointA->x - $pointB->x;
$Ay = $pointA->y - $pointB->y;
$Cx = $pointC->x - $pointB->x;
$Cy = $pointC->y - $pointB->y;
if ($Ax <= 0 && pow($Ay, 2) == 0) {
$Apolar = 180;
} else {
$Apolar = rad2deg(2 * atan($Ay / ($Ax + sqrt(pow($Ax, 2) + pow($Ay, 2)))));
}
if ($Cx + sqrt(pow($Cx, 2) + pow($Cy, 2)) == 0) {
$Cpolar = 180;
} else {
$Cpolar = rad2deg(2 * atan($Cy / ($Cx + sqrt(pow($Cx, 2) + pow($Cy, 2)))));
}
$result = $Cpolar - $Apolar;
if ($result < 0) {
$result += 360;
}
self::$anglePolarTable[$pointA->guid . ';' . $pointB->guid . ';' . $pointC->guid] = $result;
}
return self::$anglePolarTable[$pointA->guid . ';' . $pointB->guid . ';' . $pointC->guid];
}
示例12: fromPointToLatLon
public function fromPointToLatLon(Coord2D $point)
{
$origin = $this->_pixelOrigin;
$lng = ($point->x - $origin->x) / $this->_pixelsPerLonDegree;
$latRadians = ($point->y - $origin->y) / -$this->_pixelsPerLonRadian;
$lat = $this->radiansToDegrees(2 * atan(exp($latRadians)) - pi() / 2);
return new GeoPoint($lat, $lng);
}
示例13: fromPixelToLL
function fromPixelToLL($x, $y, $zoom)
{
$e = $this->zc[$zoom];
$f = ($x - $e) / $this->Bc[$zoom];
$g = ($y - $e) / -$this->Cc[$zoom];
$h = 180.0 / M_PI * (2 * atan(exp($g)) - 0.5 * M_PI);
return array($f, $h);
}
示例14: getAngle
public function getAngle($out = 'rad')
{
if ($this->y === 0) {
$angle = 0;
} else {
$angle = atan($this->x / $this->y);
}
return $out == 'rad' ? $angle : rad2deg($angle);
}
示例15: fromPointToLatLng
public function fromPointToLatLng($point)
{
$me = $this;
$origin = $me->pixelOrigin_;
$lng = ($point->x - $origin->x) / $me->pixelsPerLonDegree_;
$latRadians = ($point->y - $origin->y) / -$me->pixelsPerLonRadian_;
$lat = radiansToDegrees(2 * atan(exp($latRadians)) - M_PI / 2);
return new G_LatLng($lat, $lng);
}