Golang基本三角函数反正切计算

huangapple go评论94阅读模式
英文:

Golang basic trigonometry arctan computation

问题

这是一个三角函数101的问题。不幸的是,我对基本的三角函数记忆不太好(太老了:)。我需要找到一个在Golang中计算给定系数的角度的公式。举个例子:

Tan(角度) = 系数
角度 = arctan(系数)

例子:
角度 = arctan(0.2) = 11.31度(其中系数=0.2)

角度 = arctan(0.3) = 16.699度(其中系数=0.3)

角度 = arctan(0.5) = 26.565度(其中系数=0.5)

下面的链接提供了一个计算器,显示了正确的值:

http://www.rapidtables.com/calc/math/Tan_Calculator.htm

根据这些例子,我该如何推导出一个用Golang编写的公式来计算给定系数的角度?

提前感谢你的时间。

Bharat

英文:

This is a Trig 101 question. Unfortunately, I don't remember my basic trig too well (too old :). I need to find a formula in Golang to compute the angle in degrees given the coefficient. As an example:

Tan(angle) = coefficient
Angle = arctan (coefficient)

Examples:
Angle = arctan(0.2) = 11.31 degrees (where coefficient = 0.2)

Angle = arctan(0.3) = 16.699 degrees (where coefficient = 0.3)

Angle = arctan(0.5) = 26.565 degrees (where coefficient = 0.5)

The URL below gives the calculator which is showing the correct values:

http://www.rapidtables.com/calc/math/Tan_Calculator.htm

Given these examples, how do I derive a formula written in Golang to compute the angle in degrees given the coefficient?

Thanks in advance for your time.

Bharat

答案1

得分: 2

这是你要翻译的内容:

Go Playground

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println("Tan: ", math.Tan(90))
	fmt.Println("Arctan: ", math.Atan(0.2))
	fmt.Println("Arctan: ", math.Atan(0.3))
	fmt.Println("Arctan: ", math.Atan(0.5))
}

math包中的函数列表

英文:

Go Playground

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println("Tan: ", math.Tan(90))
	fmt.Println("Arctan: ", math.Atan(0.2))
	fmt.Println("Arctan: ", math.Atan(0.3))
	fmt.Println("Arctan: ", math.Atan(0.5))
}

List of func in math package

huangapple
  • 本文由 发表于 2016年4月8日 00:28:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/36482069.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定