如何在 MATLAB 中求角度平分线
我有一个与此代码相关的问题:
t = -20:0.1:20;
plot3(zeros(size(t)),t,-t.^2);
grid on
hold on
i = 1;
h = plot3([0 0],[0 t(i)],[0 -t(i)^2],'r');
h1 = plot3([-1 0],[0 0],[-400 -200],'g');
for(i=2:length(t))
set(h,'xdata',[-1 0],'ydata',[0 t(i)],'zdata',[-400 -t(i)^2]);
pause(0.01);
end
在这段代码中,我绘制了两条相交线。 H1 和 H2。 H1 是固定的,H2 作为时间的函数移动。在这个例子中,H2 碰巧画出了一条抛物线,但它的运动可能是任意的。
如何计算并绘制线 H2 的每个位置的这两条相交线之间的角度平分线?我希望在图中看到平分线和线 H2 同时移动。
针对 H2 的一个位置解决此问题就足够了,因为对于 H2 相对于 H1 的所有方向来说,过程都是相同的。
I have a question connected to this code:
t = -20:0.1:20;
plot3(zeros(size(t)),t,-t.^2);
grid on
hold on
i = 1;
h = plot3([0 0],[0 t(i)],[0 -t(i)^2],'r');
h1 = plot3([-1 0],[0 0],[-400 -200],'g');
for(i=2:length(t))
set(h,'xdata',[-1 0],'ydata',[0 t(i)],'zdata',[-400 -t(i)^2]);
pause(0.01);
end
In this code, I plot two intersecting lines. H1, and H2. H1 is fixed, H2 moves as a function of time. H2 happens to trace a parabola in this example, but its movement could be arbitrary.
How can I calculate and draw the bisector of the angle between these two intersecting lines for every position of the line H2? I would like to see in the plot the bisector and the line H2 moving at the same time.
Solving this problem for one position of H2 is sufficient, since it will be the same procedure for all orientations of H2 relative to H1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不是几何天才,可能有一种更简单的方法可以做到这一点。截至目前,还没有人做出回应,所以这将是一件大事。
你在三个空间中有三个点:
设 A 为两条线段的公共顶点。
设 B 和 C 为两条线段上的两个已知点。
选择任意距离 r,其中
r <= 从 A 到 B 的距离
r <= 从 A 到 C 的距离
沿线段 AB 从 A 测量距离 r。这是RB点
从 A 沿线段 AC 测量距离或 r。这是点 RC
求连接 RB 和 RC 的线段的中点。这是点M
线段AM 是角CAB 的角平分线。
每个步骤都应该相对容易完成。
I am not a geometry genius, there is likely an easier way to do this. As of now, no one has responded though, so this will be something.
You have three points in three space:
Let A be the common vertice of the two line segments.
Let B and C be two known points on the two line segments.
Choose an arbitrary distance r where
r <= distance from A to B
r <= distance from A to C
Measure from A along line segment AB a distance of r. This is point RB
Measure from A along line segment AC a distance or r. This is point RC
Find the mid point of line segment connecting RB and RC. This is point M
Line segment AM is the angular bisector of angle CAB.
Each of these steps should be relatively easy to accomplish.
这基本上是 MatlabDoug 的方法,对他称为 M 的点的确定进行了一些改进。
Here is basically MatlabDoug's method with some improvement on the determination of the point he calls M.
我只是使用以下内容:
对 V 进行归一化,然后进行 A + V * 长度,得到从公共点开始的所需长度的线段。
(请注意,此方法不适用于沿一条线的 3 个点来生成垂直平分线,在这种情况下,它将生成一个没有长度的向量)
我添加了一个 C# 实现(在 XZ 平面中使用 Unity 3D Vector3 结构)处理垂直平分线和反射平分线,以防了解 MATLAB 的人可以翻译它。
另请注意,返回的平分线是单位长度的向量。使用“中心+平分线*长度”可以将其放置到世界空间中。
I just use the following:
Normalize V, then do A + V * length to get the line segment of the desired length that starts at the common point.
(Note that this method does not work on 3 points along a line to produce a perpendicular bisector, it will yield a vector with no length in that case)
I have added a C# implementation (in the XZ plane using Unity 3D Vector3 struct) that handles Perpendicular and Reflex bisectors in case someone that knows MATLAB would translate it.
Also note that the returned bisector is a vector of unit length. Using "center + bisector * length" could be used to place it into worldspace.