geometry

Finding shared vertices among polygons

I have an interesting problem coming up soon and I've started to think about the algorithm. The more I think about it, the more I get frightened because I think it's going to scale horribly (O(n^4)), unless I can get smart. I'm having trouble getting smart about this one. Here's a simplified description of the problem. I have N polyg...

Nearest neighbor on a unit sphere, with roughly evenly distributed points.

I'm writing a program that implements SCVT (Spherical Centroidal Voronoi Tesselation). I start with a set of points distributed over the unit sphere (I have an option for random points or an equal-area spiral). There will be from a several hundred to maybe 64K points. I then need to produce probably several million random sample point...

How does Silverlight Image Clipping work?

I've got a very large image which I'd like to use for sprite techniques (à la css image sprites). I've got the code below: <Image x:Name="testImage" Width="24" Height="12" Source="../Resources/Images/sprites.png"> <Image.Clip> <RectangleGeometry Rect="258,10632,24,12" /> </Image.Clip> </Image> This clips the source...

How can I display borders for geometries with UMN-Mapserver only when zoomed in a lot?

I have a map-file for UMN, that displays a layer of vectors, each geometry with different colors depending on their attributes. That works fine. I also want to add borders around each geometry. That's no problem, but on the view showing the complete area, the borders dominate the image, because each geometry has only a few pixels. So I w...

How do I determine if two convex polygons intersect?

Suppose there are a number of convex polygons on a plane, perhaps a map. These polygons can bump up against each other and share an edge, but cannot overlap. To test if two polygons P and Q overlap, first I can test each edge in P to see if it intersects with any of the edges in Q. If an intersection is found, I declare that P and Q...

What is the best way to convert between a Media.Matrix to a Drawing2D.Matrix

I have the need to convert from the WPF Media.Matrix to the Windows Forms Drawing2D.Matrix and so I did the following: public static System.Drawing.Drawing2D.Matrix ConvertToDrawing2DMatrix( Matrix matrix) { return new System.Drawing.Drawing2D.Matrix((float)matrix.M11, (float)mat...

Is a closed polygonal mesh flipped?

I have a 3d modeling application. Right now I'm drawing the meshes double-sided, but I'd like to switch to single sided when the object is closed. If the polygonal mesh is closed (no boundary edges/completely periodic), it seems like I should always be able to determine if the object is currently flipped, and automatically correct. Be...

CGAL: Transformation Matrix for Rotation given two lines/vectors/directions

How do I generate a transformation matrix for rotating points/others by the angle between two lines/vectors/directions in CGAL? 2D is what I need. 3D is what I love. ...

Efficiency/speed for trigonometric functions

In a game I'm making, I've got two points, pt1 and pt2, and I want to work out the angle between them. I've already worked out the distance, in an earlier calculation. The obvious way would be to arctan the horizontal distance over the vertical distance (tan(theta) = opp/adj). I'm wondering though, as I've already calculated the distanc...

Fastest way to find minimum distance between points

I have a set of 2D points and need to find the fastest way to figure out which pair of points has the shortest distance in the set. What is the optimal way to do this? My approach is to sort them with quicksort and then calculate the distances. This would be O(nlogn + n) = O(nlogn). Is it possible to do it in linear time? Thanks. ...

GML usage criteria, or what is the proper way for useing GML (Geography XML)

We want to use GML in our application; It is a GIS based application which simulates the real word objects (i.e. Pipes, Roads, etc) in a virtual reality environment. Currently we draw and store the geometry in AutoCAD DWGs but in future we want to change the Database. I really need to find the answers of these questions. 1- Is GML prope...

Inverse Bilinear Interpolation?

I have four 2d points, p0 = (x0,y0), p1 = (x1,y1), etc. that form a quadrilateral. In my case, the quad is not rectangular, but it should at least be convex. p2 --- p3 | | t | p | | | p0 --- p1 s I'm using bilinear interpolation. S and T are within [0..1] and the interpolated point is given by: bilerp(s,t)...

Load points from SQL Server Multipoint data type into table

I'm kicking around the idea of using the new geometry datatype to represent a vector in the database. The multipoint geometry data type would work well for this, but my question is, is there a way to populate a two column table with the x,y values in a multipoint, where each point is a row in the table, and the X and Y point values go i...

Polygon enclosing a set of points

Hello folks, I have a set S of points (2D : defined by x and y) and I want to find P, the smallest (meaning : with the smallest number of points) polygon enclosing all the points of the set, P being an ordered subset of S. Are there any known algorithms to compute this? (my lack of culture in this domain is astonishing...) Thanks for ...

There are spatial data features for MS Sql Server 2005?

I wonder if there is any optimization I can do to achieve faster SELECTs for spatial data without moving to SQL SERVER 2008. There is for SQL Server 2005, natively or through plugins, any of the features below? Spatial field types Spatial indexes Arcsin math function for surface distance calculation on a sphere (Earth) ...

Line intersection

How to find whether a line intercepted in a polygon ...

What are good books for Computation Geometry?

I am familiar with O'Rourke's Computational Geometry in C, but it feels a little dated. Any recommendations for books, preferably with source code? ...

finding the outside of a geometric graph

I have a map of polygons, for example: (sorry the image isn't so great, I'll try and get better one later) The green lines are the shortest path from between the connected shapes. What I need to do is find the green lines that form the outer edge and which direction I need to traverse them in to circle CCW. The polygons will alway...

Polyline offset with closed polygon and islands

I have unsorted set of line segments without any binding to each other. Each line described with 2 points (x,y). I can search for lines with the same points, which means they should be connected. Every line have a thickness attribute. I need to offset each path by this thickness, and create 4 points describing the final plygon (for eac...

Shortest distance between a point and a line segment

I need a basic function to find the shortest distance between a point and a line segment. Feel free to write the solution in any language you want; I can translate it into what I'm using (Javascript). EDIT: My line segment is defined by two endpoints. So my line segment AB is defined by the two points A (x1,y1) and B (x2,y2). I'm try...