首页 > 文档 > dist() 距离
2017
07-13

dist() 距离

名称:dist()

 

例子:

// Sets the background gray value based on the distance
// of the mouse from the center of the screen
void draw() {
noStroke();
float d = dist(width/2, height/2, mouseX, mouseY);
float maxDist = dist(0, 0, width/2, height/2);
float gray = map(d, 0, maxDist, 0, 255);
fill(gray);
rect(0, 0, width, height);
}

 

描述:

计算两点之间的距离。

语法:

dist(x1, y1, x2, y2)
dist(x1, y1, z1, x2, y2, z2)

 

参数:

x1 float: x-coordinate of the first point  第一个点的x坐标
y1 float: y-coordinate of the first point  第一个点的y坐标
z1 float: z-coordinate of the first point  第一个点的z坐标
x2 float: x-coordinate of the second point  第二个点的x坐标
y2 float: y-coordinate of the second point  第二个点的y坐标
z2 float: z-coordinate of the second point  第二个点的z坐标

 

返回:float



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

dist() 距离》有 1 条评论

  1. Pingback 引用通告: mag() 向量大小 | Processing编程艺术

留下一个回复

你的email不会被公开。