如何在给定线段的情况下获取垂直矢量 [英] How to get perpendicular vectors given a line segment
本文介绍了如何在给定线段的情况下获取垂直矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取A,B,C和D点?
How to get point A, B , C, and D?
如果AB和CD垂直于p0p1.
if AB and CD are perpendicular to p0p1.
假设p0A,p0B,p1C和p1D具有标准化长度
Assume p0A, p0B, p1C, and p1D have normalized length
推荐答案
线的方向由d = normalize(p1 - p0)
给出.要计算垂直向量,我们可以使用与(0, 0, 1)
的叉积.结果是:
The direction of the line is given by d = normalize(p1 - p0)
. To calculate a perpendicular vector we can use the cross product with (0, 0, 1)
. Which results in:
d_left = (-d.y, d.x)
d_right = (d.y, -d.x)
您还没有说过坐标系统如何对齐,因此d_left
可能会变成d_right
,反之亦然.
You haven't said how your coordinate system is aligned, so d_left
might become d_right
and vice versa.
然后使用以下方法获得所需的分数:
You then get the desired points with:
A = p0 + d_left
B = p0 + d_right
C = p1 + d_left
D = p1 + d_right
这篇关于如何在给定线段的情况下获取垂直矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文