如何计算垂直线段的端点? [英] How to calculate end points of perpendicular line segments?

查看:54
本文介绍了如何计算垂直线段的端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道线段的端点以及我想创建的垂直端盖的距离/大小,但我需要计算垂直线的端点.我一直在使用 45-45-90 三角形和点积将头撞在墙上,但我似乎无法将它们组合在一起.

I know the end points of a line segment and the distance/size of the perpendicular end caps I'd like to create but I need to calcuate the end points of the perpendicular line. I've been banging my head against the wall using either 45-45-90 triangles and dot products but I just can't seem to make it come together.

我知道蓝色的点和红色的点的距离,我需要找到红色的点.

I know the points in blue and the distance to the points in red, I need to find the points in red.

在标记为重复之前,我尝试了 这个问题 但它导致端盖总是垂直的.

Before marking as duplicate, I tried the answer posted in this question but it resulted in end caps which were always vertical.

http://rauros.net/files/caps.png http://rauros.net/文件/caps.png

推荐答案

如果 B1 是两个红点之间的蓝点,而 B2 是另一个蓝点,那么这样做的方法是:

If B1 is the blue point between the 2 red points, and B2 is the other blue point then the way to do this is:

  • 找到 B1 - B2
  • 标准化这个向量
  • 然后将此向量放大为红点之间距离的一半
  • 旋转 90 度
  • 将此向量添加到 B1(这是 R1)
  • 从 B1 中减去这个向量(这是 R2)

以上所有内容都相当简单 - 最棘手的部分是弄清楚如何将其写成文本!

All of the above is fairly straightforward - the trickiest bit would be figuring out how to write it out in text!

这可能会有所帮助 - 矩阵旋转 90 度:

This might be helpful though - matrix to rotate by 90 degrees:

[ 0  -1 ]
[ 1   0 ]

这篇关于如何计算垂直线段的端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆