Calculates the sine of an angle.
- The angle, using a full circle range of 0.0-1.0 measured clockwise (0.0 to the right).
sin() function calculates the sine of an angle.
Pico-8 uses an input range of 0.0 to 1.0 to represent the angle, a percentage of the unit circle. An angle of π (3.1415) radians (180 degrees) corresponds to a Pico-8 angle of 0.5.
Pico-8 measures the angle in a clockwise direction, with 0.0 to the right, 0.25 downward, and so on. This is inverted from the convention used in traditional geometry, though the inversion only affects
sin(), not cos().
The inversion is useful because Pico-8's screen (like most graphics engines) uses inverted y coordinates: an increase in y goes downward. Many uses of
sin() would need to be inverted anyway, so Pico-8 does it by convention.
(The clockwise direction of the angle is equivalent to going counterclockwise and negating
sin(). This is how it is described in the official documentation.)
for t=0,1,0.125 do print('sin('..t..') = '..sin(t)) end
sin(0) = 0 sin(0.125) = -0.7071 sin(0.25) = -1 sin(0.375) = -0.7071 sin(0.5) = 0 sin(0.625) = 0.7071 sin(0.75) = 1 sin(0.875) = 0.7071 sin(1) = 0