基于两点绘制工字梁
我有两个点结构,我需要根据这些点绘制工字梁,其中每个点代表工字梁两侧的横截面。端盖的宽度应是固定且任意的。
基本上我需要画三条线。首先,我将 DrawLine(Point1, Point2),然后我需要数学来弄清楚如何以垂直角度绘制接下来的两条线,以便它们以 Point1 和 Point2 为中心。
下图显示了我需要根据中心线绘制的内容。然而,这条线可以是任何角度。连接线的 Point1 和 Point2 可以位于 2D 空间中的任何位置。
I have two Point structures and I need to draw an I-Beam based on those points, where each point represents the cross-section on either side of the I-Beam. The width of the end caps should be fixed and arbitrary.
Basically I need to draw three lines. First I'll DrawLine(Point1, Point2), then I need the math to figure out how to draw the next two lines on perpendicular angles so that they are centered on Point1 and Point2.
The image below shows what I need to draw based on the center line. However, this line can be at any angle. The Point1 and Point2 that connect the line can be anywhere in a 2D space.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用 LineCaps:
并调用它:
来自 CustomLineCap 类
You can try playing around with LineCaps:
and call it:
From CustomLineCap Class
假设宽度是工字梁 I 部分宽度的一半,首先找到所绘制的第一条线的斜率。
接下来,取斜率的负倒数,并从 Point1 开始在两个方向上绘制一条长度宽度的线。这就是为什么宽度是你想要绘制的宽度的一半。
最后从点 2 开始在两个方向上画一条长宽的线。
这是绘制垂直线的数学公式。
Assuming a width that's half the width of the I part of the I beam, first you find the slope of the first line you drew.
Next, you take the negative inverse of the slope, and draw a line from Point1 of length width in both directions. That's why width is half of the width you want to draw.
Finally you draw a line from Point 2 of length width in both directions.
Here's the mathematical formula for drawing a perpendicular line.