Direction of two points

主宰稳场 提交于 2019-12-20 16:23:05

问题


Some high school math concept has been forgotten, so I ask here.

If I have two points p1(x1,y1), p2(x2,y2), the direction is P1-->p2, that's p1 points to p2. To represent this direction by vector, is it Vector(x2-x1,y2-y1) or Vector(x1-x2, y1-y2)?

By the way, what is the purpose to normalize a vector?


回答1:


  • Answer 1: it is Vector(x2-x1,y2-y1)
  • Answer 2: Normalizing means to scale the vector so that its length is 1. It is a useful operation in many computations, for example, normal vectors should be specified normalized for lighting calculations in computer graphics. The normalized vector of v(x,y) is vn(x/Length(v), y/length(v)).

HTH




回答2:


A nice way to remember which way the subtraction goes is to think of what the vector actually does. Imagine vector v resting at p1, pointing and connecting to p2. This means that p1 + v = p2. Therefore, v = p2-p1.



来源:https://stackoverflow.com/questions/5483937/direction-of-two-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!