C++程序来找到给定值的反余弦值

2023年 8月 28日 53.8k 0

C++程序来找到给定值的反余弦值

Sine, cosine, tangent, and a few more ratios are some of the ones we utilize the most in trigonometry. These ratios can be computed from an angle. However, we can also determine the angle using inverse trigonometric functions if we know the ratio values.

在本教程中,我们将介绍如何使用C++的反余弦(arccosine)函数将余弦值转换为弧度角。

The acos() function

反余弦函数被用来使用acos()方法计算角度。这个函数可以在C++标准库中找到。为了使用这个方法,我们必须导入cmath库。这个函数接受余弦值作为参数,并返回以弧度为单位的角度。下面使用简单的语法:

Syntax

#include
acos( )

登录后复制

The cosine value must be in the range [-1 to +1] (both included). Otherwise, a domain error will be raised, and it will return Not-A-Number (nan). The returned value will be in the range [0, π] (both included)

算法

  • 将余弦值 x 作为输入
  • 使用 acos( x ) 来计算 cos−1(x)
  • Return result.

Example

#include
#include
using namespace std;

float solve( float x ) {
float answer;
answer = acos( x );
return answer;
}

int main()
{
float angle, ang_deg;
angle = solve( 0.7071067 );
ang_deg = angle * 180 / 3.14159;

cout

相关文章

JavaScript2024新功能:Object.groupBy、正则表达式v标志
PHP trim 函数对多字节字符的使用和限制
新函数 json_validate() 、randomizer 类扩展…20 个PHP 8.3 新特性全面解析
使用HTMX为WordPress增效:如何在不使用复杂框架的情况下增强平台功能
为React 19做准备:WordPress 6.6用户指南
如何删除WordPress中的所有评论

发布评论