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


PHP atan2函数代码示例

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


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

示例1: boxshadow_filters

/**
 * boxshadow_filters
 * Builds filter properties for IE
 * @return array $filter_properties The new filter properties
 */
function boxshadow_filters($values)
{
    // Get the relevant box shadow value
    global $cssp;
    $value = $cssp->get_final_value($values);
    $filter_properties = array();
    // Build the filter value
    if (preg_match('/([-0-9]+)\\D+([-0-9]+)\\D+([-0-9]+)\\D+#([0-9A-F]{3,6})+/i', trim($value), $matches) == 1) {
        $xoffset = intval($matches[1]);
        $yoffset = intval($matches[2]);
        $blur = intval($matches[3]);
        $color = $matches[4];
        if (strlen($color) == 3) {
            $color = substr($color, 0, 1) . substr($color, 0, 1) . substr($color, 1, 1) . substr($color, 1, 1) . substr($color, 2, 1) . substr($color, 2, 1);
        }
        $median_offset = round((abs($xoffset) + abs($yoffset)) / 2);
        $opacity = $median_offset - $blur > 0 ? ($median_offset - $blur) / $median_offset : 0.05;
        $color_opacity = strtoupper(str_pad(dechex(round(hexdec(substr($color, 0, 2)) * $opacity)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(round(hexdec(substr($color, 2, 2)) * $opacity)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(round(hexdec(substr($color, 4, 2)) * $opacity)), 2, '0', STR_PAD_LEFT));
        // Calculate direction
        $direction = rad2deg(atan2($yoffset, $xoffset * -1));
        // Hard Shadow
        if ($blur == 0) {
            $filter = 'progid:DXImageTransform.Microsoft.dropshadow(OffX=' . $xoffset . ',OffY=' . $yoffset . ',Color=\'#' . strtoupper(str_pad(dechex(round($opacity * 255)), 2, '0', STR_PAD_LEFT)) . $color . '\',Positive=\'true\')';
        } else {
            $filter = 'progid:DXImageTransform.Microsoft.Shadow(Color=\'#' . $color . '\',Direction=' . $direction . ',Strength=' . $median_offset . ')';
        }
        // IE8 compliance (note: value inside apostrophes!)
        $filter_properties['-ms-filter'] = array('"' . $filter . '"');
        // Legacy IE compliance
        $filter_properties['filter'] = array($filter);
        $filter_properties['zoom'] = array('1');
    }
    return $filter_properties;
}
开发者ID:rmdort,项目名称:Turbine,代码行数:39,代码来源:boxshadow.php

示例2: getCenterFromDegrees

 /**
  * Get a center latitude,longitude from an array of like geopoints
  *
  * @param array data 2 dimensional array of latitudes and longitudes
  * For Example:
  * $data = array
  * (
  *   0 = > array(45.849382, 76.322333),
  *   1 = > array(45.843543, 75.324143),
  *   2 = > array(45.765744, 76.543223),
  *   3 = > array(45.784234, 74.542335)
  * );
  *
  * Thanks to Gio: http://stackoverflow.com/questions/6671183/calculate-the-center-point-of-multiple-latitude-longitude-coordinate-pairs
  */
 private function getCenterFromDegrees($data)
 {
     if (!is_array($data)) {
         return FALSE;
     }
     $num_coords = count($data);
     $X = 0.0;
     $Y = 0.0;
     $Z = 0.0;
     foreach ($data as $coord) {
         $lat = $coord[0] * pi() / 180;
         $lon = $coord[1] * pi() / 180;
         $a = cos($lat) * cos($lon);
         $b = cos($lat) * sin($lon);
         $c = sin($lat);
         $X += $a;
         $Y += $b;
         $Z += $c;
     }
     $X /= $num_coords;
     $Y /= $num_coords;
     $Z /= $num_coords;
     $lon = atan2($Y, $X);
     $hyp = sqrt($X * $X + $Y * $Y);
     $lat = atan2($Z, $hyp);
     return array($lat * 180 / pi(), $lon * 180 / pi());
 }
开发者ID:primaltalk,项目名称:maptest,代码行数:42,代码来源:maptest.php

示例3: calcBearing

 static function calcBearing($lat1, $lon1, $lat2, $lon2)
 {
     // Input sind Breite/Laenge in Altgrad
     // Der Fall lat/lon1 == lat/lon2 sollte vorher abgefangen werden,
     // zB. ueber die Abfrage der Distanz, dass Bearing nur bei Distanz > 5m
     // geholt wird, sonst = false gesetzt wird...
     if ($lat1 == $lat2 && $lon1 == $lon2) {
         return false;
     } else {
         $pi = 3.141592653589793;
         if ($lat1 == $lat2) {
             $lat1 += 1.66E-5;
         }
         if ($lon1 == $lon2) {
             $lon1 += 1.66E-5;
         }
         $rad_lat1 = $lat1 / 180.0 * $pi;
         $rad_lon1 = $lon1 / 180.0 * $pi;
         $rad_lat2 = $lat2 / 180.0 * $pi;
         $rad_lon2 = $lon2 / 180.0 * $pi;
         $delta_lon = $rad_lon2 - $rad_lon1;
         $bearing = atan2(sin($delta_lon) * cos($rad_lat2), cos($rad_lat1) * sin($rad_lat2) - sin($rad_lat1) * cos($rad_lat2) * cos($delta_lon));
         $bearing = 180.0 * $bearing / $pi;
         // Output Richtung von lat/lon1 nach lat/lon2 in Altgrad von -180 bis +180
         // wenn man Output von 0 bis 360 haben moechte, kann man dies machen:
         if ($bearing < 0.0) {
             $bearing = $bearing + 360.0;
         }
         return $bearing;
     }
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:31,代码来源:geomath.class.php

示例4: 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;
}
开发者ID:hubgit,项目名称:radibus,代码行数:7,代码来源:stops.php

示例5: text

	/**
	 * ImageResizeFilter::text()
	 * Фильтр - накладывает полупрозрачный текст по диагонали.
	 * 
	 * @param mixed $arrParams
	 * @return void
	 */
	private static function text($arrParams) {

		$objImg = imagecreatefromjpeg(self::$strFile);	
		
	    //получаем ширину и высоту исходного изображения
	    $intWidth = imagesx($objImg);
	    $intHeight = imagesy($objImg);
	    
	    //угол поворота текста
	    $intAngle =  -rad2deg(atan2((-$intHeight),($intWidth))); 

	    //добавляем пробелы к строке
	    $strText = ' '.$arrParams['text'].' ';
	 
	    $intColor = imagecolorallocatealpha($objImg, $arrParams['red'], $arrParams['green'], $arrParams['blue'], $arrParams['alpha']);
	    
	    $intSize = (($intWidth + $intHeight) / 2) * 2 / strlen($strText);
	    $arrBox  = imagettfbbox($intSize, $intAngle, $arrParams['font'], $strText);
	    $intX = $intWidth / 2 - abs($arrBox[4] - $arrBox[0]) / 2;
	    $intY = $intHeight / 2 + abs($arrBox[5] - $arrBox[1]) / 2;
	 
	    //записываем строку на изображение
	    imagettftext($objImg, $intSize ,$intAngle, $intX, $intY, $intColor, $arrParams['font'], $strText);
	    
	    imagejpeg($objImg, self::$strFile, 100);
	    
	    imagedestroy($objImg);
		
	}//\\ text
开发者ID:ASDAFF,项目名称:Bitrix.include.library,代码行数:36,代码来源:image_resize_filter.php

示例6: eposr_calculate_distance

function eposr_calculate_distance()
{
    if (!session_id()) {
        session_start();
    }
    $_SESSION['location'] = array('lat' => $_POST['us2_lat'], 'lon' => $_POST['us2_lon'], 'address' => $_POST['us2_address']);
    $_SESSION['order_type'] = "delivery";
    //
    $lat1 = $_SESSION['location']['lat'];
    $lng1 = $_SESSION['location']['lon'];
    //Latitude and longitude set by restaurant on the admin panel setting
    $lat2 = esc_attr(get_option('restaurant_lat'));
    $lng2 = esc_attr(get_option('restaurant_lon'));
    $pi80 = M_PI / 180;
    $lat1 *= $pi80;
    $lng1 *= $pi80;
    $lat2 *= $pi80;
    $lng2 *= $pi80;
    $r = 6372.797;
    // mean radius of Earth in km
    //for whitton
    $wlat = $lat2 - $lat1;
    $wlng = $lng2 - $lng1;
    $w = sin($wlat / 2) * sin($wlat / 2) + cos($lat1) * cos($lat2) * sin($wlng / 2) * sin($wlng / 2);
    $wc = 2 * atan2(sqrt($w), sqrt(1 - $w));
    $wkm = $r * $wc;
    if ((double) ($wkm * 1000) <= (double) esc_attr(get_option('delivery_radius'))) {
        echo 'accessible';
        die;
    } else {
        echo 'not accessible';
        die;
    }
}
开发者ID:nyrnzn,项目名称:eposrwpplugin,代码行数:34,代码来源:eposr-select-location.php

示例7: mandel

function mandel($params)
{
    $image_x = 4 * $params['w'];
    $image_y = 4 * $params['h'];
    $image = imagecreatetruecolor($image_x, $image_y);
    imagefilledrectangle($image, 0, 0, $image_x, $image_y, 0xffffff);
    $f = imagecolorallocate($image, $params['r'], $params['g'], $params['b']);
    $color = color($params, $image);
    for ($x = 0; $x < $image_x; $x++) {
        for ($y = 0; $y < $image_y; $y++) {
            $c_r = $x / $params['w'] + -2;
            $c_i = $y / $params['h'] + -2;
            $z_r = 0;
            $z_i = 0;
            $i = 0;
            while ($z_r * $z_r + $z_i * $z_i < 4 and $i < $params['n']) {
                $mod = sqrt($z_r * $z_r + $z_i * $z_i);
                $arg = atan2($z_i, $z_r);
                $z_r = pow($mod, $params['k']) * cos($params['k'] * $arg) + $c_r;
                $z_i = pow($mod, $params['k']) * sin($params['k'] * $arg) + $c_i;
                $i++;
            }
            if ($i == $params['n']) {
                imagesetpixel($image, $x, $y, $f);
            } else {
                imagesetpixel($image, $x, $y, $color[$i]);
            }
        }
    }
    return send_image($image);
}
开发者ID:lleaff,项目名称:Backito,代码行数:31,代码来源:mandel.php

示例8: getAngleSize

 public function getAngleSize(AngleInterface $angle, AngleSizeUnitsEnum $angleSizeUnit = null)
 {
     $BA = $angle->getFirstVector();
     $BC = $angle->getLastVector();
     $A = $BA->getLastPoint();
     $B = $BA->getFirstPoint();
     $C = $BC->getLastPoint();
     $Ax = $A->getX();
     $Ay = $A->getY();
     $Bx = $B->getX();
     $By = $B->getY();
     $Cx = $C->getX();
     $Cy = $C->getY();
     $coordSumBAx = $Ax - $Bx;
     $coordSumBAy = $Ay - $By;
     $coordSumBCx = $Cx - $Bx;
     $coordSumBCy = $Cy - $By;
     $x1 = $coordSumBCx;
     $x2 = $coordSumBAx;
     $y1 = $coordSumBCy;
     $y2 = $coordSumBAy;
     $res = $rads = atan2($x1 * $y2 - $y1 * $x2, $x1 * $x2 + $y1 * $y2);
     if (empty($angleSizeUnit)) {
         $angleSizeUnit = $this->getAngleSizeUnit();
     }
     if ($angleSizeUnit->getTypeName() === AngleSizeUnitsEnum::DEG) {
         $res = rad2deg($rads);
         if ($res < 0) {
             $res = $res + 360;
         }
     }
     return new AngleSize($angleSizeUnit, $res);
 }
开发者ID:samizdam,项目名称:Geometry,代码行数:33,代码来源:AngleSizeCalculator.php

示例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;
 }
开发者ID:Tjoosten,项目名称:input,代码行数:26,代码来源:sterea.php

示例10: distance

 function distance($zip1, $zip2)
 {
     $url = parse_url(getenv("CLEARDB_DATABASE_URL"));
     $server = $url["host"];
     $user = $url["user"];
     $pass = $url["pass"];
     $database = substr($url["path"], 1);
     $db = new PDO("mysql:host={$server};dbname={$database};charset=utf8", $user, $pass);
     $stmt = $db->prepare('SELECT * FROM zip WHERE zip = :zip1;');
     $stmt->bindParam(':zip1', $zip1);
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $lat1 = $result[0]["latitude"];
     $lon1 = $result[0]["longitude"];
     $stmt = $db->prepare('SELECT * FROM zip WHERE zip = :zip2;');
     $stmt->bindParam(':zip2', $zip2);
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $lat2 = $result[0]['latitude'];
     $lon2 = $result[0]['longitude'];
     /* Convert all the degrees to radians */
     $lat1 = $this->deg_to_rad($lat1);
     $lon1 = $this->deg_to_rad($lon1);
     $lat2 = $this->deg_to_rad($lat2);
     $lon2 = $this->deg_to_rad($lon2);
     /* Find the deltas */
     $delta_lat = $lat2 - $lat1;
     $delta_lon = $lon2 - $lon1;
     /* Find the Great Circle distance */
     $temp = pow(sin($delta_lat / 2.0), 2) + cos($lat1) * cos($lat2) * pow(sin($delta_lon / 2.0), 2);
     $EARTH_RADIUS = 3956;
     $distance = $EARTH_RADIUS * 2 * atan2(sqrt($temp), sqrt(1 - $temp));
     return $distance;
 }
开发者ID:nickolasnikolic,项目名称:zipapi,代码行数:34,代码来源:zipapi.php

示例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;
}
开发者ID:ocet,项目名称:tinyos-2.x-contrib,代码行数:32,代码来源:index.php

示例12: __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'])));
 }
开发者ID:anrdaemon,项目名称:minecraft-nbt-demos,代码行数:27,代码来源:BranchTrunk.php

示例13: attack

 public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC)
 {
     if ($this->attackTime > 0) {
         $lastCause = $this->getLastDamageCause();
         if ($lastCause instanceof EntityDamageEvent and $lastCause->getDamage() >= $damage) {
             return;
         }
     }
     $pk = new EntityEventPacket();
     $pk->eid = $this->getID();
     $pk->event = 2;
     //Ouch!
     Server::broadcastPacket($this->hasSpawned, $pk);
     $this->setLastDamageCause($source);
     $motion = new Vector3(0, 0, 0);
     if ($source instanceof EntityDamageByEntityEvent) {
         $e = $source->getDamager();
         $deltaX = $this->x - $e->x;
         $deltaZ = $this->z - $e->z;
         $yaw = atan2($deltaX, $deltaZ);
         $motion->x = sin($yaw) * 0.5;
         $motion->z = cos($yaw) * 0.5;
     }
     $this->setMotion($motion);
     $this->setHealth($this->getHealth() - $damage);
     $this->attackTime = 10;
     //0.5 seconds cooldown
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:28,代码来源:Living.php

示例14: 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;
 }
开发者ID:proj4php,项目名称:proj4php,代码行数:29,代码来源:Sterea.php

示例15: updateMove

 public function updateMove()
 {
     if (!$this->isMovement()) {
         return null;
     }
     $target = null;
     if ($this->stayTime > 0) {
         $this->move(0, 0);
         if (--$this->stayTime <= 0) {
             $this->stayVec = null;
         }
     } else {
         $target = $this->getTarget();
         $x = $target->x - $this->x;
         $y = $target->y - $this->y;
         $z = $target->z - $this->z;
         $speed = [Zombie::NETWORK_ID => 0.11, Creeper::NETWORK_ID => 0.09, Skeleton::NETWORK_ID => 0.1, Spider::NETWORK_ID => 0.113, PigZombie::NETWORK_ID => 0.115, Enderman::NETWORK_ID => 0.121];
         $add = $this instanceof PigZombie && $this->isAngry() ? 0.132 : $speed[static::NETWORK_ID];
         $this->move(cos($atn = atan2($z, $x)) * $add, sin($atn) * $add);
         $this->yaw = rad2deg($atn - M_PI_2);
         $this->pitch = $y == 0 ? 0 : rad2deg(-atan2($y, sqrt($x ** 2 + $z ** 2)));
     }
     $this->updateMovement();
     return $target;
 }
开发者ID:Cybertechpp,项目名称:EntityManager,代码行数:25,代码来源:Monster.php


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