How to get perpendicular vectors given a line segment [closed]

房东的猫 提交于 2019-12-12 22:31:31

问题


How to get point A, B , C, and D?

if AB and CD are perpendicular to p0p1.

Assume p0A, p0B, p1C, and p1D have normalized length


回答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)

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



回答2:


Suppose rotate(p,d) is a operator to rotate p vector d angle.

Then if the inclination of p0p1 with positive x-axis is x. Then,

A = p0 + rotate(p1-p0,pi/2)/|p1-p0|
B = p0 + rotate(p1-p0,-pi/2)/|p1-p0|
C = p1 + rotate(p1-p0,pi/2)/|p1-p0|
D = p1 + rotate(p1-p0,-pi/2)/|p1-p0|



来源:https://stackoverflow.com/questions/17831159/how-to-get-perpendicular-vectors-given-a-line-segment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!