math.sin()

Type Function
Library math.*
Return value Number
Revision Release 2022.3683
Keywords sine, sin
See also math.asin()
math.pi
math.cos()

Overview

Returns the sine of x (the angle in radians). The result is a number in the range [-1, 1].

Syntax

math.sin( x )
x (required)

Number. The angle in radians.

Example

-- move a circle along a path
local myCircle = display.newCircle( 0, display.viewableContentHeight/2, 20 )
local t, p = 0, 0.7
myCircle:setFillColor( 1, 0, 0 )
local function onFrame( event )
    myCircle.x = display.viewableContentWidth/2 + 100 * math.cos(10*t - p)
    myCircle.y = display.viewableContentHeight/2 - 100 * math.sin(10*t)
    t = t + 5
end
Runtime:addEventListener( "enterFrame", onFrame )