PHP code example of marcoconsiglio / goniometry
1. Go to this page and download the library: Download marcoconsiglio/goniometry library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marcoconsiglio / goniometry example snippets
use MarcoConsiglio\Goniometry\Angle;
$alfa = Angle::createFromValues(180, 30);
$beta = Angle::createFromString("180° 30'");
$gamma = Angle::createFromDecimal(180.5);
$delta = Angle::createFromRadian(M_PI); // 180°
$alfa = AngularDistance::createFromValues(180, 30);
$beta = AngularDistance::createFromString("180° 30'");
$gamma = AngularDistance::createFromDecimal(180.5);
$delta = AngularDistance::createFromRadian(M_PI); // 180°
$alfa = Angle::createFromValues(180, 12, 43.4618, Rotation::CLOCKWISE); // -180° 12' 43.4618"
$beta = Angle::createFromString("-180° 12' 43.4618\"");
Angle::DEGREES_REGEX;
Angle::MINUTES_REGEX;
Angle::SECONDS_REGEX;
$gamma = Angle::createFromDecimal(180.2119); // 180.2119°
$gamma = Angle::createFromDecimal(-180.2119); // -180.2119°
$gamma = Angle::createFromDecimal(301.0); // 1.0°
$delta = Angle::createFromRadian(M_PI); // π ≅ 180°
$delta = Angle::createFromRadian(
new Radian(Number::π())
); // π = 180°
$delta = Angle::createFromRadian(-M_PI); // -π ≅ -180°
$delta = Angle::createFromRadian(2 * M_PI); // 2π ≅ 0°
$values = $alfa->getDegrees();
echo $values[0]; // int (degrees)
echo $values[1]; // int (minutes)
echo $values[2]; // float (seconds)
echo $values[3]; // int (rotation direction +1/-1)
$values = $alfa->getDegrees(true);
echo $value['degrees']; // int
echo $value['minutes']; // int
echo $value['seconds']; // float
echo $value['direction']; // int
/** @var Degrees */
(string) $alfa->degrees; // 180°
/** @var Minutes */
(string) $alfa->minutes; // 12'
/** @var Seconds */
(string) $alfa->seconds; // 43"
/** @var Rotation */
$alfa->direction; // Rotation::CLOCKWISE (-1)
Rotation::COUNTER_CLOCKWISE; // 1
Rotation::CLOCKWISE; // -1
$beta = $alfa->oppositeRotation();
// If $alfa is a positive angle
$alfa->isCounterClockwise(); // true
$alfa->isClockwise(); // false
// If $beta is a negative angle
$beta->isCounterClockwise(); // false
$beta->isClockwise(); // true
$negative_angle = Angle::createFromDecimal(-180); // -180°
$positive_angle = $negative_angle->absolute(); // +180°
$alfa->toFloat(); // 180.211971543295645
$alfa->toFloat(4); // 180.2119
$alfa->toFloat(200) // 180.211971543295645
$sexadecimal = $alfa->toSexadecimalDegrees();
/** @var Number */
(string) $sexadecimal->value;// 180.2119715432956455962174521226543543
/** @var float */
$sexadecimal->value(); // 180.211971543295645
/** @var float */
$sexadecimal->value(3); // 180.212
/** @var float */
$sexadecimal->value(12); // 180.211971543296
$alfa->toRadian(); // 3.141592653589793
$alfa->toRadian(3); // 3.141
$alfa->toRadian(200); // 3.141592653589793
(string) $alfa; // 180° 30' 25.757385"
$alfa = Angle::createFromDecimal(89.999);
$alfa->isEqualTo(90.0, 0); // true with precision 0
$alfa->isEqualTo(90.0, 3); // false with precision 3
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(90);
$gamma = Angle::createFromDecimal(360);
$alfa->isGreaterThan(90); // true 180 > 90
$alfa->gt("90° 0' 0\""); // true 180 > 90
$alfa->isGreaterThan($gamma); // false 180 > 360
$alfa->gt($gamma); // false 180 > 360
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(90);
$gamma = Angle::createFromDecimal(90);
$alfa->isGreaterThanOrEqualTo(90); // true 180 ≧ 90
$alfa->gte("180 0' 0\""); // true 180 ≧ 180
$beta->isGreaterThanOrEqualTo($alfa); // true 90 ≧ 180
$beta->gte(90); // true 90 ≧ 90
$alfa = Angle::createFromDecimal(90);
$beta = Angle::createFromDecimal(180);
$alfa->isLessThan(180); // true 90 < 180
$alfa->lt(180); // true 90 < 180
$alfa->isLessThan($beta); // true 90 < 180
$beta->lt($alfa); // false 180 < 90
$alfa = Angle::createFromDecimal(90);
$beta = Angle::createFromDecimal(180);
$alfa->isLessThanOrEqualTo(180); // true 90 ≦ 180
$alfa->lte(90); // true 90 ≦ 90
$alfa->isLessThanOrEqualTo($beta); // false 90 ≦ 180
$alfa->lte($beta); // false 90 ≦ 180
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(180);
$gamma = Angle::createFromDecimal(-180);
$alfa->isEqualTo($beta); // true 180 ≅ 180
$alfa->eq($gamma); // true 180 ≅ -180
$alfa = Angle::createFromDecimal(90);
$beta = Angle::createFromDecimal(180);
$alfa->isDifferentThan(180); // true 90 ≇ 180
$alfa->not(180); // true 90 ≇ 180
$alfa->isDifferentThan(-90); // false 90 ≇ -90
$beta->not($alfa); // true 180 ≇ 90
$alfa = Angle::createFromDecimal(90.345);
$beta = Angle::createFromValue(90);
$delta = Angle::createFromValue(4); // ±2° error
$alfa->fuzzyEqual($beta, $delta); // true
$alfa->feq($beta, $delta); // true
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(-270);
$gamma =
$alfa // 180° +
->sum($beta); // -270° =
(string) $gamma; // -90°
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(-270);
$gamma =
$alfa // 180° +
->absSum($beta); //-270° =
(string) $gamma; // 270°
$alfa = Angle::createFromDecimal(-180);
$beta = Angle::createFromDecimal(-270);
$gamma =
$alfa // -180° +
->absSum($beta); // -270°
(string) $gamma; // 270°
$alfa = Angle::createFromValues(180);
$beta = Angle::createFromValues(90);
$distance = AngularDistance::between($alfa, $beta);
php
$alfa = Angle::createFromDecimal(90.0);
$beta = $alfa->oppositeDirection();
(string) $beta; // 180° 0' 0"