Number
Inherits Steppable / Comparable / Value / Object
The top-level number type.
Constants
DEGREE_TO_RADIAN = Math::PI / 180
RADIAN_TO_DEGREE = 180 / Math::PI
Instance methods
Returns true if numbers are within delta from each other, else
false.
1.0.close_to?(1.0) # => true
1.0_f32.close_to?(1.0) # => true
1.0.close_to?(1.0 + Float64::EPSILON) # => true
1.0_f32.close_to?(1.0 + Float32::EPSILON) # => true
1.0.close_to?(1.0005, 1e-3) # => true
1.0.close_to?(1.0 + Float64::EPSILON*2) # => false
1.0_f32.close_to?(1.0 + Float32::EPSILON*2) # => false
1.0.close_to?(1.01, 1e-3) # => false
degree
Sourcedegrees
Sourceradian
Sourceradians
SourceScales the number into the given range. The result will be between zero and one.
10.scale(0, 100) # => 0.1
2.5.scale(0, 5) # 0.5
401.scale(50, 500) # => 0.78
Scales the number into the given range. The result will be between zero and one.
10.scale(0, 100) # => 0.1
2.5.scale(0, 5) # 0.5
401.scale(50, 500) # => 0.78
Reverts the scaling in the given range.
0.5.unscale(0, 100) # => 50.0 0.1.unscale(0, 5) # => 0.05 5.scale(-4, 20).unscale(-4, 20) # => 5.0