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


PHP sin函数代码示例

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


在下文中一共展示了sin函数的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());
             }
         }
     }
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:29,代码来源:Ghast.php

示例2: 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');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:60,代码来源:DrawingTest.php

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

示例4: AdjustAxes

 /**
  * Adjust axes for block spacing, setting the depth unit
  */
 protected function AdjustAxes(&$x_len, &$y_len)
 {
     // make sure project_angle is in range
     if ($this->project_angle < 1) {
         $this->project_angle = 1;
     } elseif ($this->project_angle > 90) {
         $this->project_angle = 90;
     }
     $ends = $this->GetAxisEnds();
     $bars = $ends['k_max'][0] - $ends['k_min'][0] + 1;
     $a = deg2rad($this->project_angle);
     $depth = $this->depth;
     $u = $x_len / ($bars + $depth * cos($a));
     $d = $u * $depth * sin($a);
     if ($d > $y_len) {
         // doesn't fit - use 1/2 y length
         $d = $y_len / 2;
         $u = $d / $depth * sin($a);
     }
     $c = $u * $depth * cos($a);
     $x_len -= $c;
     $y_len -= $d;
     $this->depth_unit = $u;
     return array($c, $d);
 }
开发者ID:battelle-dsi-capstone-2015,项目名称:corpus_topic_browser,代码行数:28,代码来源:SVGGraph3DGraph.php

示例5: __construct

 public function __construct($options)
 {
     parent::__construct();
     $inner_radius = (double) $options['inner_radius'];
     $outer_radius = (double) $options['outer_radius'];
     $r1 = ($outer_radius - $inner_radius) / 2;
     $r2 = $inner_radius + $r1;
     $d1 = (int) round(max(1, $options['detail_1']) * 4);
     $d2 = (int) round(max(1, $options['detail_2']) * 4);
     $rings = array();
     for ($i = 0; $i < $d1; ++$i) {
         $rings[$i] = array();
         for ($j = 0; $j < $d2; ++$j) {
             $_i = $i / $d1;
             $_j = $j / $d2;
             $z = cos($_j * pi() * 2) * $r1;
             $z2 = sin($_j * pi() * 2) * $r1;
             $x = ($r2 + $z2) * cos($_i * pi() * 2);
             $y = ($r2 + $z2) * sin($_i * pi() * 2);
             $rings[$i][] = new Image_3D_Point($x, $y, $z);
         }
     }
     foreach ($rings as $i => $ring) {
         $i_next = ($i + 1) % count($rings);
         foreach ($ring as $j => $point) {
             $j_next = ($j + 1) % count($ring);
             $this->_addPolygon(new Image_3D_Polygon($rings[$i_next][$j], $rings[$i][$j], $rings[$i][$j_next]));
             $this->_addPolygon(new Image_3D_Polygon($rings[$i_next][$j], $rings[$i][$j_next], $rings[$i_next][$j_next]));
         }
     }
 }
开发者ID:payonesmile,项目名称:Image_3D,代码行数:31,代码来源:Torus.php

示例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);
 }
开发者ID:nevstokes,项目名称:coords,代码行数:34,代码来源:UTMRef.php

示例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;
 }
开发者ID:hackergarage,项目名称:ThaFrame,代码行数:45,代码来源:pie.php

示例8: calculateColumnWidth

 /**
  * Calculate an (approximate) OpenXML column width, based on font size and text contained
  *
  * @param 	int		$fontSize			Font size (in pixels or points)
  * @param 	bool	$fontSizeInPixels	Is the font size specified in pixels (true) or in points (false) ?
  * @param 	string	$columnText			Text to calculate width
  * @param 	int		$rotation			Rotation angle
  * @return 	int		Column width
  */
 public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0)
 {
     if (!$fontSizeInPixels) {
         // Translate points size to pixel size
         $fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
     }
     // If it is rich text, use rich text...
     if ($columnText instanceof PHPExcel_RichText) {
         $columnText = $columnText->getPlainText();
     }
     // Only measure the part before the first newline character
     if (strpos($columnText, "\r") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\r"));
     }
     if (strpos($columnText, "\n") !== false) {
         $columnText = substr($columnText, 0, strpos($columnText, "\n"));
     }
     // Calculate column width
     $columnWidth = (strlen($columnText) * $fontSize + 5) / $fontSize * 256 / 256;
     // Calculate approximate rotated column width
     if ($rotation !== 0) {
         if ($rotation == -165) {
             // stacked text
             $columnWidth = 4;
             // approximation
         } else {
             // rotated text
             $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5;
             // approximation
         }
     }
     // Return
     return round($columnWidth, 6);
 }
开发者ID:nagiro,项目名称:hospici_cultural,代码行数:43,代码来源:Font.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: 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;
 }
开发者ID:treffynnon,项目名称:navigator,代码行数:19,代码来源:GreatCircle.php

示例11: __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);
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:36,代码来源:Distance.php

示例12: __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 */
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:29,代码来源:greatcircle.php

示例13: 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);
}
开发者ID:sdgdsffdsfff,项目名称:json-db,代码行数:32,代码来源:spray.php

示例14: drawRhythm

	function drawRhythm($daysAlive, $period, $color)
	{
	    global $daysToShow, $image, $diagramWidth, $diagramHeight;

	    // get day on which to center
	    $centerDay = $daysAlive - ($daysToShow / 2);

	    // calculate diagram parameters
	    $plotScale = ($diagramHeight - 25) / 2;
	    $plotCenter = ($diagramHeight - 25) / 2;

	    // draw the curve
	    for($x = 0; $x <= $daysToShow; $x++)
	    {
		// calculate phase of curve at this day, then Y value
		// within diagram
		$phase = (($centerDay + $x) % $period) / $period * 2 * pi();
		$y = 1 - sin($phase) * (float)$plotScale + (float)$plotCenter;

		// draw line from last point to current point
		if($x > 0)
		    imageLine($image, $oldX, $oldY,
			      $x * $diagramWidth / $daysToShow, $y, $color);

		// save current X/Y coordinates as start point for next line
		$oldX = $x * $diagramWidth / $daysToShow;
		$oldY = $y;
	    }

	}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:30,代码来源:biorhythm.php

示例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']));
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:25,代码来源:pts_BlockDiagramGraph.php


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