polygon

OpenGL GL_POLYGON concave polygon doesn't color in

我是研究僧i 提交于 2019-12-17 21:31:07
问题 I have a problem when I try to use Polygon in OpenGL. I don't know how to explain this but all my vertices are connected with the beginning one. The problem happens when I try to color the object. I want to draw a simple object. void TOP (float x1, float y1, float x2, float h,float n) { float r = x2-x1; if(n==1){glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);} // FOR FILL OR NO FILL OBJECT glBegin(GL_POLYGON); glVertex2f(x1,y1); glVertex2f(x2,y1); glVertex2f(x2,y1+h/7); y1=y1+h/7; glVertex2f(x2-r

Finding euclidean distance in R{spatstat} between points, confined by an irregular polygon window

懵懂的女人 提交于 2019-12-17 20:25:57
问题 I'm trying to find the euclidean distance between two points, confined by an irregular polygon. (ie. the distance would have to be calculated as a route through the window given) Here is an reproducible example: library(spatstat) #Simple example of a polygon and points. ex.poly <- data.frame(x=c(0,5,5,2.5,0), y=c(0,0,5,2.5,5)) points <- data.frame(x=c(0.5, 2.5, 4.5), y=c(4,1,4)) bound <- owin(poly=data.frame(x=ex.poly$x, y=ex.poly$y)) test.ppp <- ppp(x=points$x, y=points$y, window=bound)

Extruding multiple polygons with multiple holes and texturing the combined shape

我的梦境 提交于 2019-12-17 19:53:42
问题 This question is related to this question. The answer shows very nice way to extrude polygons that have holes (see the excellent live example). The main learning of the answer was that paths in three.js (r58) cannot have more than one moveTo command and it have to be in the start of the path, which means that path have to be broken by moveTos, so that moveTo start always a new path. Extruding in three.js means that 2D paths are converted to 3D shapes using possible beveling. It is suitable

shapefile and matplotlib: plot polygon collection of shapefile coordinates

拥有回忆 提交于 2019-12-17 18:34:05
问题 I'm trying to plot filled polygons of countries on the world map with matplotlib in python. I've got a shapefile with country boundary coordinates of every country. Now, I want to convert these coordinates (for each country) into a polygon with matplotlib. Without using Basemap. Unfortunately, the parts are crossing or overlapping. Is there a workarund, maybe using the distance from point to point.. or reordering them ? 回答1: Ha! I found out, how.. I completely neglected, the sf.shapes[i]

how to order vertices in a non-convex polygon (how to find one of many solutions)

早过忘川 提交于 2019-12-17 18:22:01
问题 I have the same problem as here: how to order vertices in a simple, non-convex polygon but there is no solutions I can use. I have coordinates of points and need to find some polygon. Does not matter that there is more solutions for one list of dots. I need some algorithm to find one of them. Does not matter which one. I really don't know how to solve this. (I have stored coordinates in array and I want to use some algorithm in Javascript) Thanks a lot. 回答1: First, find the center of the

Polygons nicely cropping ggplot2/ggmap at different zoom levels

不羁的心 提交于 2019-12-17 17:45:14
问题 I am playing with a spatial data set (mostly polygons over an area of a city) and I would like to produce different views, based on different levels of zoom. Everything is fine when I have the plot boundary box larger than the area that contains the polygons. But on a zoom in, some polygons get parts that are outside the boundary box and the output for those polygons is problematic : the points of the polygon outside the boundary box are not displayed, resulting in polygons that are not

Use of GL_STENCIL_TEST to render concave polygons

余生长醉 提交于 2019-12-17 16:53:30
问题 I'm working on a custom geometry library adapted to Quartz Composer and trying to draw some concave polygons in a Plug In. I implemented the poly2tri library, so the user can choose to triangulate or not, but it's not suitable for a per-frame polygon transformations rendering. I'm a noob in OpenGL and I've been reading and testing a lot, about stencil buffer and odd/even operations, but even code that seem to work for other people, doesn't work for me. The render context is a CGLContextObj,

How can I create an internal spiral for a polygon?

大兔子大兔子 提交于 2019-12-17 16:49:22
问题 For any shape how can I create a spiral inside it of a similar shape. This would be a similar idea to bounding (using Minkowski sum). Rather than creating the same shape inside the shape though it would be a spiral of same shape. I found this - http://www.cis.upenn.edu/~cis110/13su/lectures/Spiral.java It creates a spiral based on the parameters passed so it can be for any regular shape. I want the above for all shapes i.e. irregular polygons too. I am not hugely familiar with geometric

Circle and Polygon Collision with Libgdx

你离开我真会死。 提交于 2019-12-17 15:58:26
问题 Is there a way in Libgdx to verify a collision between a Polygon and a Circle? I saw the Intersector class but only found collision test for Circle and Rectangle. What about any other Polygon? If I need to do it manually, what's the best way to do that using Libgdx? 回答1: So, I managed to create a collision test method between a Circle and a Polygon. At least, it works for me. Here's the code: public boolean overlaps(Polygon polygon, Circle circle) { float []vertices=polygon

How can I split a Polygon by a Line?

我的未来我决定 提交于 2019-12-17 15:44:08
问题 As shown below, Is it possible to split a Polygon by a Line? (into two Polygons). If the line doesn't go all the way across the polygon it would fail. Is this possible? If so, how would I do this? 回答1: I had to do this recently. Just walking the polygon won't work for concave polygons, as in your diagram. Below is a sketch of my algorithm, inspired by the Greiner-Hormann polygon clipping algorithm. Splitting is both easier and harder than polygon clipping. Easier because you only clip against