Angle
An angle, held in radians to 9 places, written 90deg or 1.5rad.
Physical quantities; ordered; since Jadpo 0.1.0.
Make one
text.parse(raw, as: Angle) reads one from its text; text that isn't one at all fails malformed, such as 5, "" or 1.2.3.
These operations give one: units.of and units.sum.
Text, JSON and storage
text.from writes its canonical text, the one form text.parse reads back. JSON sends an object of its parts.
| Text | JSON |
|---|---|
0 rad |
{"value":"0","unit":"rad"} |
1.570796327 rad |
{"value":"1.570796327","unit":"rad"} |
3.141592654 rad |
{"value":"3.141592654","unit":"rad"} |
It is stored in one column named for the field, of type numeric(38, 9), holding the angle in radians (rad). 1.570796327 rad is stored as 1.570796327.
Shown to people
text.format(value, locale:) shows it to people in their locale. A call may also give unit:.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
0 rad |
0 rad |
1.570796327 rad |
1.570796327 rad |
3.141592654 rad |
3.141592654 rad |
Operations
colour.from_hsl(hue: Angle, saturation: Percentage, lightness: Percentage) -> Colour: The colour of a CSS Color 4 HSL hue, saturation and lightness, the percentages clamped to 0% to 100%:colour.from_hsl(120deg, 100%, 25%)is#008000.colour.from_oklch(lightness: Percentage, chroma: Decimal, hue: Angle) -> Colour: The colour of an OKLCH lightness, chroma and hue, clipped into sRGB, the lightness clamped to 0% to 100% and the chroma to 0 or more:colour.from_oklch(62.8%, 0.2577, 29.23deg)is#ff0000.units.in(value: Quantity, unit: QuantityUnit, scale: Int, rounding: Rounding) -> Decimal:valueinunit, a unit of its kind, as aDecimalofscaleplaces rounded byrounding:units.in(5km, LengthUnit.mile, scale: 2, rounding: Rounding.half_even)is3.11.units.of(value: Number, unit: QuantityUnit) -> Quantity:valueofunit, anIntor aDecimal, as the quantity ofunit's kind, converted exactly to the base unit and rounded half to even to the kind's scale:units.of(5, LengthUnit.mile).units.sum(items: List<Quantity>) -> Quantity: The items added up, all of one kind; nothing for no items. ATemperatureor aSoundLeveldoesn't add to itself, so neither is summed.
Like every standard type, it also has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It is ordered, so < and sorting take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-angle.md.Built from Jadpo main at e00e61f.