Fizzy / docs / ref / Angle.md
Angle
Fizzy has a special type devoted to angles. This has certain advantages over the use a plain old Doubles
- Improved type safety (cannot incorrectly mix and match number and angles)
- No confusion between the use of degrees and radians
Fizzy chooses 0° to point East (along the positive x axis), and progress anticlockwise. i.e. North is 90° and South is -90°. This is the normal mathematical convention.
This makes it easy for mathematically minded people to visualise the angles in the normal way.
However, because the origin is in the top left of the page, and the Y axis point downwards, angles can still be a little confusing.
If you stick to using Fizzy's in-built Angle, Vector2 and Dimension2 objects, then the 'weird' Y axis won't be a problem.
However, if you use trig functions (sin, cos, tan etc), then you must ensure you negate the y values appropriately.
Creation
Used the "rad" or "deg" suffix operators. e.g.
10 deg
10 °
3 rad
Constants
Note, PI
and TAU
are Doubles, not Angles.
But you can do the following :
PI rad
180 deg
TAU rad
360 deg
Operators
Mathematical operators work as you might expect :
Left | Operator | Right | = | Comments |
---|---|---|---|---|
Angle | + or - | Angle | Angle | |
Angle | * or / | Double | Angle |
Fields
Name | Type | Comments |
---|---|---|
Degrees | Double | |
Radians | Double |
Methods
Name | Parameters | Return Type | Comments |
---|---|---|---|
unitVector | none | Vector2 | A vector of length 1, at the given angle. |
format | String | String | Uses Java's DecimalFormat |
sin | none | Double | |
cos | none | Double | |
tan | none | Double | |
sinh | none | Double | |
cosh | none | Double | |
tanh | none | Double | |
clamp | min : Angle, max : Angle | Angle |