2011-07-03 24 views
3

如何在一般情況下找到兩個向量的bisec b =(bx,by)(我們考慮兩個非零向量u =(ux,uy),v = vx,vy),這可能是共線的)。2D中兩個向量的平分線(可以是共線的)

對於非共線向量,我們可以寫出:

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

但對於共線矢量

bx = by = 0. 

實施例:

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

如果解決了您的問題,您應該考慮將答案標記爲已接受。 – EOL

回答

5

爲了找到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) 
the bisector of (u0v): 
b=(-1,0) 
5

的一般和均勻的方法是獲得兩種載體

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/|u|, ux/|u|)中的任何一個矢量正交的矢量來分別觀察。

相關問題