5

简单的javascript角度问题:

javascript中角度进入哪个方向?

是吗:

   90
180    0
   270

或者

   270
180    0
   90

或者是其他东西?

我知道 javascript 使用弧度,我使用度数来表示。

4

3 回答 3

3

在规则的单位圆上,y轴指向上方,因此角度逆时针增加:

在此处输入图像描述

但是在 HTML 文档或 canvas 元素中,y轴指向下方,因此如果您使用cos(t)sin(t)增加角度t并在x、y上绘制点,结果将是顺时针方向:

       270
 180          0
       90

现场示例

正如其他答案所说,这不是因为角度在 JavaScript 中的工作方式,而是因为坐标空间的方向。

于 2013-04-08T16:21:23.020 回答
0

An angle by definition has no direction, but is rather the measure of the radial distance between two intersecting lines.

Various libraries/css methods might measure the angle from a certain direction - like up for example, but this totally depends on the context.

Javascript itself has no concept of directions to angles - it is something that has to be built on top of javascript's angle functions.

于 2013-04-08T15:47:23.453 回答
0

它可能取决于您使用的 javascript 库。

然而,在大多数情况下,旋转度数是相对于原始位置的。因此,旋转 180 度总是会将图像(或其他任何东西)颠倒过来,否则元素将需要了解,我将称之为“向上”(哪种方式是向上方向)本身。

于 2013-04-08T15:44:43.837 回答