polygon

Triangulate a polygon whose contour touches itself with poly2tri?

我只是一个虾纸丫 提交于 2019-12-08 04:28:29
问题 Is it possible to triangulate a polygon which touches itself (like in the image above) with poly2tri? 回答1: My solution: use Clipper to offset the polygon, triangulate it, and re-offset to obtain the final mesh. Of course, this is a hack which does not always work since offsetting the polygon is a possibly destructive operation (if the are tiny ends on the polygon, they might not offset back to their original positions). 来源: https://stackoverflow.com/questions/34221075/triangulate-a-polygon

Adding a square polygon of a set size around a point using leaflet.js

五迷三道 提交于 2019-12-08 03:31:36
问题 Bit of a weird one I hope someone can help out with. In leaflet, once the user has entered a lat/lng and added a point to the map I want to be able to also add a 10km square around that point. I've tried looking around for a calculation to find the corners of the square x Km away but haven't dug anything up. But surely there's an easier way! Does anyone have any thoughts? It'd be lovely to just say L.polygon then pass in a centre point and a square size. Thanks, Tayler 回答1: Initialize a L

Bezier path see if it crosses

北战南征 提交于 2019-12-08 03:08:16
问题 I have a code that lets the user draw a shape, I'm using UIBezierPath for this. But I need to see if the shape crosses itself, for example like this: http://upload.wikimedia.org/wikipedia/commons/0/0f/Complex_polygon.svg Then it's not a a valid shape. How can I find this? Edit: I still haven't solved this. I save all the points between the lines in the path in a array. And then I loop through the array and try to find if any lines intersects. But it does not work, sometimes it says that there

Visibility of polygons from an edge

北慕城南 提交于 2019-12-08 01:50:48
问题 Given is a 2D are with the polygons. I need to find out the polygons visible in a perpendicular line of sight from the a given line segment lying within that area. e.g. Further, What can be the optimizations when the polygons have only vertical and horizontal edges. 回答1: I'd suggest the following ... Rotate the problem so your 'line of sight' segment is aligned to the x axis. Find the (axis aligned) bounding rectangle (BR) of each polygon. Sort the polygons using the Y coordinate of the

how to detemine if a line segment is inside of a polygon?

旧时模样 提交于 2019-12-08 00:33:02
问题 we have a line segment L defined by two points from polygon and a polygon P define by 4 or more points, I need an algorithm determine if L is inside P ? EDIT: The line segment must be completely inside the polygon, if only partly it will defined as outside. for example look below picture: few more examples: 回答1: Step 1 : Is L crossing any edge of P? If yes, L is not inside P. If no, see step 2 Step 2 : Where is the middle M of L? If M is inside P, L is inside P. Just in case: http://en

Plot polygon in R

拈花ヽ惹草 提交于 2019-12-07 21:10:47
问题 I want to plot a polygon from a sample of points (in practice, the polygon is a convex hull) whose coordinates are x <- c(0.66, 0.26, 0.90, 0.06, 0.94, 0.37) y <- c(0.99, 0.20, 0.38, 0.77, 0.71, 0.17) When I apply the polygon function I get the following plot: plot(x,y,type="n") polygon(x,y) text(x,y,1:length(x)) But it is not what I expect... What I want is the following plot: I obtained this last plot by doing: good.order <- c(1,5,3,6,2,4) plot(x,y,type="n") polygon(x[good.order], y[good

Overlay ggplot grouped tiles with polygon border depending on extra factor

一世执手 提交于 2019-12-07 19:45:57
问题 I have a data frame with x and y positions and two factor columns blocknr and cat: dput(testData) structure(list(xpos = c(2L, 8L, 5L, 8L, 1L, 4L, 5L, 1L, 8L, 4L, 3L, 2L, 6L, 5L, 1L, 7L, 3L, 4L, 3L, 7L, 1L, 6L, 7L, 7L, 2L, 5L, 3L, 4L, 6L, 7L, 1L, 5L, 1L, 6L, 4L, 5L, 3L, 6L, 4L, 8L, 1L, 3L, 4L, 6L, 7L, 3L, 2L, 6L, 4L, 2L, 1L, 7L, 4L, 8L, 2L, 3L, 2L, 5L, 8L, 2L, 8L, 3L, 3L, 5L, 6L, 7L, 1L, 5L, 6L, 4L, 2L, 6L, 7L, 1L, 5L, 7L, 2L), ypos = c(1L, 2L, 8L, 1L, 6L, 7L, 1L, 4L, 6L, 1L, 2L, 3L, 4L, 5L,

How to test if a line intersects a convex polygon?

可紊 提交于 2019-12-07 19:44:31
问题 Assume you are given the equation of a line (in 2d), and the equations of lines that form a convex polygon (the polygon could be unbounded). How do I determine if the line intersects the polygon? Furthermore, are there computational geometry libraries where such tasks are pre-defined? I ask because I'm interested not just in the 2D version but n-dimensional geometry. 回答1: For the 2D case, I think the problem simplifies a bit. The line partitions the space into two regions. If the polygon is

Changing a Polygon's Points

岁酱吖の 提交于 2019-12-07 17:02:22
问题 SOLUTION Dynamic Margin on Window Drag So I'm trying to get my polygon to move as the window is moved. I have; private void ResetPolygon(Point Point1, Point Point2, Point Point3) { SpeechPoly.Points.Clear(); ObservableCollection<Point> myPointCollection = new ObservableCollection<Point>(); myPointCollection.Add(Point3); myPointCollection.Add(Point2); myPointCollection.Add(Point1); foreach (Point p in myPointCollection) { SpeechPoly.Points.Add(p); } } private void Window_LocationChanged(object

Drawing equidistant points from the sides of a polygon

喜你入骨 提交于 2019-12-07 15:17:16
问题 I am drawing a polygon with the following vertices x y -0.02208709 -0.039161304 0.01184081 -0.020268029 0.04578401 -0.001351904 0.02210236 0.039176396 -0.01185226 0.020252146 -0.04578784 0.001352696 using the following code plot(x,y) polygon(x,y) points(mean(x),mean(y),col="red") Now I want to plot 50 equally-spaced points along the sides of polygon. Any suggestion how to do it? 回答1: You can do this with spsample from the sp package. First we'll load the library and read in your vertices.