Download the PHP package marcoconsiglio/trigonometry without Composer
On this page you can find all versions of the php package marcoconsiglio/trigonometry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marcoconsiglio/trigonometry
More information about marcoconsiglio/trigonometry
Files in marcoconsiglio/trigonometry
Package trigonometry
Short Description A PHP support for angles and trigonometric functions.
License Unlicense
Informations about the package trigonometry
trigonometry
Mutation testing
A PHP support for angles and trigonometric functions.
Installation
composer require marcoconsiglio/trigonometry
Usage
Import this class to represent angles.
Import this class to sum angles.
Creating an angle
Degrees, minutes and seconds
This creates an angle from its values in degrees, minutes and seconds:
Parse a string
This creates an angle from its textual representation:
This is possible thank to the regular expression
The regex treat degrees and minutes as integer numbers, but seconds are treated as a float number.
Decimal
This create an angle from its decimal representation:
Radiant
This create an angle from its radiant representation:
Exceptions when creating an angle
Creating an angle by values overflowing the maximum (+/-)360° throws the AngleOverflowException
Creating an angle by string overflowing the maximum (+/-)360° throws the NoMatchException
Getting angle values
You can obtain degrees values separated in an array (simple by default, or associative):
There is read-only properties too:
You can cast the angle to decimal:
You can cast the angle to radiant:
Negative angles
You can create negative angles too!
Comparison
You can compare an angle with a numeric value, numeric string or another Angle
object.
$\alpha > \beta$ (greater than)
$\alpha \ge \beta$ (greater than or equal)
$\alpha < \beta$ (less than)
$\alpha \le \beta$ (less than or equal)
Direction
Positive angle are represented by the class constant
while negative angle are represented by the opposite class constant:
You can toggle direction:
You can check if an angle is clockwise or counterclockwise.
Algebric sum between two angles
The Sum
class extends the Angle
class, so you immediately obtain the algebric sum
between two angles, passing in its constructor a FromAngles builder, which is a SumBuilder.
Note that if the sum is more than +360° or less than -360°, the resulting angle will be corrected to remain between these limits.
Code documentation
UML Diagrams
You can find a class diagram at docs/classes.png
.
phpDoc
You can read the code documentation at docs/index.html
.