nebble/util/math

Source   Edit  

High-level Nim wrapper for Pebble Math utilities.

Provides mathematical functions and constants for Pebble development.

Consts

TRIG_MAX_ANGLE = 0x00010000
Source   Edit  
TRIG_MAX_RATIO = 65535
Source   Edit  

Procs

proc abs(x: int32): int32 {.inline, ...raises: [], tags: [], forbids: [].}
Absolute value for int32. Equivalent to C function abs(x). Source   Edit  
proc clamp[T](value, minVal, maxVal: T): T {.inline.}
Clamp value between min and max. Source   Edit  
proc cosLookup(angle: int32): int32 {.inline, ...raises: [], tags: [], forbids: [].}
Compute the cosine of an angle in Pebble angle units. Returns a value in the range -TRIG_MAX_RATIO, TRIG_MAX_RATIO. Equivalent to C function cos_lookup(angle). Source   Edit  
proc degToTrigAngle(degrees: float32): int32 {.inline, ...raises: [], tags: [],
    forbids: [].}
Convert degrees to Pebble angle units. Equivalent to: degrees * TRIG_MAX_ANGLE / 360.0. Source   Edit  
proc max[T](a, b: T): T {.inline.}
Maximum of two values. Source   Edit  
proc min[T](a, b: T): T {.inline.}
Minimum of two values. Source   Edit  
proc sinLookup(angle: int32): int32 {.inline, ...raises: [], tags: [], forbids: [].}
Compute the sine of an angle in Pebble angle units. Returns a value in the range -TRIG_MAX_RATIO, TRIG_MAX_RATIO. Equivalent to C function sin_lookup(angle). Source   Edit  
proc trigAngleToDeg(angle: int32): float32 {.inline, ...raises: [], tags: [],
    forbids: [].}
Convert Pebble angle units to degrees. Equivalent to: angle * 360.0 / TRIG_MAX_ANGLE. Source   Edit