Lua asin()

laisvigas's avatar
Published Nov 3, 2023
Contribute to Docs

Lua’s math.asin() function calculates the inverse sine, also known as arcsine, of a given value. In other words, it finds the angle in radians whose sine equals the given value. The function takes a number within the range of -1 to 1 as input, representing a sine value, and returns the corresponding angle in radians. This is particularly useful in various applications, such as physics simulations and game development, where understanding angles and trajectories is essential for tasks like character movement and object positioning.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours

Syntax

The math.asin() function must be called with an argument using the following syntax:

math.asin(x)
  • Where x is a number between -1 and 1, representing a sine value for finding the corresponding angle in radians. If no argument is passed, the program will raise an error.

Example 1

The following example shows the usage of math.asin():

print(math.asin(1))

Output:

1.5707963267949

All contributors

Contribute to Docs

Learn Lua on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours