本文整理汇总了PHP中cos函数的典型用法代码示例。如果您正苦于以下问题:PHP cos函数的具体用法?PHP cos怎么用?PHP cos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attackEntity
public function attackEntity(Entity $player)
{
if ($this->attackDelay > 30 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 200) {
$this->attackDelay = 0;
$f = 2;
$yaw = $this->yaw + mt_rand(-220, 220) / 10;
$pitch = $this->pitch + mt_rand(-120, 120) / 10;
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2), new DoubleTag("", $this->y + 2), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI) * $f), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
$fireball = Entity::createEntity("FireBall", $this->chunk, $nbt, $this);
if ($fireball instanceof FireBall) {
$fireball->setExplode(true);
}
$fireball->setMotion($fireball->getMotion()->multiply($f));
$ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $fireball, $f);
$this->server->getPluginManager()->callEvent($ev);
$projectile = $ev->getProjectile();
if ($ev->isCancelled()) {
$projectile->kill();
} elseif ($projectile instanceof Projectile) {
$this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
if ($launch->isCancelled()) {
$projectile->kill();
} else {
$projectile->spawnToAll();
$this->level->addSound(new LaunchSound($this), $this->getViewers());
}
}
}
}
示例2: bearing
function bearing($lat1, $lon1, $lat2, $lon2)
{
if (round($lon1, 1) == round($lon2, 1)) {
if ($lat1 < $lat2) {
$bearing = 0;
} else {
$bearing = 180;
}
} else {
$dist = distance($lat1, $lon1, $lat2, $lon2, 'N');
$arad = acos((sin(deg2rad($lat2)) - sin(deg2rad($lat1)) * cos(deg2rad($dist / 60))) / (sin(deg2rad($dist / 60)) * cos(deg2rad($lat1))));
$bearing = $arad * 180 / pi();
if (sin(deg2rad($lon2 - $lon1)) < 0) {
$bearing = 360 - $bearing;
}
}
$dirs = array("N", "E", "S", "W");
$rounded = round($bearing / 22.5) % 16;
if ($rounded % 4 == 0) {
$dir = $dirs[$rounded / 4];
} else {
$dir = $dirs[2 * floor((floor($rounded / 4) + 1) % 4 / 2)];
$dir .= $dirs[1 + 2 * floor($rounded / 8)];
#if ($rounded % 2 == 1)
# $dir = $dirs[round_to_int($rounded/4) % 4] . "-" . $dir;
}
$var_dist = "";
#return $dir;
if (isset($dist)) {
$var_dist = $dist . " miles";
}
return round($bearing, 0) . "º " . $dir . " " . $var_dist;
}
示例3: 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;
}
示例4: _createPie
protected function _createPie($parameter)
{
$step = ($parameter['end'] - $parameter['start']) / $parameter['detail'];
// center
$centerTop = new Image_3D_Point(0, 0, 0.5);
$centerBottom = new Image_3D_Point(0, 0, -0.5);
// Add polygones for top and bottom of the pie
$x = cos($parameter['start']) * $parameter['outside'];
$y = sin($parameter['start']) * $parameter['outside'];
$top = new Image_3D_Point($x, $y, 0.5);
$bottom = new Image_3D_Point($x, $y, -0.5);
// Polygones for the opening side
$this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom));
$this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom));
for ($i = 1; $i <= $parameter['detail']; $i++) {
$x = cos($parameter['start'] + $i * $step) * $parameter['outside'];
$y = sin($parameter['start'] + $i * $step) * $parameter['outside'];
$newTop = new Image_3D_Point($x, $y, 0.5);
$newBottom = new Image_3D_Point($x, $y, -0.5);
$this->_addPolygon(new Image_3D_Polygon($centerTop, $top, $newTop));
$this->_addPolygon(new Image_3D_Polygon($centerBottom, $bottom, $newBottom));
// Rand
$this->_addPolygon(new Image_3D_Polygon($top, $newBottom, $newTop));
$this->_addPolygon(new Image_3D_Polygon($top, $bottom, $newBottom));
$top = $newTop;
$bottom = $newBottom;
}
// Polygones for the closing side
$this->_addPolygon(new Image_3D_Polygon($top, $centerTop, $centerBottom));
$this->_addPolygon(new Image_3D_Polygon($bottom, $top, $centerBottom));
}
示例5: scopeNearLatLong
public function scopeNearLatLong($query, $lat, $lng, $radius = 10, $unit = 69.0)
{
if (!is_numeric($lat) || -90 >= $lat || $lat >= 90) {
throw new RangeException("Latitude must be between -90 and 90 degrees.");
}
if (!is_numeric($lng) || -180 >= $lng || $lng >= 180) {
throw new RangeException("Longitude must be between -180 and 180 degrees.");
}
$subQuery = clone $query;
$latDistance = $radius / $unit;
$latNorth = $lat - $latDistance;
$latSouth = $lat + $latDistance;
$lngDistance = $radius / ($unit * cos(deg2rad($lat)));
$lngEast = $lng - $lngDistance;
$lngWest = $lng + $lngDistance;
$subQuery->selectRaw(DB::raw('*, (? * DEGREES(
ACOS(
COS(RADIANS(?)) * COS(RADIANS(latitude)) * COS(RADIANS(? - longitude))
+ SIN(RADIANS(?)) * SIN(RADIANS(latitude))
)
)) AS distance'))->addBinding([$unit, $lat, $lng, $lat], 'select');
$subQuery->whereBetween('latitude', [$latNorth, $latSouth]);
$subQuery->whereBetween('longitude', [$lngEast, $lngWest]);
$query->from(DB::raw('(' . $subQuery->toSql() . ') as d'));
$query->mergeBindings($subQuery->getQuery());
$query->where('distance', '<=', $radius);
// // To use:
// $latitude = 29.443778;
// $longitude = -98.478903;
// // Default radius is 10; default unit is miles.
// Model::nearLatLong($latitude, $longitude)->get();
}
示例6: 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);
}
示例7: get
/**
* This function generates a pie chart of the given data.
* It uses the technology provided by the {@link Chart} class to generate a pie chart from the given data.<br>
* You can pass the following options to the this method by using {@link Chart::get()}:<br>
* * cx & cy - The coordinates of the center point of the pie chart.<br>
* * r - The radius of the pie chart.
* @param array An array of options, see {@link Chart::get()}.
* @return string
* @see Chart::get()
*/
function get($options)
{
$cx = $options["cx"] ? $options["cx"] : 200;
$cy = $options["cy"] ? $options["cy"] : 200;
$r = $options["r"] ? $options["r"] : 150;
$x1 = $cx;
$y1 = $cy - $r;
$alpha = 0;
$output = "";
$count = 0;
$data = $this->chart->data;
$sum = 0;
foreach ($data as $obj) {
$sum += $obj->value;
}
$colors = $this->chart->colors;
foreach ($data as $obj) {
$alpha = $alpha + $obj->percent / 100 * (2 * M_PI);
$x2 = $cx + $r * sin($alpha);
$y2 = $cy - $r * cos($alpha);
$over180 = $obj->percent > 50 ? "1" : "0";
$color = $this->chart->getColor($count);
$output .= "<path d='M{$cx},{$cy} L{$x1},{$y1} A{$r},{$r} 0 {$over180},1 {$x2},{$y2} Z' fill='{$color}' opacity='0.6'/>\n\n";
$x1 = $x2;
$y1 = $y2;
$count++;
}
if (isset($this->options["legend"])) {
$x = $cx + $r * 1.2;
$y = $cy - $r;
$this->options["legend"]["x"] = $x;
$this->options["legend"]["y"] = $y;
}
return $output;
}
示例8: AmbientTemperature
function AmbientTemperature($w, $ws, $METEO, $TIME)
{
//Daily maximum and minimum temperatures
if ($TIME['Ndays'] == 365) {
//All year
$TM = MonthlyAverageToAll($METEO['TMm']);
$Tm = MonthlyAverageToAll($METEO['Tmm']);
} elseif ($TIME['Ndays'] == 12) {
//Only characteristic days
$TM = $METEO['TMm'];
$Tm = $METEO['Tmm'];
}
//Calculations
for ($d = 0; $d < $TIME['Ndays']; $d++) {
//Daily coefficients
$a3[$d] = -pi() / ($ws[$d] + 2 * pi() - pi() / 6);
$b3[$d] = -$a3[$d] * $ws[$d];
$a4[$d] = pi() / ($ws[$d] - pi() / 6);
$b4[$d] = -$a4[$d] * pi() / 6;
$a5[$d] = pi() / (2 * pi() + $ws[$d] - pi() / 6);
$b5[$d] = -(pi() + $a5[$d] * pi() / 6);
for ($h = 0; $h < $TIME['Nsteps']; $h++) {
if (-pi() < $w[$d][$h] && $w[$d][$h] < $ws[$d]) {
$Ta[$d][$h] = $TM[$d] - ($TM[$d] - $Tm[$d]) / 2 * (1 + cos($a3[$d] * $w[$d][$h] + $b3[$d]));
} elseif ($ws[$d] < $w[$d][$h] && $w[$d][$h] < pi() / 6) {
$Ta[$d][$h] = $Tm[$d] + ($TM[$d] - $Tm[$d]) / 2 * (1 + cos($a4[$d] * $w[$d][$h] + $b4[$d]));
} else {
$Ta[$d][$h] = $TM[$d] - ($TM[$d] - $Tm[$d]) / 2 * (1 + cos($a5[$d] * $w[$d][$h] + $b5[$d]));
}
}
//end FOR $h
}
//end FOREACH $d
return $Ta;
}
示例9: __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);
}
示例10: __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 */
}
示例11: calculate
/**
* Calculate the distance between two
* points using the Great Circle formula.
*
* Supply instances of the coordinate class.
*
* http://www.ga.gov.au/earth-monitoring/geodesy/geodetic-techniques/distance-calculation-algorithms.html#circle
*
* @param Treffynnon\Navigator\Coordinate $point1
* @param Treffynnon\Navigator\Coordinate $point2
* @return float
*/
public function calculate(N\LatLong $point1, N\LatLong $point2)
{
$celestialBody = $this->getCelestialBody();
$degrees = acos(sin($point1->getLatitude()->get()) * sin($point2->getLatitude()->get()) + cos($point1->getLatitude()->get()) * cos($point2->getLatitude()->get()) * cos($point2->getLongitude()->get() - $point1->getLongitude()->get()));
$d = $degrees * $celestialBody->volumetricMeanRadius;
return $d * 1000;
}
示例12: imagecharx
function imagecharx($img, $char, $x0, $y0, $ylist)
{
global $bk_color, $fg_color;
$da = @imagecreate(10, 20) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($da, $bk_color[0], $bk_color[1], $bk_color[2]);
$text_color = imagecolorallocate($da, $fg_color[0], $fg_color[1], $fg_color[2]);
$color = imagecolorallocate($img, $fg_color[0], $fg_color[1], $fg_color[2]);
$arg = rand(0, 18) / 100.0 * pi();
imagestring($da, 18, 0, 0, $char, $text_color);
for ($i = 0; $i < 200; $i++) {
$y = @floor($i / 10);
$x = $i % 10;
$point_color = imagecolorat($da, $x, $y);
if ($point_color == $text_color) {
for ($j = 0; $j < 12; $j++) {
$dx = 0;
$dy = 0;
$p = 6;
for ($s = 0; $s < $p; $s++) {
$dx += rand(0, 1000 / $p) / 100;
$dy += rand(0, 1000 / $p) / 100;
}
$xx = $x * 5 + $dx - 25;
$yy = $y * 5 + $dy - 50;
$x1 = cos($arg) * $xx - sin($arg) * $yy + 25;
$y1 = sin($arg) * $xx + cos($arg) * $yy + 50;
imagesetpixel($img, $x0 + $x1, $y0 + $y1, $color);
}
}
}
imagedestroy($da);
}
示例13: testDrawing
public function testDrawing()
{
$pdf = new Zend_Pdf();
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages[] = $page1 = $pdf->newPage('A4');
// Add new page generated by Zend_Pdf_Page object (page is not attached to the document)
$pdf->pages[] = $page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font and draw text
$page1->setFont($font, 36);
$page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'));
$page1->drawText('Helvetica 36 text string', 60, 500);
// Use font object for another page
$page2->setFont($font, 24);
$page2->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32);
$page2->drawText('Times-Roman 32 text string', 60, 450);
// Draw rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8));
$page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
$page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
$page2->drawRectangle(60, 400, 400, 350);
// Draw circle
$page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
$page2->drawCircle(85, 375, 25);
// Draw sectors
$page2->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6);
$page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
$page2->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
$page2->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
// Draw ellipse
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
$page2->drawEllipse(250, 400, 400, 350);
$page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
$page2->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
$page2->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
// Draw and fill polygon
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1));
$x = array();
$y = array();
for ($count = 0; $count < 8; $count++) {
$x[] = 140 + 25 * cos(3 * M_PI_4 * $count);
$y[] = 375 + 25 * sin(3 * M_PI_4 * $count);
}
$page2->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
// Draw line
$page2->setLineWidth(0.5);
$page2->drawLine(60, 375, 400, 375);
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
示例14: getArea
/**
* Get polygon area fast method
*
* @param float[][] $polygon
* @param float $a
* @param float $f
*
* @return float area of given polygon in square meters
* @throws Exception
*/
public static function getArea($polygon, $a = 6378137.0)
{
if (!is_array($polygon) || !is_array($polygon[0])) {
throw new Exception("Array of array of floats expected!");
}
if ($polygon[0][0] != $polygon[count($polygon) - 1][0] || $polygon[0][1] != $polygon[count($polygon) - 1][1]) {
$polygon[] = $polygon[0];
}
$total = 0;
$previous = $polygon[0];
$cx = 0;
$cy = 0;
for ($i = 1; $i < count($polygon); $i++) {
$cx = $cx + $polygon[$i][1];
$cy = $cy + $polygon[$i][0];
}
$cx = $cx / count($polygon);
$cy = $cy / count($polygon);
$xRef = $cx + 1;
$yRef = $cy + 1;
for ($i = 1; $i < count($polygon); $i++) {
$current = $polygon[$i];
$earthRadians = $a * pi() / 180;
// convert to cartesian coordinates in meters, note this not very exact
$x1 = ($previous[1] - $xRef) * $earthRadians * cos($yRef * pi() / 180);
$y1 = ($previous[0] - $yRef) * $earthRadians;
$x2 = ($current[1] - $xRef) * $earthRadians * cos($yRef * pi() / 180);
$y2 = ($current[0] - $yRef) * $earthRadians;
$total += $x1 * $y2 - $x2 * $y1;
$previous = $current;
}
return 0.5 * abs($total);
}
示例15: renderGraph
public function renderGraph()
{
$this->i['top_heading_height'] = max(self::$c['size']['headers'] + 22 + self::$c['size']['key'], 48);
$this->i['top_start'] = $this->i['top_heading_height'] + 50;
$this->update_graph_dimensions($this->i['graph_width'], $this->i['graph_height'] + $this->i['top_start'], true);
// Do the actual work
$this->render_graph_init();
$this->graph_key_height();
$this->render_graph_key();
$this->render_graph_heading();
$data = array(1, 2, 3, 6, 7, 8, 9, 10);
$center_block_x = round($this->i['graph_width'] / 2);
$center_block_y = round($this->i['graph_height'] / 2);
for ($ring = 0, $blocks_per_ring = count($data) <= 5 ? 5 : 4, $ring_size = ceil(count($data) / $blocks_per_ring); $ring < $ring_size; $ring++) {
$depth = ($ring + 1) * (min($center_block_x, $center_block_y) / ($ring_size + 0.25));
for ($i = $ring * $blocks_per_ring, $i_size = $i + $blocks_per_ring; $i < $i_size; $i++) {
$this_degree = 360 / $blocks_per_ring * ($i % $blocks_per_ring + $ring / $ring_size);
$this_block_x = round($center_block_x + cos(deg2rad($this_degree)) * $depth);
$this_block_y = round($center_block_y - sin(deg2rad($this_degree)) * $depth);
$this->svg_dom->draw_svg_line($center_block_x, $center_block_y, $this_block_x, $this_block_y, self::$c['color']['notches'], 2);
$this->svg_dom->add_element('rect', array('x' => $this_block_x - 20, 'y' => $this_block_y - 20, 'width' => 40, 'height' => 40, 'fill' => self::$c['color']['alert']));
}
}
$this->svg_dom->add_element('rect', array('x' => $center_block_x - 50, 'y' => $center_block_y - 50, 'width' => 100, 'height' => 100, 'fill' => self::$c['color']['alert']));
}