polygon

Greiner-Hormann clipping with degeneracies

折月煮酒 提交于 2019-12-22 01:19:38
问题 I'm trying to understand the paper "Clipping of Arbitrary Polygons with Degeneracies" by E. L Foster and J. R. Overfelt [1], which claims to extend the classic Greiner-Hormann polygon clipping algorithm by handling of degeneracies. However, I ran into some difficulties with the procedure they describe. Consider the situation depicted on Figure 6(c) and suppose the polygons are oriented in the same way. Start the labeling phase from the I5 (as opposed from I1, as they do): for both subject

How to draw an arbitrary irregular polygon with n sides?

北战南征 提交于 2019-12-22 01:17:20
问题 I am trying to find an algorithm of how to draw a simple (no lines are allowed to intersect), irregular polygon. The number of sides should be defined by the user, n>3 . Here is an intial code which only draws a complex polygon (lines intersect): var ctx = document.getElementById('drawpolygon').getContext('2d'); var sides = 10; ctx.fillStyle = '#f00'; ctx.beginPath(); ctx.moveTo(0, 0); for(var i=0;i<sides;i++) { var x = getRandomInt(0, 100); var y = getRandomInt(0, 100); ctx.lineTo(x, y); }

fast calculation of the intersection area of a triangle and the unit square

点点圈 提交于 2019-12-21 20:15:00
问题 In my current project I need to calculate the intersection area of triangles and the unit squares in an infinite grid. For every triangle (given by three pairs of floating point numbers) I need to know the area (in the interval (0,1] ) it has in common with every square it intersects. Right now I convert both (the triangle and the square) to polygons and use Sutherland-Hodgman polygon clipping to calculate the intersection polygon, which I then use to calculate its area. This approach now

fast calculation of the intersection area of a triangle and the unit square

我只是一个虾纸丫 提交于 2019-12-21 20:14:47
问题 In my current project I need to calculate the intersection area of triangles and the unit squares in an infinite grid. For every triangle (given by three pairs of floating point numbers) I need to know the area (in the interval (0,1] ) it has in common with every square it intersects. Right now I convert both (the triangle and the square) to polygons and use Sutherland-Hodgman polygon clipping to calculate the intersection polygon, which I then use to calculate its area. This approach now

Calculate time when a moving ball collides with a moving line/polygon (2D)

笑着哭i 提交于 2019-12-21 17:10:32
问题 I have a polygon and inside of it is a moving ball. The ball should bounce back if it hits a border. My current 'solution': I split the polygon in lines and calculate when the ball hits the moving line all variables: a = length of a b = length of b c = length of c ax = x position of A ay = y position of A bx = x position of B by = y position of B cx = x position of C cy = y position of C vax = speed of A on the x-axis vay = speed of A on the y-axis vbx = speed of B on the x-axis vby = speed

identify zip codes that fall within latitude and longitudinal coordinates

≡放荡痞女 提交于 2019-12-21 06:10:32
问题 I have several data frames in R. The first data frame contains the computed convex hull of a set of lat and long coordinates by market (courtesy of chull in R). It looks like this: MyGeo<- "Part of Chicago & Wisconsin" Longitude <- c(-90.31914, -90.61911, -89.37842, -88.0988, -87.44875) Latitude <- c(38.45781, 38.80097, 43.07961, 43.0624,41.49182) dat <- data.frame(Longitude, Latitude, MyGeo) The second has zip codes by their latitude and longitudinal coordinates (courtesy of the US census

Best Algorithm to find the edges (polygon) of vertices

半世苍凉 提交于 2019-12-21 05:11:19
问题 I have a large array of vertices, some of them are edges, some are redundant (inside the shape) and I want to remove those. The simplest algorithm I could think of is checking one by one if they hit the shape formed by the others. But it should be a very slow algorithm. I thought about picking one from the edge (the one farthest from origin per example) and calculate the longest path from this start... should get the edge path, right? Any suggestion? 回答1: The trick with polyhedral algorithms

How to correct Polygon Ring Orientation using C# Entity Framework 5 DbGeography Spatial Data

佐手、 提交于 2019-12-21 04:39:09
问题 I'm working with the new Entity-Framework 5 using the Spatial data type DbGeography as part of my model for storing in one instance, a POINT and in another instance a POLYGON. When setting the value of my POLYGON all saves with no error however this is only the case if I draw the Polygon on the map in a clockwise order. If I draw the POLGON in an anti-clockwise direction I get an error the the sql level indicating that the data is an invalid geography type. Now after doing my own research

Drawing outlines around multiple geom_point groups with ggplot

Deadly 提交于 2019-12-21 03:36:30
问题 I currrently have the code included below to draw this: What I am trying to do is get the outline for each of the groups to follow all of the points in each group - rather than skip some of them as it currently does. In addition I would want each outline to have a semi-transparent fill. Thanks for any help. library(ggplot2) library(reshape) library(car) G1 <- 1:10 G2 <- 11:20 G3 <- 21:30 G4 <- 31:35 G5 <- 36:41 sdata <- read.csv("http://dl.dropbox.com/u/58164604/sdata.csv", stringsAsFactors =

How to compute the union polygon of two (or more) rectangles

时光毁灭记忆、已成空白 提交于 2019-12-21 02:20:24
问题 For example we have two rectangles and they overlap. I want to get the exact range of the union of them. What is a good way to compute this? These are the two overlapping rectangles. Suppose the cords of vertices are all known: How can I compute the cords of the vertices of their union polygon? And what if I have more than two rectangles? 回答1: There exists a Line Sweep Algorithm to calculate area of union of n rectangles. Refer the link for details of the algorithm. As said in article, there