如何偏移多边形边缘? [英] How to offset polygon edges?

查看:40
本文介绍了如何偏移多边形边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成闭合多边形的 point2D 列表.现在我想通过在给定内部或外部选项和偏移值的情况下偏移多边形来创建另一组 2D 点.我该怎么做?

I have a list of point2D that makes a closed polygon. Now I want to create another set of 2D points by offsetting the polygon given an option inside or outside and an offset value. How can I do it?

推荐答案

您需要使用 dircetion 才能定义什么是外部/内部.更好的是使用箭头的左侧/右侧(矢量).

You need to work with dircetion to be able to define what is outside/inside. Better is to work with to the left/right of the arrow (vector).

在我的例子中,偏移量在向量的右边,现在你需要计算红线的所有交点来定义线的新起点.

In my example the offset is to the right of the vector, now you need to calculate all intersections of the red lines to define the new start-end points of the lines.

示例:P0 = (5,2) &P1 = (2, 1.7)

Example: P0 = (5,2) & P1 = (2, 1.7)

V1 = -3,-0.3.顺时针旋转 90 度给我们向量 -0.3, 3 (a,b) -> (b, -a)

V1 = -3, -0.3. Rotating clock wise 90deg gives us vector -0.3, 3 (a,b) -> (b, -a)

将向量除以 3(大约是图中的距离)得到 (-0.1, 1)向量的设置点 P0 给出 P0' (5,2) - v(-0.1,1) = (4.9, 3)

Divide the vector by 3 (thats about the distance in the drawing) gives us (-0.1, 1) ofsetting point P0 by the vector gives P0' (5,2) - v(-0.1,1) = (4.9, 3)

这篇关于如何偏移多边形边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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