二维中两个向量的平分线(可能共线)

发布于 2024-11-18 09:37:29 字数 304 浏览 5 评论 0原文

一般如何找到两个向量的二等分 b = (bx, by)(我们考虑两个非零向量 u = (ux, uy), v = (vx, vy),可能是共线的)。

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

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

但对于共线向量

bx = by = 0.

示例:

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

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

杯别 2024-11-25 09:37:29

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

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|)零向量。

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.

茶底世界 2024-11-25 09:37:29

求 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)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文