2021-10-11|閱讀時間 ‧ 約 2 分鐘

三角函數 (C++)

C++ 使用三角函數

C++ 裡面使用三角函數輸入的不是角度,而是弧度
弧度 = 角度×π÷180°

使用巨集
#define rad 0.01745329252
  • rad = π÷180° = 0.01745329252 (工程計算機CASIO fx-991ES PLUS)

使用標頭檔
#include cmath //使用三角函數(sin、cos......) #include iostream //std::cout

正弦sin

    sin(0°) = 0 sin(30°) = 1/2 sin(45°) = (√2)/2 = 0.7071067812... sin(60°) = (√3)/2 = 0.8660254038... sin(90°) = 1

C++範例 三角函數sin(弧度) Output 三角函數sin(弧度) sin(0) = 0 sin(30) = -0.988032 sin(45) = 0.850904 sin(60) = -0.304811 sin(90) = 0.893997

分享至
成為作者繼續創作的動力吧!
C++新手教學正在規畫緩慢更新(圖片、內容增加、程式碼文字)_2023/04/17,文章有錯誤的地方還請留言指正,謝謝各位
從 Google News 追蹤更多 vocus 的最新精選內容從 Google News 追蹤更多 vocus 的最新精選內容

發表回應

成為會員 後即可發表留言