PHP code example of marcoconsiglio / trigonometry
1. Go to this page and download the library: Download marcoconsiglio/trigonometry 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 / trigonometry example snippets
use MarcoConsiglio\Trigonometry\Angle;
use MarcoConsiglio\Trigonometry\Operations\Sum;
$alfa = Angle::createFromValues(180, 12, 43, Angle::CLOCKWISE); // 180° 12' 43"
$alfa = new Angle(new FromDegrees(180, 12, 43, Angle::CLOCKWISE))
$beta = Angle::createFromString("180° 12' 43\""); // Input from the user
$beta = new Angle(new FromString("180° 12' 43\""));
Angle::ANGLE_REGEX;
$gamma = Angle::createFromDecimal(180.2119); // 180.2119°
$gamma = new Angle(new FromDecimal(180.2119));
$delta = Angle::createFromRadiant(3.1452910063); // deg2rad(180.2119°)
$delta = new Angle(FromRadiant(3.1452910063));
$values = $alfa->getDegrees();
echo $values[0]; // Degrees
echo $values[1]; // Minutes
echo $values[2]; // Seconds
$values = $alfa->getDegrees(true);
echo $value['degrees'];
echo $value['minutes'];
echo $value['seconds'];
$alfa->degrees; // 180
$alfa->minutes; // 12
$alfa->seconds; // 43
$alfa->direction; // Angle::CLOCKWISE (1)
$alfa->toDecimal(); // 180.2119
$alfa->toRadiant(); // 3.1452910063
$alfa = Angle::createFromValues(180, 12, 43, Angle::COUNTER_CLOCKWISE);
$beta = Angle::createFromString("-180° 12' 43\"");
$gamma = Angle::createFromDecimal(-180.2119);
$delta = Angle::createFromRadiant(-3.1452910063);
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(90);
$gamma = Angle::createFromDecimal(360);
$alfa->isGreaterThan(90); // true 180 > 90
$alfa->gt("90"); // 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->isGreaterThanOrEqual(90); // true 180 >= 90
$alfa->gte("180"); // true 180 >= 180
$beta->isGreaterThanOrEqual($gamma); // true 90 >= 90
$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); // true 180 < 90
$alfa = Angle::createFromDecimal(90);
$beta = Angle::createFromDecimal(180);
$alfa->isLessThanOrEqual(180); // true
$alfa->lte(90); // true
$alfa->isLessThanOrEqual($beta); // true
$alfa->lte($beta); // true
Angle::CLOCKWISE; // 1
Angle::COUNTER_CLOCKWISE; // 1
$alfa->toggleDirection();
$alfa->isClockwise(); // false
$alfa->isCounterClockwise(); // true
$alfa = Angle::createFromDecimal(180);
$beta = Angle::createFromDecimal(270);
$gamma = new Sum(new FromAngles($alfa, $beta));
(string) $gamma; // 90° 0' 0"