首页 > 文档 > atan2()
2017
07-12

atan2()

名称:atan2()

 

例子:

void draw() {
background(204);
translate(width/2, height/2);
float a = atan2(mouseY-height/2, mouseX-width/2);
rotate(a);
rect(-30, -5, 60, 10);
}

 

描述:

从X正轴计算从指定点到坐标原点的角度(弧度)。 其值作为浮点型返回,范围从PI到-PI。 atan2()函数最常用于将几何定位到光标的位置。注意:计算正切的结构时,点的y坐标是第一个参数,x坐标是第二个参数。

 

语法:

atan2(y, x)


参数:

y float: y-coordinate of the point     点的y坐标
x float: x-coordinate of the point     点的x坐标

 

返回:float

 

相关:

tan()



最后编辑:
作者:Hewes
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。