当前位置: 首页>>代码示例>>PHP>>正文


PHP pi函数代码示例

本文整理汇总了PHP中pi函数的典型用法代码示例。如果您正苦于以下问题:PHP pi函数的具体用法?PHP pi怎么用?PHP pi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pi函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct($NAME = NULL, $DESCRIPTION = NULL, $LONG = NULL, $LAT = NULL, $ALT = NULL, $HEAD = NULL, $TILT = NULL, $RANGE = NULL)
 {
     $this->NAME = is_null($NAME) ? "Building and Wall" : $NAME;
     $this->DESCRIPTION = is_null($DESCRIPTION) ? "Building and Wall share textures" : $DESCRIPTION;
     $this->LONG = is_null($LONG) ? "-79.37380981445312" : $LONG;
     $this->LAT = is_null($LAT) ? "43.656211853027344" : $LAT;
     $this->ALT = is_null($ALT) ? "311" : $ALT;
     $this->HEAD = is_null($HEAD) ? "-40.34248730008207" : $HEAD;
     $this->TILT = is_null($TILT) ? "34.9531454664821" : $TILT;
     $this->RANGE = is_null($RANGE) ? "50.90180128676323" : $RANGE;
     $this->RADIAN = 180 / pi();
     //create the xml document
     $this->xmlDoc = new DOMDocument('1.0', 'UTF-8');
     $kml = $this->xmlDoc->appendChild($this->xmlDoc->createElementNS('http://www.opengis.net/kml/2.2', 'kml'));
     //create the root element
     $this->folTag = $kml->appendChild($this->xmlDoc->createElement("Folder"));
     $this->folTag->appendChild($this->xmlDoc->createElement("name", $this->NAME));
     $this->folTag->appendChild($this->xmlDoc->createElement("description", $this->DESCRIPTION));
     $lokTag = $this->folTag->appendChild($this->xmlDoc->createElement("Camera"));
     $lokTag->appendChild($this->xmlDoc->createElement("longitude", $this->LONG));
     $lokTag->appendChild($this->xmlDoc->createElement("latitude", $this->LAT));
     $lokTag->appendChild($this->xmlDoc->createElement("altitude", $this->ALT));
     $lokTag->appendChild($this->xmlDoc->createElement("heading", $this->HEAD));
     $lokTag->appendChild($this->xmlDoc->createElement("tilt", $this->TILT));
     $lokTag->appendChild($this->xmlDoc->createElement("range", $this->RANGE));
 }
开发者ID:Nemeziz,项目名称:googletwitter,代码行数:26,代码来源:setDomeKML.php

示例2: toLatLng

 /**
  * Convert this UTM reference to a latitude and longitude
  *
  * @return the converted latitude and longitude
  */
 function toLatLng()
 {
     $wgs84 = new ReferenceEllipsoid(ReferenceEllipsoid::WGS84_MAJ, ReferenceEllipsoid::WGS84_MIN);
     $UTM_F0 = 0.9996;
     $a = $wgs84->maj;
     $eSquared = $wgs84->ecc;
     $ePrimeSquared = $eSquared / (1.0 - $eSquared);
     $e1 = (1 - sqrt(1 - $eSquared)) / (1 + sqrt(1 - $eSquared));
     $x = $this->easting - 500000.0;
     $y = $this->northing;
     $zoneNumber = $this->lngZone;
     $zoneLetter = $this->latZone;
     $longitudeOrigin = ($zoneNumber - 1.0) * 6.0 - 180.0 + 3.0;
     // Correct y for southern hemisphere
     if (ord($zoneLetter) - ord("N") < 0) {
         $y -= 10000000.0;
     }
     $m = $y / $UTM_F0;
     $mu = $m / ($a * (1.0 - $eSquared / 4.0 - 3.0 * $eSquared * $eSquared / 64.0 - 5.0 * pow($eSquared, 3.0) / 256.0));
     $phi1Rad = $mu + (3.0 * $e1 / 2.0 - 27.0 * pow($e1, 3.0) / 32.0) * sin(2.0 * $mu) + (21.0 * $e1 * $e1 / 16.0 - 55.0 * pow($e1, 4.0) / 32.0) * sin(4.0 * $mu) + 151.0 * pow($e1, 3.0) / 96.0 * sin(6.0 * $mu);
     $n = $a / sqrt(1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad));
     $t = tan($phi1Rad) * tan($phi1Rad);
     $c = $ePrimeSquared * cos($phi1Rad) * cos($phi1Rad);
     $r = $a * (1.0 - $eSquared) / pow(1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad), 1.5);
     $d = $x / ($n * $UTM_F0);
     $latitude = ($phi1Rad - $n * tan($phi1Rad) / $r * ($d * $d / 2.0 - (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $c * $c - 9.0 * $ePrimeSquared) * pow($d, 4.0) / 24.0 + (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $t * $t - 252.0 * $ePrimeSquared - 3.0 * $c * $c) * pow($d, 6.0) / 720.0)) * (180.0 / pi());
     $longitude = $longitudeOrigin + ($d - (1.0 + 2.0 * $t + $c) * pow($d, 3.0) / 6.0 + (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $c * $c + 8.0 * $ePrimeSquared + 24.0 * $t * $t) * pow($d, 5.0) / 120.0) / cos($phi1Rad) * (180.0 / pi());
     return new LatLng($latitude, $longitude);
 }
开发者ID:nevstokes,项目名称:coords,代码行数:34,代码来源:UTMRef.php

示例3: 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);
 }
开发者ID:markguinn,项目名称:silverstripe-gis,代码行数:7,代码来源:GoogleMapUtility.php

示例4: TrueSolarTime

function TrueSolarTime($Hours, $ET, $SITE, $TIME)
{
    //Calculations
    if ($TIME['LocalTime'] == 1) {
        //True solar time, radian
        for ($i = 0; $i < $TIME['Ndays']; $i++) {
            for ($j = 0; $j < $TIME['Nsteps']; $j++) {
                $w[$i][$j] = ($Hours[$i][$j] - 12) * 15 * pi() / 180;
            }
        }
    } elseif ($TIME['LocalTime'] == 2) {
        //Daily loop
        for ($d = 0; $d < $TIME['Ndays']; $d++) {
            //Daylight Saving Time, DST
            if ($d < $TIME['DOCS'] || $d >= $TIME['DOCW']) {
                $DST[$d] = $TIME['DSTW'][$d];
            } else {
                $DST[$d] = $TIME['DSTS'][$d];
            }
            //Hourly loop
            for ($h = 0; $h < $TIME['Nsteps']; $h++) {
                //True solar time, radian
                $w[$d][$h] = ($Hours[$d][$h] - (12 + $DST[$d][$h])) * 15 * pi / 180 + ($SITE['Longitude'] - $SITE['StandardLongitude']) * pi / 180 + $ET[$d];
            }
        }
        //end foreach
    }
    //end elseif
    return $w;
}
开发者ID:rubennj,项目名称:SISIFO,代码行数:30,代码来源:TrueSolarTime.php

示例5: timeout

function timeout()
{
    global $da, $background, $back_width, $back_height, $frame, $images, $frame_num;
    $background->copy_area(0, 0, $back_width, $back_height, $frame, 0, 0);
    $f = $frame_num % CYCLE_LEN / CYCLE_LEN;
    $xmid = $back_width / 2.0;
    $ymid = $back_height / 2.0;
    $radius = min($xmid, $ymid) / 2.0;
    for ($i = 0; $i < N_IMAGES; $i++) {
        $ang = 2.0 * pi() * $i / N_IMAGES - $f * 2.0 * pi();
        $iw = $images[$i]->get_width();
        $ih = $images[$i]->get_height();
        $r = $radius + $radius / 3.0 * sin($f * 2.0 * pi());
        $xpos = floor($xmid + $r * cos($ang) - $iw / 2.0 + 0.5);
        $ypos = floor($ymid + $r * sin($ang) - $ih / 2.0 + 0.5);
        $k = $i & 1 ? sin($f * 2.0 * pi()) : cos($f * 2.0 * pi());
        $k = 2.0 * $k * $k;
        $k = max(0.25, $k);
        $r1 = new GdkRectangle($xpos, $ypos, $iw * $k, $ih * $k);
        $r2 = new GdkRectangle(0, 0, $back_width, $back_height);
        $dest = $r1->intersect($r2);
        $images[$i]->composite($frame, $dest->x, $dest->y, $dest->width, $dest->height, $xpos, $ypos, $k, $k, Gdk::INTERP_NEAREST, $i & 1 ? max(127, abs(255 * sin($f * 2.0 * pi()))) : max(127, abs(255 * cos($f * 2.0 * pi()))));
    }
    $da->queue_draw();
    $frame_num++;
    return true;
}
开发者ID:rakotomandimby,项目名称:php-gtk-src,代码行数:27,代码来源:bug_pixbuf-demo.php

示例6: approximate

 public function approximate()
 {
     $correlation = $this->getCorrelation();
     $step = $this->getStep();
     $this->_tau = 0;
     for ($i = 0; $i < count($correlation); $i++) {
         if ($correlation[$i] < 0) {
             $p1 = new Model_Coordinate($step * ($i - 1), $correlation[$i - 1]);
             $p2 = new Model_Coordinate($step * $i, $correlation[$i]);
             $k = ($p2->getY() - $p1->getY()) / ($p2->getX() - $p1->getX());
             $b = $p2->getY() - $k * $p2->getX();
             $this->_tau = -$b / $k;
             break;
         }
     }
     $this->_beta = pi() / (2 * $this->_tau);
     $s1 = 0;
     $s2 = 0;
     for ($i = 0; $i * $step < $this->_tau; $i++) {
         $tau = $i * $step;
         $ro_tau = $correlation[$i];
         $s1 += abs($tau * log($ro_tau / cos($this->_beta * $tau)));
         $s2 += $tau * $tau;
     }
     if ($this->_tau < $step) {
         $this->_alpha = 1;
     } else {
         $this->_alpha = $s1 / $s2;
     }
 }
开发者ID:nikita-prikazchikov,项目名称:RoadEstimation,代码行数:30,代码来源:Microprofile.php

示例7: testGetTheVolumeOfSphere

 public function testGetTheVolumeOfSphere()
 {
     $radius = 4;
     $result = 4 / 3 * pi() * sqrt($radius) * $radius;
     $volume_sphere = new Shape() / Sphere($radius);
     $this->assertEquals($result, $volume_sphere);
 }
开发者ID:arnacmj,项目名称:Assignment-Shapes,代码行数:7,代码来源:SphereTest.php

示例8: direction

function direction($u, $v, $good)
{
    $stringNum = array("N" => 0, "NNE" => 2, "NE" => 4, "ENE" => 6, "E" => 8, "ESE" => 10, "SE" => 12, "SSE" => 14, "S" => 16, "SSO" => 18, "SO" => 20, "OSO" => 22, "O" => 24, "ONO" => 26, "NO" => 28, "NNO" => 30);
    $dirString = array(0 => "N", 1 => "NNE", 2 => "NNE", 3 => "NE", 4 => "NE", 5 => "ENE", 6 => "ENE", 7 => "E", 8 => "E", 9 => "ESE", 10 => "ESE", 11 => "SE", 12 => "SE", 13 => "SSE", 14 => "SSE", 15 => "S", 16 => "S", 17 => "SSO", 18 => "SSO", 19 => "SO", 20 => "SO", 21 => "OSO", 22 => "OSO", 23 => "O", 24 => "O", 25 => "ONO", 26 => "ONO", 27 => "NO", 28 => "NO", 29 => "NNO", 30 => "NNO", 31 => "N", 32 => "N");
    $dir = (atan2($u, $v) / pi() + 1) * 180;
    $dirSecteur = round($dir / 11.25);
    $goods = str_getcsv($good);
    //var_dump($goods);
    $col = "white";
    foreach ($goods as $good) {
        //echo $good . '?';
        if ($good != '') {
            $num = $stringNum[$good];
            // echo 'ref='.$num.' et wind='.$dirSecteur . '! ';
            //je n'arrive pas Ó bien formuler l'intervalle sur mes numÚros de secteur
            if ($num + 3 >= $dirSecteur and $num - 3 <= $dirSecteur) {
                $col = "lightgreen";
            }
            if ($num == 0) {
                if ($dirSecteur == 31 or $dirSecteur == 30 or $dirSecteur == 29) {
                    $col = "lightgreen";
                }
            }
            if ($num == 1) {
                if ($dirSecteur == 31) {
                    $col = "lightgreen";
                }
            }
        }
    }
    print "<td bgcolor='" . $col . "'>" . $dirString[$dirSecteur] . "</td>";
}
开发者ID:nbald,项目名称:RASP-User,代码行数:32,代码来源:rasp.php

示例9: getClubs

 public static function getClubs($userLongitude, $userLatitude, $range = 10)
 {
     $searchRange = 180 / pi() * ($range / 6372.797);
     $lngR = abs($searchRange / cos($userLatitude * pi() / 180.0));
     $maxLat = $userLatitude + $searchRange;
     $minLat = $userLatitude - $searchRange;
     $maxLng = $userLongitude + $lngR;
     $minLng = $userLongitude - $lngR;
     $con = DBUtil::connectDB();
     $sql = "SELECT * FROM club where ((latitude BETWEEN {$minLat} AND {$maxLat}) AND (longitude BETWEEN {$minLng} AND {$maxLng}))";
     $result = mysql_query($sql, $con);
     $clubs = [];
     while ($row = mysql_fetch_array($result)) {
         $r = [];
         $r['id'] = $row['id'];
         $r['name'] = $row['name'];
         $r['longitude'] = $row['longitude'];
         $r['latitude'] = $row['latitude'];
         $r['images'] = json_decode($row['images']);
         $r['address'] = $row['address'];
         $r['meta'] = json_decode($row['meta']);
         $clubs[] = $r;
     }
     mysql_close();
     return $clubs;
 }
开发者ID:BurizaDo,项目名称:iPartyCloud,代码行数:26,代码来源:ClubDBUtil.php

示例10: distance

 public static function distance($lat1, $long1, $lat2, $long2)
 {
     //радиус Земли
     $R = 6372795;
     //перевод коордитат в радианы
     $lat1 *= pi() / 180;
     $lat2 *= pi() / 180;
     $long1 *= pi() / 180;
     $long2 *= pi() / 180;
     //вычисление косинусов и синусов широт и разницы долгот
     $cl1 = cos($lat1);
     $cl2 = cos($lat2);
     $sl1 = sin($lat1);
     $sl2 = sin($lat2);
     $delta = $long2 - $long1;
     $cdelta = cos($delta);
     $sdelta = sin($delta);
     //вычисления длины большого круга
     $y = sqrt(pow($cl2 * $sdelta, 2) + pow($cl1 * $sl2 - $sl1 * $cl2 * $cdelta, 2));
     $x = $sl1 * $sl2 + $cl1 * $cl2 * $cdelta;
     $ad = atan2($y, $x);
     $dist = $ad * $R;
     $dist = round($dist);
     return $dist;
 }
开发者ID:neolinks,项目名称:cabinet,代码行数:25,代码来源:Helpers.php

示例11: distanceBetween

	public function distanceBetween(Geopoint $pointA, Geopoint $pointB, $algorithm = 'flat', $unit = null) {

		if (!$unit) $unit = $this->defaultUnit;

		switch ($algorithm) {
			case 'haversine':
				$theta = ($pointA->longitude - $pointB->longitude); 
				$dist = sin(deg2rad($pointA->latitude)) * sin(deg2rad($pointB->latitude)) +  cos(deg2rad($pointA->latitude)) * cos(deg2rad($pointB->latitude)) * cos(deg2rad($theta)); 
				$dist = acos($dist); 
				
				$distance = rad2deg($dist);
			break;
			case 'flat':
			default:	
				$distanceEW = ($pointB->longitude - $pointA->longitude) * cos($pointA->latitude);
				$distanceNS = $pointB->latitude - $pointA->latitude;
				
				$distance = sqrt( ($distanceEW * $distanceEW) + ($distanceNS * $distanceNS));
			break;
		}
		
		$distance *= 2 * pi() * $this->earthRadius[$unit] / 360.0;
		
		return $distance;
		
	}
开发者ID:rjdjohnston,项目名称:Geotools-for-CodeIgniter,代码行数:26,代码来源:geotools.php

示例12: distanceBetween

 public static function distanceBetween(Geopoint $pointA, Geopoint $pointB, $algorithm, $units)
 {
     switch ($algorithm) {
         case 'haversine':
             $theta = $pointA->getLongitude() - $pointB->getLongitude();
             $dist = sin(deg2rad($pointA->getLatitude())) * sin(deg2rad($pointB->getLatitude())) + cos(deg2rad($pointA->getLatitude())) * cos(deg2rad($pointB->getLatitude())) * cos(deg2rad($theta));
             $dist = acos($dist);
             $distance = rad2deg($dist);
             break;
         case 'flat':
         default:
             $distanceEW = ($pointB->getLongitude() - $pointA->getLongitude()) * cos($pointA->getLatitude());
             $distanceNS = $pointB->getLatitude() - $pointA->getLatitude();
             $distance = sqrt($distanceEW * $distanceEW + $distanceNS * $distanceNS);
             break;
     }
     switch ($units) {
         case self::GEO_UNIT_KM:
             $radius = self::EARTH_RADIUS_KM;
             break;
         case self::GEO_UNIT_MILES:
             $radius = self::EARTH_RADIUS_MILES;
             break;
     }
     $distance *= 2 * pi() * $radius / 360.0;
     return $distance;
 }
开发者ID:weejames,项目名称:geotools,代码行数:27,代码来源:Tools.php

示例13: get_condition

 private function get_condition()
 {
     if ($this->input['jd'] || $this->input['wd']) {
         //gps坐标转百度坐标
         $baidu_zuobiao = GpsToBaidu($this->input['jd'], $this->input['wd']);
         $this->input['baidu_longitude'] = $baidu_zuobiao['x'];
         $this->input['baidu_latitude'] = $baidu_zuobiao['y'];
     }
     $distance = $this->input['distance'];
     if ($this->input['baidu_longitude'] && $this->input['baidu_latitude'] && $distance) {
         $baidu_longitude = $this->input['baidu_longitude'];
         $baidu_latitude = $this->input['baidu_latitude'];
         $range = 180 / pi() * $distance / 6372.797;
         //里面的 $distance 就代表搜索 $distance 之内,单位km
         $lngR = $range / cos($baidu_latitude * pi() / 180);
         //echo $range;exit()
         $maxLat = $baidu_latitude + $range;
         //最大纬度
         $minLat = $baidu_latitude - $range;
         //最小纬度
         $maxLng = $baidu_longitude + $lngR;
         //最大经度
         $minLng = $baidu_longitude - $lngR;
         //最小经度
         $condition .= ' AND t1.baidu_longitude >=' . $minLng . ' AND t1.baidu_longitude <=' . $maxLng . ' AND t1.baidu_latitude >=' . $minLat . ' AND t1.baidu_latitude <= ' . $maxLat . ' AND t1.baidu_latitude != "" AND t1.baidu_longitude != ""';
     }
     return $condition;
 }
开发者ID:h3len,项目名称:Project,代码行数:28,代码来源:get_station_all.php

示例14: 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);
 }
开发者ID:netconstructor,项目名称:cartodb-staticmap-php,代码行数:7,代码来源:class.cartodb-staticmap.php

示例15: explodeTestData

 protected function explodeTestData($locale, $currencyCode)
 {
     // valid values for all currencies
     $validDomainValues = [(double) -10, (double) 0, (double) 10];
     // invalid values for all currencies
     $invalidDomainValues = [-1, 0, 1, null, false, true, "", "123", "foo", [], ['foo' => 'bar'], new \stdClass(), NAN, INF, -INF];
     $tmpValid = $validDomainValues;
     $tmpInvalid = $invalidDomainValues;
     // Build fraction digits test data
     $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
     $formatter->setTextAttribute($formatter::CURRENCY_CODE, $currencyCode);
     $fractionDigits = $formatter->getAttribute(\NumberFormatter::FRACTION_DIGITS);
     $tmpValid[] = (double) (1 + pow(10, -$fractionDigits));
     $tmpInvalid[] = (double) (1 + pow(10, -($fractionDigits + 1)));
     $pi = pi();
     $tmpValid[] = round($pi, $fractionDigits);
     if ($fractionDigits > 2) {
         $tmpValid[] = round($pi, $fractionDigits - 1);
         $tmpValid[] = (double) (1 + pow(10, -($fractionDigits - 1)));
     }
     $tmpInvalid[] = round($pi, $fractionDigits + 1);
     $return = [];
     foreach ($tmpValid as $value) {
         $return[] = [$value, true];
     }
     foreach ($tmpInvalid as $value) {
         $return[] = [$value, false];
     }
     return $return;
 }
开发者ID:leodido,项目名称:moneylaundry,代码行数:30,代码来源:DomainTest.php


注:本文中的pi函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。