abstract struct Number

Overview

The top-level number type.

Included Modules

Direct Known Subclasses

Defined in:

lapis/math.cr

Instance Method Summary

Instance methods inherited from class Object

try?(&)
try?
try?

Instance Method Detail

def approach(target : Number, step : Number) : Float64 #

Smoothly approaches target by step without overshooting.

current = 5.0
current = current.approach(10.0, 2.0) # => 7.0
current = current.approach(10.0, 5.0) # => 10.0 (does not overshoot)

def degrees : Float64 #

Converts this number (interpreted as degrees) into radians.

rotation = 90.degrees # => ~1.5707963

def radians : Float64 #

Converts this number (interpreted as degrees) into radians. Alias to #degrees.


def to_degrees : Float64 #

Converts this number (interpreted as radians) into degrees.

deg = 1.5707963.to_degrees # => ~90.0