想在 Swift 中使用 cos^-1
Want to use cos^-1 in Swift
我的 Swift 代码需要帮助。我不知道如何使用 cos^-1。如果有人能告诉我方法就太好了。
let cosinus = cos((.pi * cosinusValue / 180))
acos()
和 BSD 库中的其他数学函数可以直接从 Swift 使用。示例:
import Darwin // or Foundation
let x = 0.0
let angle = acos(x)
print(angle) // 1.5707963267948966 (radians)
print(angle * 180.0 / .pi) // 90.0 (degrees)
在 Swift 的未来版本中,这些函数也可用作浮点类型的静态函数,比较 SE-0246 Generic Math(s) Functions
let x = 0.0
let angle = Double.acos(x)
print(angle) // 1.5707963267948966 (radians)
print(angle * 180.0 / .pi) // 90.0 (degrees)
我的 Swift 代码需要帮助。我不知道如何使用 cos^-1。如果有人能告诉我方法就太好了。
let cosinus = cos((.pi * cosinusValue / 180))
acos()
和 BSD 库中的其他数学函数可以直接从 Swift 使用。示例:
import Darwin // or Foundation
let x = 0.0
let angle = acos(x)
print(angle) // 1.5707963267948966 (radians)
print(angle * 180.0 / .pi) // 90.0 (degrees)
在 Swift 的未来版本中,这些函数也可用作浮点类型的静态函数,比较 SE-0246 Generic Math(s) Functions
let x = 0.0
let angle = Double.acos(x)
print(angle) // 1.5707963267948966 (radians)
print(angle * 180.0 / .pi) // 90.0 (degrees)