cos()

설명

각(라디안)의 코사인 계산. 결과는 -1과 1 사이.

문법

cos(rad)

매개변수

  • rad: 라디안 각 (float).

반환값

  • 각의 코사인 (double).

예제 코드

void setup() { Serial.begin(9600); for (int angle = 0; angle <= 180; angle += 15) { float angle_rad = angle * M_PI / 180; float cos_result = cos(angle_rad); Serial.print("cos("); Serial.print(angle); Serial.print("°) = "); Serial.println(cos_result); } } void loop() { }

The result in Serial Monitor:

COM6
Send
cos(0°) = 1.00 cos(15°) = 0.97 cos(30°) = 0.87 cos(45°) = 0.71 cos(60°) = 0.50 cos(75°) = 0.26 cos(90°) = -0.00 cos(105°) = -0.26 cos(120°) = -0.50 cos(135°) = -0.71 cos(150°) = -0.87 cos(165°) = -0.97 cos(180°) = -1.00
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

더보기

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at ArduinoGetStarted@gmail.com, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.