Bisector of two vectors in 2D (may be collinear)

ぐ巨炮叔叔 提交于 2019-12-12 15:40:29

问题


How to find a bisecor b = (bx, by) of two vectors in general (we consider two non–zero vectors u = (ux, uy), v = (vx, vy), that may be collinear ).

For non-collinear vector we can write:

bx = ux/|u| + vx / |v|
by = uy/|u| + vy / |v|

But for collinear vectors

bx = by = 0.

Example:

u = (0 , 1)
v = (0, -1)
b = (0, 0)

回答1:


A general and uniform approach is to get the angle of both vectors

theta_u = math.atan2(ux, uy)
theta_v = math.atan2(vx, vy)

and to create a new vector with the average angle:

middle_theta = (theta_u+theta_v)/2
(bx, by) = (cos(middle_theta), sin(middle_theta))

This way, you avoid the pitfall that you observed with opposite vectors.

PS: Note that there is an ambiguity in what the "bisector" vector is: there are generally two bisector vectors (typically one for the smaller angle and one for the larger angle). If you want the bisector vector inside the smaller angle, then your original formula is quite good; you may handle separately the special case that you observed for instance by taking a vector orthogonal to any of the two input vectors (-uy/|u|, ux/|u|) if your formula yields the null vector.




回答2:


To find the unit bisection vectors of u and v.

if u/|u|+v/|v| !=0

first calculate the unit vector of u and v

then use the parallelogram rule to get the bisection (just add them)

since they both have unit of 1, their sum is the bisector vector 

then calculate the unit vector of the calculated vector.

else (if u/|u|+v/|v| ==0):
 (if you use the method above, it's like a indintermination: 0*infinity=?)

 if you want the bisector of (u0v) if u/|u| = (cos(t),sin(t)) 
 take b=(cost(t+Pi/2),sin(t+Pi/2)) = (-sin(t),cos(t) )as the bisector
 therefore if u/|u|=(a1,a2) chose b=(-a2,a1)

Example:

u=(0,1)
v=(0,-1)
the bisector of (u0v):
b=(-1,0)


来源:https://stackoverflow.com/questions/6562784/bisector-of-two-vectors-in-2d-may-be-collinear

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