Math 二维中两个向量的平分线(可以共线) 如何找到两个向量的BISECOR B=(Bx,by)一般(我们考虑两个非零向量u=(UX,UY),V=(Vx,Vy),这可能是共线的)。

Math 二维中两个向量的平分线(可以共线) 如何找到两个向量的BISECOR B=(Bx,by)一般(我们考虑两个非零向量u=(UX,UY),V=(Vx,Vy),这可能是共线的)。,math,vector,bisect,Math,Vector,Bisect,对于非共线向量,我们可以写: bx = ux/|u| + vx / |v| by = uy/|u| + vy / |v| 但对于共线向量 bx = by = 0. 例如: u = (0 , 1) v = (0, -1) b = (0, 0) u=(0,1) v=(0,-1) the bisector of (u0v): b=(-1,0) 求u和v的单位二分向量 if u/|u|+v/|v| !=0 first calculate the unit vector of u and v

对于非共线向量,我们可以写:

bx = ux/|u| + vx / |v|
by = uy/|u| + vy / |v|
但对于共线向量

bx = by = 0.
例如:

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

求u和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)
例如:

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

一种通用且统一的方法是获得两个向量的角度

theta_u = math.atan2(ux, uy)
theta_v = math.atan2(vx, vy)
要创建具有平均角度的新向量,请执行以下操作:

middle_theta = (theta_u+theta_v)/2
(bx, by) = (cos(middle_theta), sin(middle_theta))
这样,您就避免了使用相反向量观察到的陷阱


PS:请注意,“平分线”向量的含义不明确:通常有两个平分线向量(通常一个用于较小角度,一个用于较大角度)。如果你想让平分线向量在较小的角度内,那么你原来的公式很好;你可以单独处理你观察到的特殊情况,例如,通过向量正交于两个输入向量<代码>(-uy/uu,ux/uuü)< /> >如果你的公式产生空向量。

你应该考虑将答案标记为接受,如果它解决了你的问题。