×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2478 | Released: 25 Oct 2014, 1:35am | What's New | Download Now

math.sin()

Description:

Returns the sine of an angle (assumed to be in radians).

Syntax:

math.sin (x)

Example:

-- move a circle along a path
local myCircle = display.newCircle( 0, display.viewableContentHeight/2, 10 )
local t, p = 0, 0.7
myCircle:setFillColor(250,250,100)
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 )

Parameters:

x
A number.

Returns:

A number in the range [-1, 1].

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 1.0
  • Windows:
    Corona SDK 1.0
  • iOS:
    Corona SDK 1.0
  • Android:
    Corona SDK 2.0

Replies

ali.ayyaz
User offline. Last seen 1 year 43 weeks ago. Offline
Joined: 3 Sep 2012

could anyone tell me the relationship b/w the command t = t + 5 and math.sin (10*t)

if you change either, the image starts moving, vibrating in unexpected ways.
using the above code, how can i change the radius of motion of an object, and speed etc?

Tom
User offline. Last seen 1 day 21 hours ago. Offline
Staff
Joined: 13 Jul 2010

You should ask this question in the forums and not on this document page. We have switched to new APIs pages and these pages are no longer used.