Angles - bali-nebula/go-component-framework GitHub Wiki

Overview

An angle is a primitive element that represents a mathematical angle measured in radians and normalized to the range [0..τ) where τ = 2π. Why tau? Notice that tau is outside the specified range and will be normalized to zero.

UML Diagram

A Quick Example

To whet your appetite, here is some short example code that demonstrates the behavior of angles.

package main

import (
	fmt "fmt"
	mat "math"
	bal "github.com/bali-nebula/go-component-framework/v2/bali"
	ele "github.com/bali-nebula/go-component-framework/v2/elements"
)

func main() {
	var zero = bal.Angle(`~0`)
	fmt.Println("Sine of zero:", ele.Angles.Sine(zero))

	var pi = bal.Angle(`~π`)
	fmt.Println("Cosine of pi:", ele.Angles.Cosine(pi))

	var tau = bal.Angle(`~τ`) // Will be normalized.
	fmt.Println("Cosine of tau:", ele.Angles.Cosine(tau))

	var halfPi = ele.AngleFromFloat(-1.5 * mat.Pi) // Will be normalized.
	fmt.Println("Sine of pi over 2:", ele.Angles.Sine(halfPi))
}