本文整理汇总了PHP中asin函数的典型用法代码示例。如果您正苦于以下问题:PHP asin函数的具体用法?PHP asin怎么用?PHP asin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了asin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: returnGeo
function returnGeo($lat, $lng, $radius, $tableName, $limit = 10)
{
$r = $radius / 3956;
$latRadians = $lat * pi() / 180;
$maxLat = 180 * ($latRadians + $r) / pi();
$minLat = 180 * ($latRadians - $r) / pi();
$lonRadians = $lng * pi() / 180;
$deltaLon = asin(sin($r) / cos($latRadians));
//return $deltaLon;
$maxLon = 180 * (($lonRadians + $deltaLon) / pi());
$minLon = 180 * (($lonRadians - $deltaLon) / pi());
// return array($lat,$lng,$radius,$tableName,$limit);
if ($tableName == 'cities') {
$query = "SELECT *, 3956 * 2 * ASIN(SQRT(POWER(SIN(abs(" . $lat . " - latitude) * pi()/180 /2),2)+ " . "(COS(" . $lat . "* pi()/180) * COS(abs(latitude) * pi()/180) * " . "POWER(SIN(abs(" . $lng . " - longitude) * pi()/180 / 2),2)) )) " . " as Distance FROM " . $tableName . " WHERE latitude < " . $maxLat . " AND latitude > " . $minLat . " AND longitude < " . $maxLon . " AND longitude > " . $minLon . " having Distance < " . $radius . " ORDER BY population DESC, Distance ASC LIMIT " . $limit . ";";
} else {
$query = "SELECT *, 3956 * 2 * ASIN(SQRT(POWER(SIN(abs(" . $lat . " - latitude) * pi()/180 /2),2)+ " . "(COS(" . $lat . "* pi()/180) * COS(abs(latitude) * pi()/180) * " . "POWER(SIN(abs(" . $lng . " - longitude) * pi()/180 / 2),2)) )) " . " as Distance FROM " . $tableName . " WHERE latitude < " . $maxLat . " AND latitude > " . $minLat . " AND longitude < " . $maxLon . " AND longitude > " . $minLon . "having Distance < " . $radius . " ORDER BY Distance ASC LIMIT " . $limit . ";";
}
//return $query;
$results = $this->query($query);
//if (!$results) return array('problem'=>$query);
foreach ($results as $key => $value) {
$results[$key] = $value[$tableName];
$results[$key]['distance'] = $value[0]['Distance'];
}
return $results;
}
示例2: getRange
public static function getRange($params)
{
if (empty($params['range'])) {
$params['range'] = 1000;
}
if (!isset($params['latitude']) || !isset($params['longitude']) || !isset($params['range'])) {
return false;
}
$latitude = $params['range'] / 111319.55;
$result['min_latitude'] = number_format($params['latitude'] - $latitude, 6);
$result['max_latitude'] = number_format($params['latitude'] + $latitude, 6);
// $longitude = $params['range']/(111319.55*cos($params['latitude']))*0.817;//0.86修正数
$longitude = rad2deg(asin(sin($params['range'] / self::R) / cos(deg2rad($params['latitude']))));
$result['min_longitude'] = number_format($params['longitude'] - $longitude, 6);
$result['max_longitude'] = number_format($params['longitude'] + $longitude, 6);
if ($result['min_latitude'] < -90) {
$result['min_latitude'] = -90.0;
}
if ($result['max_latitude'] > 90) {
$result['max_latitude'] = 90.0;
}
if ($result['min_longitude'] < -180) {
$result['min_longitude'] = -180.0;
}
if ($result['max_longitude'] > 180) {
$result['max_longitude'] = 180.0;
}
return $result;
}
示例3: __construct
public function __construct(Coords $p0, Coords $dir, $len, $r0, $r1)
{
$vl = $dir->distance(0, 0, 0);
if ($vl == 1) {
$this->ap = atan2($dir->y, $dir->x);
$this->av = asin($dir->z);
$this->dir = clone $dir;
} else {
$this->ap = atan2($dir->y, $dir->x);
$this->av = asin($dir->z / $vl);
$this->dir = Coords::fromPolar(1, $this->ap, $this->av);
}
$this->p0 = clone $p0;
$this->p1 = $p0->translate($len * $this->dir->x, $len * $this->dir->y, $len * $this->dir->z);
$this->len = $len;
$this->r0 = $r0;
$this->r1 = $r1;
$cap = cos($this->ap - M_PI / 2);
$sap = sin($this->ap - M_PI / 2);
$sav = sin($this->av - M_PI / 2);
$points[] = new Coords($this->p0->x + $this->r0 * $cap, $this->p0->y + $this->r0 * $sap, $this->p0->z + $this->r0 * $sav);
$points[] = new Coords($this->p0->x - $this->r0 * $cap, $this->p0->y - $this->r0 * $sap, $this->p0->z - $this->r0 * $sav);
$points[] = new Coords($this->p1->x + $this->r1 * $cap, $this->p1->y + $this->r1 * $sap, $this->p1->z + $this->r1 * $sav);
$points[] = new Coords($this->p1->x - $this->r1 * $cap, $this->p1->y - $this->r1 * $sap, $this->p1->z - $this->r1 * $sav);
$this->red = new Coords(floor(min($points[0]['x'], $points[1]['x'], $points[2]['x'], $points[3]['x'])), floor(min($points[0]['y'], $points[1]['y'], $points[2]['y'], $points[3]['y'])), floor(min($points[0]['z'], $points[1]['z'], $points[2]['z'], $points[3]['z'])));
$this->blue = new Coords(ceil(max($points[0]['x'], $points[1]['x'], $points[2]['x'], $points[3]['x'])), ceil(max($points[0]['y'], $points[1]['y'], $points[2]['y'], $points[3]['y'])), ceil(max($points[0]['z'], $points[1]['z'], $points[2]['z'], $points[3]['z'])));
}
示例4: normalizedBoundingBox
function normalizedBoundingBox($center, $tolerance, $fromProj = null, $toProj = null)
{
if ($fromProj !== null || $toProj !== null) {
$projector = new MapProjector();
}
// create the bounding box in lat/lon first
if ($fromProj !== null) {
$projector->setSrcProj($fromProj);
$center = $projector->projectPoint($center);
}
// approximate upper/lower bounds for lat/lon before calculating GCD
$dLatRadians = $tolerance / EARTH_RADIUS_IN_METERS;
// by haversine formula
$dLonRadians = 2 * asin(sin($dLatRadians / 2) / cos($center['lat'] * M_PI / 180));
$dLatDegrees = $dLatRadians * 180 / M_PI;
$dLonDegrees = $dLonRadians * 180 / M_PI;
$min = array('lat' => $center['lat'] - $dLatDegrees, 'lon' => $center['lon'] - $dLonDegrees);
$max = array('lat' => $center['lat'] + $dLatDegrees, 'lon' => $center['lon'] + $dLonDegrees);
if ($toProj !== null) {
$projector->setSrcProj(GEOGRAPHIC_PROJECTION);
$projector->setDstProj($toProj);
$min = $projector->projectPoint($min);
$max = $projector->projectPoint($max);
}
return array('min' => $min, 'max' => $max, 'center' => $center);
}
示例5: getDistance
function getDistance($lat1, $lng1, $lat2, $lng2)
{
$earthRadius = 6367000;
//approximate radius of earth in meters
/*
Convert these degrees to radians
to work with the formula
*/
$lat1 = $lat1 * pi() / 180;
$lng1 = $lng1 * pi() / 180;
$lat2 = $lat2 * pi() / 180;
$lng2 = $lng2 * pi() / 180;
/*
Using the
Haversine formula
http://en.wikipedia.org/wiki/Haversine_formula
calculate the distance
*/
$calcLongitude = $lng2 - $lng1;
$calcLatitude = $lat2 - $lat1;
$stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
$stepTwo = 2 * asin(min(1, sqrt($stepOne)));
$calculatedDistance = $earthRadius * $stepTwo;
return round($calculatedDistance);
}
示例6: __construct
/**
* Calculate Great Circle distance
*/
function __construct($latitude, $longitude, $latitude_origin, $longitude_origin)
{
$lat1 = $this->deg2rad($latitude_origin);
$lat2 = $this->deg2rad($latitude);
$lon1 = $this->deg2rad($longitude_origin);
$lon2 = $this->deg2rad($longitude);
$d = 2 * asin(sqrt(pow(sin(($lat1 - $lat2) / 2), 2) + cos($lat1) * cos($lat2) * pow(sin(($lon1 - $lon2) / 2), 2)));
if ($d <= 1.0E-7) {
$tc1 = 0;
// less than 10 cm: going to self
} elseif ($lat1 > M_PI / 2.0001) {
$tc1 = M_PI;
// starting from N pole
} elseif ($lat1 < -M_PI / 2.0001) {
$tc1 = 0;
// starting from S pole
} else {
$tc1 = acos((sin($lat2) - sin($lat1) * cos($d)) / (sin($d) * cos($lat1)));
if (sin($lon2 - $lon1) < 0) {
$tc1 = 2 * M_PI - $tc1;
}
}
$this->heading = rad2deg($tc1);
$this->distance = rad2deg($d) * 60 * 1852;
/* Assumes Earth radius of 6366.71 km */
}
示例7: _getLatLngDistance
/**
* Calculates the distance (in miles) between two points using the Haversine formula.
*
* @param array $point1 Array with indices [lat,lng]
* @param array $point2 Array with indices [lat,lng]
* @return float Distance in miles
*/
public static function _getLatLngDistance($point1, $point2)
{
$lat1 = $point1["lat"];
$lng1 = $point1["lng"];
$lat2 = $point2["lat"];
$lng2 = $point2["lng"];
//$earth = 6371; //km change accordingly
$earth = 3960;
//miles
//Point 1 cords
$lat1 = deg2rad($lat1);
$long1 = deg2rad($lng1);
//Point 2 cords
$lat2 = deg2rad($lat2);
$long2 = deg2rad($lng2);
//Haversine Formula
$dlong = $long2 - $long1;
$dlat = $lat2 - $lat1;
$sinlat = sin($dlat / 2);
$sinlong = sin($dlong / 2);
$a = $sinlat * $sinlat + cos($lat1) * cos($lat2) * ($sinlong * $sinlong);
$c = 2 * asin(min(1, sqrt($a)));
$d = $earth * $c;
return $d;
}
示例8: 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;
}
示例9: inverse
public function inverse($p)
{
$lon;
$lat;
$p->x = ($p->x - $this->x0) / $this->a;
/* descale and de-offset */
$p->y = ($p->y - $this->y0) / $this->a;
$p->x /= $this->k0;
$p->y /= $this->k0;
if ($rho = sqrt($p->x * $p->x + $p->y * $p->y)) {
$c = 2.0 * atan2($rho, $this->R2);
$sinc = sin($c);
$cosc = cos($c);
$lat = asin($cosc * $this->sinc0 + $p->y * $sinc * $this->cosc0 / $rho);
$lon = atan2($p->x * $sinc, $rho * $this->cosc0 * $cosc - $p->y * $this->sinc0 * $sinc);
} else {
$lat = $this->phic0;
$lon = 0.0;
}
$p->x = $lon;
$p->y = $lat;
Proj4php::$proj['gauss']->inverse->apply($this, array($p));
$p->x = Proj4php::$common->adjust_lon($p->x + $this->long0);
/* adjust longitude to CM */
return $p;
}
示例10: inverse
/**
* @param type $p
* @return type
*/
public function inverse($p)
{
// descale and de-offset
$p->x = ($p->x - $this->x0) / $this->a;
$p->y = ($p->y - $this->y0) / $this->a;
$p->x /= $this->k0;
$p->y /= $this->k0;
if ($rho = sqrt($p->x * $p->x + $p->y * $p->y)) {
$c = 2.0 * atan2($rho, $this->R2);
$sinc = sin($c);
$cosc = cos($c);
$lat = asin($cosc * $this->sinc0 + $p->y * $sinc * $this->cosc0 / $rho);
$lon = atan2($p->x * $sinc, $rho * $this->cosc0 * $cosc - $p->y * $this->sinc0 * $sinc);
} else {
$lat = $this->phic0;
$lon = 0.0;
}
$p->x = $lon;
$p->y = $lat;
//$p = Proj4php::$proj['gauss']->inverse($p);
$p = parent::inverse($p);
// adjust longitude to CM
$p->x = Common::adjust_lon($p->x + $this->long0);
return $p;
}
示例11: CircleDraw
function CircleDraw($lat_one, $long_one, $radius, $datasrc, $time)
{
//convert from degrees to radians
$lat1 = deg2rad($lat_one);
$long1 = deg2rad($long_one);
$d = $radius;
$d_rad = $d / 6378137;
$hex = 0xc249255;
$color = $datasrc * $hex;
$out = "<name>Data Visualization</name>\n";
$out .= "<visibility>1</visibility>\n";
$out .= "<Placemark>\n";
$out .= "<name>Dilution for node " . $datasrc . " at " . $time . "</name>\n";
$out .= "<visibility>1</visibility>\n";
$out .= "<Style>\n";
$out .= "<geomColor>" . dechex($color) . "</geomColor>\n";
$out .= "<geomScale>1</geomScale></Style>\n";
$out .= "<LineString>\n";
$out .= "<coordinates>\n";
// loop through the array and write path linestrings
for ($i = 0; $i <= 360; $i++) {
$radial = deg2rad($i);
$lat_rad = asin(sin($lat1) * cos($d_rad) + cos($lat1) * sin($d_rad) * cos($radial));
$dlon_rad = atan2(sin($radial) * sin($d_rad) * cos($lat1), cos($d_rad) - sin($lat1) * sin($lat_rad));
$lon_rad = fmod($long1 + $dlon_rad + M_PI, 2 * M_PI) - M_PI;
$out .= rad2deg($lon_rad) . "," . rad2deg($lat_rad) . ",0 ";
}
$out .= "</coordinates>\n";
$out .= "</LineString>\n";
$out .= "</Placemark>\n";
return $out;
}
示例12: getDistance
public static function getDistance($lat1, $long1, $lat2, $long2, $scale = 'km')
{
switch (strtolower($scale)) {
case 'miles':
$earth = 3960;
break;
case 'km':
default:
$earth = 6371;
break;
}
//Point 1 cords
$lat1 = deg2rad($lat1);
$long1 = deg2rad($long1);
//Point 2 cords
$lat2 = deg2rad($lat2);
$long2 = deg2rad($long2);
//Haversine Formula
$dlong = $long2 - $long1;
$dlat = $lat2 - $lat1;
$sinlat = sin($dlat / 2);
$sinlong = sin($dlong / 2);
$a = $sinlat * $sinlat + cos($lat1) * cos($lat2) * ($sinlong * $sinlong);
$b = 2 * asin(min(1, sqrt($a)));
return $earth * $b;
}
示例13: bearing
function bearing($lat1, $long1, $lat2, $long2)
{
$args = func_get_args();
list($lat1, $long1, $lat2, $long2) = array_map('deg2rad', $args);
$bearing = rad2deg(atan2(asin($long2 - $long1) * cos($lat2), cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($long2 - $long1)));
return $bearing < 0 ? 360 + $bearing : $bearing;
}
示例14: 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;
}
示例15: Generate
function Generate($level)
{
$CI =& get_instance();
$CI->load->library('10/Szogfuggvenyek/Haromszog_tangens', NULL, 'tangens');
$node = 'BC';
$length = rand(ceil($level / 2), $level);
$AB = $length + rand(ceil($level / 2), $level);
$question = 'Az $ABC$ derékszögű háromszög $' . $node . '$ befogója $' . $length . '$ cm, $AB$ átfogója $' . $AB . '$ cm hosszú. Számítsa ki az $ABC$ háromszög hegyesszögeinek nagyságát legalább két tizedesjegy pontossággal!';
$alpha = toDeg(asin($length / $AB));
$beta = 90 - $alpha;
$alphatext = str_replace('.', ',', round($alpha * 100) / 100);
$betatext = str_replace('.', ',', round($beta * 100) / 100);
$correct = array(round1($alpha), round1($beta));
$labels = array('$\\alpha$', '$\\beta$');
$solution = '$\\alpha=' . $alphatext . '°$ és $\\beta=' . $betatext . '°$.';
$hints[][] = 'Rajzoljunk egy derékszögű háromszöget:' . $CI->tangens->Triangle();
$hints[][] = 'Tudjuk, hogy az $\\textcolor{blue}{' . $node . '}$ befogó $' . $length . '$ cm hosszú:' . $CI->tangens->Triangle([$node], [$length], ['blue']);
$hints[][] = 'Tudjuk, hogy az $\\textcolor{green}{AB}$ átfogó $' . $AB . '$ cm hosszú:' . $CI->tangens->Triangle([$node, 'AB'], [$length, $AB], ['blue', 'green']);
$page[] = 'Az $\\alpha$ szög <b>szinusza</b> a szöggel szembeni befogó ($BC$) és az átfogó ($AB$) hányadosa:' . '$$\\sin\\alpha=\\frac{\\textcolor{blue}{BC}}{\\textcolor{green}{AB}}=' . '\\frac{\\textcolor{blue}{' . $length . '}}{\\textcolor{green}{' . $AB . '}}' . '$$';
$page[] = 'Az $\\alpha$ szöget úgy kapjuk meg, ha a hányados <b>arkusz szinuszát</b> vesszük (ami a szinusz függvény inverze), és az eredményt két tizedesjegyre kerekítjük:$$\\alpha=\\arcsin\\frac{\\textcolor{blue}{' . $length . '}}{\\textcolor{green}{' . $AB . '}}=' . $alphatext . '°$$';
$page[] = '<b>Megjegyzés</b>: az eredményt a következőképpen lehet kiszámolni számológéppel:
<ol>
<li>Állítsuk be a gépet <b>DEG</b> módba (ha még nem tettük):<br /><kbd>MODE</kbd> <kbd>DEG</kbd></li>
<li>Az szinusz függvény inverzét a <b>sin<sup>-1</sup></b> gomb segítségével lehet kiszámolni:<br />' . '<kbd>' . $length . '</kbd> <kbd>÷</kbd> <kbd>' . $AB . '</kbd> <kbd>=</kbd> <kbd>Shift</kbd> <kbd>sin<sup>-1</sup></kbd> <kbd>=</kbd></li>
</ol>';
$page[] = 'Tehát az $\\alpha$ szög <span class="label label-success">$' . $alphatext . '°$</span>.';
$hints[] = $page;
$page = [];
$page[] = 'Mivel a háromszög belső szögeinek összege $180°$, ezért a $\\beta$ szöget már könnyen ki lehet számolni:$$\\beta=180°-90°-' . $alphatext . '°$$';
$page[] = 'Tehát a $\\beta$ szög <span class="label label-success">$' . $betatext . '°$</span>.';
$hints[] = $page;
return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints, 'labels' => $labels, 'type' => 'array');
}