ラジアンと角度の変換をする (C++)
C++
Published: 2020-07-11

確認環境

$ g++ --version
g++ (Homebrew GCC 9.2.0) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

調査

test.cpp

#include <bits/stdc++.h>
using namespace std;

int main() {
    // degree -> radian
    double target_degree = 45;
    double radian = target_degree * M_PI / 180.0;
    printf("radian: %.10f\n", radian);

    // radian -> degree
    double degree = radian * 180.0 / M_PI;
    printf("degree: %.10f\n", degree);
}

出力結果

radian: 0.7853981634
degree: 45.0000000000