两点之间的距离 [英] Distance between two points

查看:151
本文介绍了两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别:

 距离= point1.subtract(点2).length;
 

 距离= Point.distance(点1,点2);
 

解决方案

由于这个问题是标签优化,手写的勾股定理将是最有效的方式找到在AS3中两点之间的距离,只要你不T:

  1. 在实例化一个对象,而这样做
  2. 在调用任何更多的数学函数不是必要的(做手工的ABS等)
  3. 请不要实际调用的任意的功能,如果你能帮助它

几乎所有内置的方法是方便。他们不求速度进行了优化。

Is there any difference between:

distance = point1.subtract(point2).length;

and

distance = Point.distance(point1, point2);

解决方案

Since this question is tagged Optimization, the longhand for the pythagorean theorem will be the most efficient way to find the distance between two points in AS3, provided that you don't:

  1. Instantiate an object while doing it
  2. Call any more Math functions than necessary (manually do an Abs, for example)
  3. Don't actually call any functions if you can help it

Almost all the built-in methods are conveniences. They're not optimized for speed.

这篇关于两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆