如何画2个点和斜率的平行四边形
我有一个起点(x0,y0),一个终点(x2,y2)和一个斜率((x0,y0)和(x3,y3)之间的线),我想画一个平行四边形。
(x0,y0) (x1,y1)
__________
\ \
\ \
\_________\
(x3,y3) (x2,y2)
有人可以告诉我该怎么做吗?或者建议一些算法什么的。
编辑:这里 y0 = y1 和 y2 = y3
问候
I have a start point(x0,y0), a end point(x2,y2) and a slope (of line between (x0,y0) and (x3,y3)) and i want to draw a parallelogram.
(x0,y0) (x1,y1)
__________
\ \
\ \
\_________\
(x3,y3) (x2,y2)
Can somebody tell me how to do this? or suggest some algorithm or something.
Edit: Here y0 = y1 and y2 = y3
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我们将斜率表示为
m
并假设y0=y1
和y3=y2
,那么我们可以计算x3
> 像这样:类似地:
If we denote the slope as
m
and suppose thaty0=y1
andy3=y2
, then we can computex3
like so:And similarly:
一般来说,如果平行四边形的边不平行于轴:
z0 和 z1 的公式为:
In general, if the sides of the parallelogram are not parallel to the axes:
The formulas for z0 and z1 are:
您没有足够的数据。只需两个点和一个斜率,您就有无限可能的平行四边形(两个点和一个斜率仅定义两条平行线,而不是平行四边形)。
从你的绘图中,你似乎正在寻找具有水平边框的平行四边形,如果是这样,它会给你第二个斜率,并且你有 y0 = y1 和 y2 = y3。
使用 slop 可以得到 x3:
只有 x1 仍然未知:
显然,当您没有解决方案或无限解决方案时,我没有检查所有退化情况。我把它留给别人。
You do not have enough data. With just two points and a slope you have an infinity of possible parallelograms (two points and a slope defines just two parallels, not a parallelogram).
From your drawing you seem to be looking for the parallelogram with horizontal borders, if so it gives you a second slope and you have y0 = y1 and y2 = y3.
You get x3 using the slop with:
There is only x1 still unknown:
Obviously I did not checked for all degenerating cases when you have no solution or infinite solutions. I leave that to someone else.