polygon

Converting SVG paths with holes to extruded shapes in three.js

流过昼夜 提交于 2019-12-05 11:06:00
I have a shape that consists of 4 polygons: 2 non-holes and 2 holes. This is only an example. In reality there can be a shape that consists of 50 polygons, of which 20 are non-holes and 30 are holes. In SVG path this like polygon can be represented easily by combining moveto:s and lineto:s. Every sub-polygon (hole or non-hole) in path string starts with moveto-command and ends with z (end) command and non-holes have winding order CW and holes CCW. Very easy and intuitive. The shape in SVG is represented this way ( http://jsbin.com/osoxev/1/edit ): <path d="M305.08,241.97 L306,251.51 L308.18

Closest points of two polygons

家住魔仙堡 提交于 2019-12-05 09:29:31
I have two polygons and I want to get the minimal distance and the points between this distance is measured. Of course such a point could very well lie on the edge between two nodes. Here is an example: I am looking for an algorithm that gives me the green distance and the two points. If the polygons do not intersect, you could do this: If you have polygon A and polygon B and A[i] and B[j] are the vertexes of A and B respectively. Then you could compute the closest distance from A[i] to each segment of B (you could use something like this , but take into account that you'd be working with

How did google get the outline for postcodes on maps?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:23:49
For example: http://g.co/maps/2dpkj has the outline around the postcode area. I understand this is unavailable through the API , but where else can I get this data, eg in a KML format. This is for UK Data Most likely Google have a licensing agreement with Ordnance Survey that allows them to use the Code Points with Polygons data - I imagine they've then done some processing of the data to generate a KML file. Depending on your GIS skills and your ability to read the source file (ESRI/MapInfo), you should be able to do the same. An alternative is to use the Code Point dataset, which has the

How could I simplify a complex polygon?

爷,独闯天下 提交于 2019-12-05 06:49:02
Recently I've been thinking about how to transform a complex polygon into a non-complex polygon. How is this done? This is the sort of thing I want to do: I'm going to end up with JavaScript when I'm done, but any form of a solution is fine (language, algorithm, or just plain English). I would use the same heuristic that I would use when drawing the polygon by hand (which is probably not the most mathematically efficient way to caluclaute that polygon, but probably the easiest to understand/implement). Start at a point Find all the intersections between my current point and the point I'm

Arrange points in sequence

偶尔善良 提交于 2019-12-05 06:41:38
问题 I have some points in 3D which are in a single plane. I want to arrange them in clock wise or counter clockwise order. The points can create a concave or convex polygon in a single plane. Can any body give any suggestions? 回答1: Find the center of all the points, then calculate all the angles from the center to each point. Then sort by angle. 回答2: Ok, I nearly solve the problem. I got line segment instead of having points in 3d. So, Now I have to arrange line segment in sequence. Which becomes

Algorithm creating polygon of n corners inside a square (HTML5 - Canvas)?

穿精又带淫゛_ 提交于 2019-12-05 05:16:41
问题 Consider the following setup : CSS : div { position :absolute; top: 50px; left: 50px; height: 200px; width: 200px; border: 2px solid black; } HTML : <div id="container"> <canvas id="my-canvas"/> </div> Now inside #my-canvas I want to be able to draw a polygon with any number of corners that always sits on one of its sides (and not one of its corners). The height and width that the polygon will "take up" should always be equal to that of its parent (in this case 200px X 200px) which we will

Footprint finding algorithm

耗尽温柔 提交于 2019-12-05 04:40:23
I'm trying to come up with an algorithm to optimize the shape of a polygon (or multiple polygons) to maximize the value contained within that shape. I have data with 3 columns: X: the location on the x axis Y: the location on the y axis Value: Value of the block which can have positive and negative values. This data is from a regular grid so the spacing between each x and y value is consistent. I want to create a bounding polygon that maximizes the contained value with the added condition. There needs to be a minimum radius maintained at all points of the polygon. This means that we will

identify which is the polygon from latitude and longitude

百般思念 提交于 2019-12-05 04:30:06
I have a map drawn using leaflet.js. If I give longitude and latitude value as input Can I identify the polygon? Can I get a client side script for this? Got an answer as follows : //This is based on 'point in polygon algorithm' function getPoint () { float x=-89.82421875; //x and y represents the lat and lng values float y= 40.18307014852533; var a = boundaries; //the coordinates used to draw the map for (i = 0; i < a.features.length; i++) { PointInPolygon(x,y, a.features[i].geometry.coordinates[0], i); } }; function PointInPolygon(pointX, pointY, _vertices, number) { var j = _vertices.length

How can I create a filled polygon from unordered edge data in MATLAB?

家住魔仙堡 提交于 2019-12-05 03:25:22
I want to create a polygon using edge data (X,Y coordinates of each point of edge) that is unordered , and I want to fill that polygon with some color. Any suggestions how I can accomplish this? If your polygon is convex , you can just compute the convex hull from the vertices using the function CONVHULL and plot the polygon using the plotting function PATCH . For example: x = [0 1 0 1]; %# Unordered x coordinates of vertices y = [0 1 1 0]; %# Corresponding y coordinates of vertices hullIndices = convhull(x,y); %# Gives vertex indices running counterclockwise %# around the hull patch(x

Change colour scheme for ggplot geom_polygon in R

这一生的挚爱 提交于 2019-12-05 02:53:49
I'm creating a map using the maps library and ggplot's geom_polygon. I'd simply like to change the default blue, red, purple colour scheme to something else. I'm extremely new to ggplot so please forgive if I'm just not using the right data types. Here's what the data I'm using looks like: > head(m) region long lat group order subregion Group.1 debt.to.income.ratio.mean ratio total 17 alabama -87.46201 30.38968 1 1 <NA> alabama 12.4059 20.51282 39 18 alabama -87.48493 30.37249 1 2 <NA> alabama 12.4059 20.51282 39 19 alabama -87.52503 30.37249 1 3 <NA> alabama 12.4059 20.51282 39 20 alabama -87