Returns the cosine of this number.

This number is presumed to be a radian.

val = angle.cos()

.cos( min, max )

The min and max describe the upper and lower bounds for a cosine wave. The cosine of this number is then multiplied against this range, to produce a value which is found within it.

This is for making it simpler to generate cosine waves.

Advanced Example

Displays pretty colours, based on a cosine wave.

angle = 0.toRadians()

onEachFrame() do |delta|
    angle = angle + delta/30
    red   = 130 +  60*angle.cos()
    green = 120 + -60*angle.cos()
    blue  = 150 +  30*(angle*2).cos()
    fill( red, green, blue )

See also

acos - sin - tan