polygon

How could I simplify a complex polygon?

妖精的绣舞 提交于 2019-12-07 03:01:07
问题 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). 回答1: 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

Drawing a concave polygon in OpenGL

二次信任 提交于 2019-12-07 01:51:52
问题 I have a concave polygon I need to draw in OpenGL. The polygon is defined as a list of points which form its exterior ring, and a list of lists-of-points that define its interior rings (exclusion zones). I can already deal with the exclusion zones, so a solution for how to draw a polygon without interior rings will be good too. A solution with Boost.Geometry will be good, as I already use it heavily in my application. I need this to work on the iPhone, namely OpenGL ES (the older version with

Fill Octagon in C#

南楼画角 提交于 2019-12-07 01:12:28
I have created a method that draws an octagon, and it works well, as long as the size is 200 or higher public static void FillOctagon(PaintEventArgs e, Color color, int x, int y, int width, int height) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; var points = new [] { new Point(((x + width) / 2) - (width / 4), y), //side 1 new Point(x, ((y + height) / 2) - (height / 4)), //side 2 new Point(x, ((y + height) / 2) + (height / 4)), //side 3 new Point(((x + width) / 2) - (width / 4), y + height), //side 4 new Point((x + width) - (width / 4), y + height), //side 5 new Point(x + width, ((y +

save google map polygon to postgreSQL database

天涯浪子 提交于 2019-12-07 00:51:43
I develop a web-based application where a user will create a polygon on a map and the database will return points of interest. The problem is that the postgreSQL saves the polygon in a different way than google map polygon. So how I can save the user polygon to postgis? I already use google maps v3 api and geojson Some code would be useful. In the absence of that here's a best guess generic answer: In general terms you will need to work out how to map (convert) each format to the other. Then you can convert to the format suitable for the database before you save and convert from database

Sorting vertices of a polygon in CCW or CW direction

倖福魔咒の 提交于 2019-12-07 00:34:27
I really need some urgent help with this problem. I have a set of edges and vertices defining a polygon (not necessarily convex). The vertices and edges are in random order and I want to sort/order the vertices of this polygon in clockwise (or anti-clock wise) direction. please see this page for more detailed description: http://www.dixittech.com/blog/2012/10/28/sorting-vertices-of-a-polygon-in-ccw-or-cw-direction/ Any idea how this can be achieved? I think this is a simplified version of Königsberg Bridge Problem essentially. if there's no any case that more than two edges are connected at a

Algorithm to make a polygon from transparent png sprite

有些话、适合烂在心里 提交于 2019-12-06 22:54:39
Say, I have a sprite of a game object which is a png image with transparency. I want to create a polygon from this image which will contain my game object. I am pretty sure there is an existing algorithm for it, but I haven't found any. I expect something like: public static Polygon getPolygon(BufferedImage sprite) { // get coordinates of all points for polygon return polygon; } See this question . It will be slow, but it depends on how accurate you want it (second answer is sloppier, but a bit faster). After you get the Area from getOutline() on the other question, try using this code

Find Parallel or Offset SVG path

此生再无相见时 提交于 2019-12-06 16:37:19
I need a parallel SVG path. I have path as 'M0 0 H50 A20 20 0 1 0 100 50 v25 C50 125 0 85 0 85 z'. Let Offset be 2px. Original Path O/P: Path Image Path Segments when further divided: 0: ["M", 0, 0] 1: ["H", 50] 2: ["A", 20, 20, 0, 1, 0, 100, 50] 3: ["V", 75] 4: ["C", 50, 125, 0, 85, 0, 85] Any algorithm or way to find the offset path for individual segments or on whole?? Updated Image: Red lines represent the offset SVG image, I need to get. Example Offset SVG Path Algorithmic solution Offsetting lines is relatively trivial. For arcs, it is solvable by changing both radii by the same value.

Algorithm for translating list of wallsections into coherent polygon

梦想的初衷 提交于 2019-12-06 16:09:00
问题 I have a list of points that in pairs describe a polygon, like this: <0,0><0,1><0,1><1,0><1,0><1,1><1,1><0,0> which is a square. Note that each pair of points describes a line so our square is made up out of the lines <<0,0><0,1>><<0,1><1,0>><<1,0><1,1>><<1,1><0,0>> I do however have to draw these polygons which works fine when the points in question are all properly in order and there are no holes. Unfortunatly this sometimes goes wrong when the input is like <0,0><0,1><1,1><0,0><0,1><1,0><1

White Pixels With GL_POLYGON_SMOOTH

岁酱吖の 提交于 2019-12-06 16:01:42
I had a problem where white pixels appeared randomly (sort of) on objects in OpenGL. This is an example of what was going on. While searching Stack Overflow for other people who may have had this problem, I found that GL_POLYGON_SMOOTH wasn't worth enabling. I disabled it, and the spots disappeared (this was lucky of me). This was very lucky, but I still don't understand why enabling GL_POLYGON_SMOOTH creates these artifact-thingies. Can someone explain why they appear? Also note I had glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) going on. GL_POLYGON_SMOOTH is selective anti-aliasing, as

Draw a rectangle arround a polygon when given in certain angle

懵懂的女人 提交于 2019-12-06 15:58:01
问题 Using Google Maps V3 API How can I draw a rectangle (It wouldn't exactly be a google map rectangle anymore but a rectangular polygon) around a polygon. Important however is that the rectangle has be rotated around a certain given angle. I do not mean to calculate the min and max of the coord of the polygon first to draw a rectangle and rotate it afterwards; This image may be a better description from what I am trying to accomplish. What I am trying to accomplish is to get the bounding