polygon

in a wavefront object file (.obj) how am i supposed to render faces with more than 4 vertices in opengl?

空扰寡人 提交于 2019-11-30 04:22:25
问题 So using a Wavefront object file how am i supposed to render faces that have more than 4 vertices in OpenGL? I understand that if it has 3 vertices I use GL_TRIANGLES , if it has 4 I use GL_QUADS , but if it has 5 or more, what am I supposed to use? Is there a standard? 回答1: OBJ exporters will export the vertices in a sane order for each face (anti-/clockwise), and long as your faces are coplanar and convex (which they bloody should be!) - you can use GL_TRIANGLE_FAN. I disagree with Nicol

Check whether a point is inside of a simple polygon

旧城冷巷雨未停 提交于 2019-11-30 04:03:32
I'm trying to determine whether a point is located inside of a polygon or not. I use the following (for Swift modified) algorithm from this website : func contains(polygon: [Point], test: Point) -> Bool { let count = polygon.count var i: Int, j: Int var contains = false for (i = 0, j = count - 1; i < count; j = i++) { if ( ((polygon[i].y >= test.y) != (polygon[j].y >= test.y)) && (test.x <= (polygon[j].x - polygon[i].x) * (test.y - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x) ) { contains = !contains; } } return contains; } However, when having a simple polygon with the

OpenGL ES - How to Draw a filled Polygon?

自古美人都是妖i 提交于 2019-11-30 04:01:20
I tried googling and searching on stack but I didn't find anything :-( ( Mapping irregular shapes or other polygons (cartoons, sprites) to triangles in OpenGL ES ) I want to draw a filled polygon in OpenGL ES on iPad (2D, don't need 3D) (I'm new to OpenGL && OpenGL ES) It seems simple on OpenGL but with ES with just can draw triangle. But I can't find any good tutorial about this :-( Does it exist any wrapper / library or anything else that could help me ? I don't want to use CoreGraphics , it's too slow for what I'm doing ^^ And if possible, avoiding too (big) library like Cocos2D. Edit :

How can I tell if two polygons intersect?

大兔子大兔子 提交于 2019-11-30 03:43:50
问题 Imagine I have the coordinate of 4 points that form a polygon. These points are represented using PointF in C#. If I have 2 polygons (using 8 points), how can I tell if they intersect? Rectangle class has a method called IntersectsWith but I couldn't find something similar for GraphicsPath or Region. Any advice would be greatly appreciated. Mosh 回答1: As Charlie already pointed out you can use the Separating Axis theorem. Check out this article for a C# implementation and example of polygon

Convert a shapefile from polygons to points? [closed]

瘦欲@ 提交于 2019-11-29 23:27:24
问题 I have a non-overlapping polygon-based shapefile (.shp) with a large spatial extent and many dozens of associated attributes. The shapefile is projected in UTMs. I would like to convert the polygons to points spaced out in a 30-m resolution grid, in which each point would retain the attributes of the polygon it is located within. Output would simply be a table of the points: X, Y, attribute1, attribute2, attribute 3,etc... I would ideally like to do this operation in R, or (less ideally) some

Algorithm to merge adjacent rectangles into polygon

时光怂恿深爱的人放手 提交于 2019-11-29 23:12:40
I guess that my problem is related to "convex hull", but no the same. All shapes in the drawing are rectangles with same width and height. Many are adjacent to each other. I want to combine those adjacent rectangles into polygons. Unlike "convex hull", the resuled polygons could be "hollow" inside. Is there any open source algorithm available? I had to write an algorithm for merging adjacent polygons as part of an experiment project with HTML5 canvas (nothing glorious, a jigsaw puzzle :-) Holes in the resulting polygon are naturally supported. The Javascript routine is found in the function

Expand fill of convex polygon

一世执手 提交于 2019-11-29 22:36:15
I have a convex polygon P1 of N points. This polygon could be any shape or proportion (as long as it is still convex). I need to compute another polygon P2 using the original polygons geometry, but "expanded" by a given number of units. What might the algorithm be for expanding a convex polygon? Oren Trutner To expand a convex polygon, draw a line parallel to each edge and the given number of units away. Then use the intersection points of the new lines as the vertices of the expanded polygon. The javascript/canvas at the end follows this functional breakdown: Step 1: Figure out which side is

Locating Bounding 2D Entities

狂风中的少年 提交于 2019-11-29 22:02:47
问题 Given a point and a set of arbitrary 2D entities (circles, polygons, lines, polylines, arcs, etc.), does anyone know of existing strategies to: Determine if the point is enclosed (bounded) by any combination of entities? I know that it is easy enough to do an 'inside' test on the closed shapes, but this won't always give me what I want - particularly with nested or intersecting shapes. Find the smallest (closest?) set of lines / entities that form a closed polygon around my point? (think of a

Simplified (or smooth) polygons that contain the original detailed polygon

耗尽温柔 提交于 2019-11-29 21:02:59
I have a detailed 2D polygon (representing a geographic area) that is defined by a very large set of vertices. I'm looking for an algorithm that will simplify and smooth the polygon, (reducing the number of vertices) with the constraint that the area of the resulting polygon must contain all the vertices of the detailed polygon. For context, here's an example of the edge of one complex polygon: My research: I found the Ramer–Douglas–Peucker algorithm which will reduce the number of vertices - but the resulting polygon will not contain all of the original polygon's vertices. See this article

draw a smooth polygon around data points in a scatter plot, in matplotlib

偶尔善良 提交于 2019-11-29 20:38:40
问题 I have a bunch of cross plots with two sets of data and have been looking for a matploltib way of highlighting their plotted regions with smoothed polygon outlines. At the moment i just use Adobe Illustrator and amend saved plot, but this is not ideal. Example: I'd be grateful for any pointers/links to examples. Cheers 回答1: Here, you have an example. I was written the main ideas, but obviously, you could do it better. A short explanations: 1) You need to compute the convex-hull (http://en