Library contents

Go math.Asin

In Go, math.Asin returns the inverse sine in radians. For real inputs from −1 to 1, the result lies between −π/2 and π/2.

A simple example

math.Asin

  1. Start with 0
  2. Do this Find the angle with sine 0
  3. Result 0 radians
Sine starts at zero. Zero is also the angle returned by inverse sine here.
main.go
package main

import "fmt"
import "math"

func main() {
    fmt.Println(math.Asin(0.0))
}
Output
0

Syntax

Go syntax
math.Asin(riseFraction)
Run these examples in Go

Save one example at a time as main.go. Use Go 1.21 or later.

go run main.go

Recover a ladder angle from its height

A maintenance team is sketching a ladder or lifting arm against a wall. Use the known length and angle or height to recover the missing dimension and check the units before entering it in the drawing.

From the programriseFraction := 0.5
Result0.524
main.go
package main

import (
    "fmt"
    "math"
)

func main() {
    riseFraction := 0.5

    fmt.Printf("%.3f\n", math.Asin(riseFraction))
}
Output
0.524

A rise of half the ladder length gives about 0.524 radians, or 30 degrees.

Advertisements

Set the angle on a stage drawing

A 5 m model beam runs from the stage floor to a point 3 m above it. The set designer needs the angle from the horizontal in radians.

GivenRise 3 m · length 5 m
Worked result0.644 rad

The height is opposite the marked angle. Divide it by the beam length.

Draw a level platform arm

A museum exhibit has an arm that starts level with its pivot. Its zero vertical rise provides a quick check before the designer animates it.

GivenRise 0 cm · arm 40 cm
Worked result0.000 rad

The ratio zero gives an angle of zero.

What to watch for

For real results the ratio must be between minus one and one.

Documentation for math.Asin