针对矩形裁剪多边形
问题说明
今天,我有一个(简单的)渲染问题.我当前的项目从文件获取数据以生成SVG文件.多亏了SVG格式,将事物绘制为多边形非常容易,但是我有一个问题:我的某些多边形位于页面的AND内(这意味着它们中的某些部分会显示,而其余部分由于事实而不会显示)它们超出了显示限制).为了优化最终的SVG文件,我需要将多边形缩小为更简单的形式.
today I have a (simple) rendering problem for you. My current project gets datas from a file to generate a SVG file. Drawing things as polygon is pretty easy thanks to the SVG format, but I have a single problem: some of my polygons are in AND out of the page (meaning that some parts of them are displayed while the rest is not shown due to the fact they are out of the display limit). In order to optimize the final SVG file I need to reduce my polygon to a simpler form.
将灰色矩形视为我的页面. 将绿色多边形视为我实际绘制的东西.
Consider the grey rectangle as my page. Consider the green polygon as the thing I actually draw.
第一张照片向您展示了我实际拥有的东西,第二张照片向您展示了我想要的最终结果.
First picture shows you the thing that I actually have while the second picture shows you the final result I want to have.
首先,我考虑将多边形简化为简单的三角形,以便仅在显示范围内绘制点.但是我认为存在一个更简单的解决方案...如果您有,请毫不犹豫地与我分享:)
First I thought to reduce my polygon in simple triangles in order to only draw points in the display limits. But I think a simpler solution exists... if you have it do not hesitate to share it with me :)
我也要处理这个棘手的情况:
I have this tricky case to handle as well :
谢谢.
正确答案
- 使用矩形剪切多边形.我们将这个问题减少到
- 使用线剪切多边形.我们将其简化为一个更简单的问题:
- 用一条线剪切多边形的一个边缘.真的是
- 查找线段与线的交点(如果存在).
- Clipping a polygon with a rectangle. We reduce this problem to
- clipping a polygon with a line. We reduce this to an even simpler problem:
- clipping one edge of a polygon with a line. Which is really just
- Finding the intersection of a line segment with a line (if it exists).
考虑到您的线条是垂直还是水平,最后一个问题很容易.够了吗?
The last problem is pretty easy, considering that your lines are vertical or horizontal. Is that enough?
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangjaiae
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20