Compute Cosine
Examples
Filter
function getCircleX(radians, radius) {
return Math.cos(radians) * radius;
}
console.log(getCircleX(1, 10));
// expected output: 5.403023058681398
console.log(getCircleX(2, 10));
// expected output: -4.161468365471424
console.log(getCircleX(Math.PI, 10));
// expected output: -10
Math.cos(0); // 1
Math.cos(1); // 0.5403023058681398
Math.cos(Math.PI); // -1
Math.cos(2 * Math.PI); // 1
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%.2f", math.Cos(math.Pi/2))
}