Angles - craterdog/go-component-framework GitHub Wiki
Overview
An angle is a primitive element that represents a mathematical angle measured in radians. Each angle has the following string format:
$angle: '~' ('0' | AMPLITUDE)
The source of this format is Bali Document Notation™ (Bali) defined here.
The phase is normalized to the range [0..τ)
where τ = 2π
.
Why tau?
Notice that tau is outside the specified range and will be normalized to zero.
The angle values support the standard trigonometric operations.
A Quick Example
To whet your appetite, here is some short example code that demonstrates the use of angles.
package main
import (
fmt "fmt"
fra "github.com/craterdog/go-component-framework/v7"
)
func main() {
// Retrieve the class reference.
var class = fra.AngleClass()
// Retrieve a class constant.
var pi = class.Pi()
fmt.Println(pi)
// Create some new angles.
var angle = class.Angle(1.23)
fmt.Println(angle)
var tau = class.AngleFromString("~τ") // Will be normalized to zero.
fmt.Println(tau)
// Call some trigonometric operations.
fmt.Println(class.Cosine(pi))
fmt.Println(class.Sine(tau))
fmt.Println(class.Tangent(angle))
}