polygon

java - merge adiacent rectangles into a polygon

强颜欢笑 提交于 2019-12-03 03:29:26
I have a set of rectangles that have the same width and height and are always adiacent. I know the position of all the vertices, each one having only 4. (because is a square). This image can explain this: If there are any gaps, is ok if the algorithm will 'fill' the gap. I searched a lot, and could not find anything good.. I need an simple algorithm, it doesn't have to be that efficient.. Let's say that we got 7 rectangles like in the second polygon example from the image. Is ok if I first merge 1 with 2, then merge our new polygon with 3, and so on, it doesn't have to be that fast, because

Algorithm for finding a point in an irregular polygon

假装没事ソ 提交于 2019-12-03 03:14:11
Imagagine I have a polygon like the following: I am looking for a C# algorithm with whom I can find a point (could be the middlepoint or also a random point) inside any polygon. For finding the center of mass I used the following algorithm: private Point3d GetPolyLineCentroid(DBObject pObject, double pImageWidth, double pImageHeight) { Point2d[] pointArray = GetPointArrayOfRoomPolygon(pObject); double centroidX = 0.0; double centroidY = 0.0; double signedArea = 0.0; double x0 = 0.0; // Current vertex X double y0 = 0.0; // Current vertex Y double x1 = 0.0; // Next vertex X double y1 = 0.0; //

Put label in the “center” of an SVG path

匆匆过客 提交于 2019-12-03 02:10:00
I'm trying to draw a label on a polygon of an svg file. The problem I'm facing is to find out roughly the center of this polygon to place the label, as the path's coordinates are in svg format and need to be parsed. Is there an easier way to determine the center of an svg polygon (maybe someone can point out a javascript library or a snippet)? I'm using Raphael javascript library to manipulate the svg, but it doesn't seem to go beyond the standard svg functionality. You could try the following approximation for doing something similar to the polygon suggestion, based on SVG DOM methods: var

Finding largest subset of points forming a convex polygon

邮差的信 提交于 2019-12-03 02:01:29
I'm looking for an algorithm for finding largest subset of points (by largest i mean in number) that form a convex polygon from the given set of point. I think this might be solvable using DP but i'm not sure. Is it possible to do this in O(n^3) ? Actually i just need the size of the largest subset, so it doesn't need to have unique solution Edit : just to keep this simple, Given input : a set of points in 2D Desired output : maximum number of points that form a convex polygon, like in the example the output is 5 (ABHCD is one of the possible convex polygon) There's a similar problem spoj.com

Transparency with polygon command

主宰稳场 提交于 2019-12-03 01:41:46
I used the polygon command in R which created an area in the plot. However, the values in this area are not shown whereas the main aim is to monitor these values. Does anyone know how to handle this? You can use The function rgb() to specify a color with an alpha transparency. for example : xx <- c(1:50) yy <- rnorm(50) n <- 50 hline <- 0 plot (yy ~ xx, type="n", axes=FALSE, ann=FALSE) text(x=xx,y=min(yy)+max(yy),labels='a') polygon(c(xx[1], xx, xx[n]), c(min(yy), yy, min(yy)), col=rgb(1, 0, 0,0.5), border=NA) 来源: https://stackoverflow.com/questions/14099833/transparency-with-polygon-command

How to get list of points inside a polygon in python?

女生的网名这么多〃 提交于 2019-12-03 01:32:11
I searched a lot and cant find any practical answer to my question. I have a polygon. For example: [(86, 52), (85, 52), (81, 53), (80, 52), (79, 48), (81, 49), (86, 53), (85, 51), (82, 54), (84, 54), (83, 49), (81, 52), (80, 50), (81, 48), (85, 50), (86, 54), (85, 54), (80, 48), (79, 50), (85, 49), (80, 51), (85, 53), (82, 49), (83, 54), (82, 53), (84, 49), (79, 49)] I want to get a list of all the points inside this border polygon. I heard alot about polygon triangulation techniques or linear/flood/intersection/... filling algorithms. but i cant really come up with an efficient way of

Efficient extraction of all sub-polygons generated by self-intersecting features in a MultiPolygon

≡放荡痞女 提交于 2019-12-03 01:19:06
Starting from a shapefile containing a fairly large number (about 20000) of potentially partially-overlapping polygons, I'd need to extract all the sub-polygons originated by intersecting their different "boundaries". In practice, starting from some mock-up data: library(tibble) library(dplyr) library(sf) ncircles <- 9 rmax <- 120 x_limits <- c(-70,70) y_limits <- c(-30,30) set.seed(100) xy <- data.frame( id = paste0("id_", 1:ncircles), x = runif(ncircles, min(x_limits), max(x_limits)), y = runif(ncircles, min(y_limits), max(y_limits))) %>% as_tibble() polys <- st_as_sf(xy, coords = c(2,3)) %>

Point in polygon

南笙酒味 提交于 2019-12-02 21:57:40
问题 I'm trying to do some SPOJ problem it's https://www.spoj.pl/problems/FSHEEP/ We have to find out if point is inside the polygon. As we see it's not convex polygon ( image from problem ). I was trying to solve it in O(n*m) time with Ray Casting algorithm described on wikipedia or any other site. But how to solve it in O(n log m ) ? So in other words how to check if point is in polygon in logarithmic time ? Cheers 回答1: Since this is a homework-esque problem, I'll give you homework-esque help.

Check if geo-point is inside or outside of polygon

喜欢而已 提交于 2019-12-02 19:11:56
I am using python and I have defined the latitudes and longitudes (in degrees) of a polygon on the map. My goal is to check if a generic point P of coordinates x,y falls within such polygon. I would like therefore to have a function that allows me to check such condition and return True or False if the point is inside or outside the polygon. In this example the point is outside so the result would be False Question : Is there a library/package that allows to reach my goal? if yes which one do you recommend? would you be able to give a small example on how to use it? Here is the code I have

How to clip WorldMap with polygon in R?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 18:34:37
I have imported a world map dataset from www.GADM.org using the R package raster. I would like to clip it to a polygon I create to reduce the size of the map. I can retrieve the data and I can create the polygon no problem, but when I use the 'gIntersection' command I get an obscure error message. Any suggestions on how to clip my World Map dataset? library(raster) library(rgeos) ## Download Map of the World ## WorldMap <- getData('countries') ## Create the clipping polygon clip.extent <- as(extent(-20, 40, 30, 72), "SpatialPolygons") proj4string(clip.extent) <- CRS(proj4string(WorldMap)) ##