将弧度转换为度数的方法是什么?

发布于 2024-07-05 09:35:41 字数 93 浏览 8 评论 0原文

我偶尔会遇到这种情况,但总是忘记该怎么做。

其中之一是经常出现的事情。

另外,将以弧度表示的角度转换为度数并再转换回来的公式是什么?

I run into this occasionally and always forget how to do it.

One of those things that pop up ever so often.

Also, what's the formula to convert angles expressed in radians to degrees and back again?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

另类 2024-07-12 09:35:41

pi 弧度 = 180 度

因此 1 度 = pi/180 弧度

或 1 弧度 = 180/pi 度

pi Radians = 180 degrees

So 1 degree = pi/180 radians

or 1 radian = 180/pi degrees

2024-07-12 09:35:41

360 度 = 2*pi 弧度

这意味着 deg2rad(x) = x*pi/180 且 rad2deg(x) = 180x/pi;

360 degrees = 2*pi radians

That means deg2rad(x) = x*pi/180 and rad2deg(x) = 180x/pi;

青柠芒果 2024-07-12 09:35:41

x 弧度(度)-> x*180/pi
x 度(以拉德为单位)-> x*pi/180

我猜你是否想为此创建一个函数[用 PHP]:

function convert($type, $num) {
    if ($type == "rads") {
          $result = $num*180/pi();
        }

    if ($type == "degs") {
          $result = $num*pi()/180;
        }

    return $result;
  }

是的,这可能可以写得更好。

x rads in degrees - > x*180/pi
x degrees in rads -> x*pi/180

I guess if you wanted to make a function for this [in PHP]:

function convert($type, $num) {
    if ($type == "rads") {
          $result = $num*180/pi();
        }

    if ($type == "degs") {
          $result = $num*pi()/180;
        }

    return $result;
  }

Yes, that could probably be written better.

划一舟意中人 2024-07-12 09:35:41

在javascript中你可以这样做

radians = degrees * (Math.PI/180);

degrees = radians * (180/Math.PI);

In javascript you can do it this way

radians = degrees * (Math.PI/180);

degrees = radians * (180/Math.PI);
秋风の叶未落 2024-07-12 09:35:41

.NET8:https://github.com/dotnet/runtime/issues/86402

double.RadiansToDegrees(1);
float.DegreesToRadians(1);

.NET8: https://github.com/dotnet/runtime/issues/86402

double.RadiansToDegrees(1);
float.DegreesToRadians(1);
提笔落墨 2024-07-12 09:35:41

这对我来说已经足够好了:)

// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)

This works well enough for me :)

// deg2rad * degrees = radians
#define deg2rad (3.14159265/180.0)
// rad2deg * radians = degrees
#define rad2deg (180/3.14159265)
烟雨扶苏 2024-07-12 09:35:41

180 度 = PI * 弧度

180 degrees = PI * radians

天煞孤星 2024-07-12 09:35:41

360 度为 2*PI 弧度

您可以在以下位置找到转换公式: http://en.wikipedia .org/wiki/Radian#Conversion_ Between_radians_and_ Degrees

360 degrees is 2*PI radians

You can find the conversion formulas at: http://en.wikipedia.org/wiki/Radian#Conversion_between_radians_and_degrees.

凑诗 2024-07-12 09:35:41
radians = degrees * (pi/180)

degrees = radians * (180/pi)

至于实现,主要问题是您希望 pi 的值有多精确。 这里有一些相关的讨论

radians = degrees * (pi/180)

degrees = radians * (180/pi)

As for implementation, the main question is how precise you want to be about the value of pi. There is some related discussion here

滿滿的愛 2024-07-12 09:35:41

以弧度表示的完整圆是 2*pi。 一个完整的圆(以度为单位)为 360。要从度数转换为弧度,则为 (d/360) * 2*pi,或 d*pi/180。

a complete circle in radians is 2*pi. A complete circle in degrees is 360. To go from degrees to radians, it's (d/360) * 2*pi, or d*pi/180.

朦胧时间 2024-07-12 09:35:41
radians = (degrees/360) * 2 * pi
radians = (degrees/360) * 2 * pi
锦上情书 2024-07-12 09:35:41

下面是一些使用 rad(deg)deg(rad) 以及两个更有用的函数扩展 Object 的代码:getAngle(point1,point2)getDistance(point1,point2) 其中点需要具有 xy 属性。

Object.prototype.rad = (deg) => Math.PI/180 * deg;
Object.prototype.deg = (rad) => 180/Math.PI * rad;
Object.prototype.getAngle = (point1, point2) => Math.atan2(point1.y - point2.y, point1.x - point2.x);
Object.prototype.getDistance = (point1, point2) => Math.sqrt(Math.pow(point1.x-point2.x, 2) + Math.pow(point1.y-point2.y, 2));

Here is some code which extends Object with rad(deg), deg(rad) and also two more useful functions: getAngle(point1,point2) and getDistance(point1,point2) where a point needs to have a x and y property.

Object.prototype.rad = (deg) => Math.PI/180 * deg;
Object.prototype.deg = (rad) => 180/Math.PI * rad;
Object.prototype.getAngle = (point1, point2) => Math.atan2(point1.y - point2.y, point1.x - point2.x);
Object.prototype.getDistance = (point1, point2) => Math.sqrt(Math.pow(point1.x-point2.x, 2) + Math.pow(point1.y-point2.y, 2));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文