computational-geometry

Determining polygon intersection and containment

I have a set of simple (no holes, no self-intersections) polygons, and I need to check that they don't intersect each other (one can be entirely contained in another; that is okay). I can check this by simply checking the per-vertex inside-ness of one polygon versus other polygons. I also need to determine the containment tree, which is...

How can I test if a point lies within a 3d shape with its surface defined by a point cloud?

Hi I have a collection of points which describe the surface of a shape that should be roughly spherical, and I need a method with which to determine if any other given point lies within this shape. I've previously been approximating the shape as an exact sphere, but this has proven too inaccurate and I need a more accurate method. Simpl...

How to find a random point in a quadrangle?

Hi! I have to be able to set a random location for a waypoint for a flight sim. The maths challenge is straightforward: "To find a single random location within a quadrangle, where there's an equal chance of the point being at any location." Visually like this: An example ABCD quadrangle is: A:[21417.78 37105.97] B:[38197.32...

Largest triangle from a set of points

Possible Duplicate: How to find largest triangle in convex hull aside from brute force search I have a set of random points from which i want to find the largest triangle by area who's verticies are each on one of those points. So far I have figured out that the largest triangle's verticies will only lie on the outside points...

area of intersection of two triangles, or a set of halfplanes, or area of a convex point set

I need to compute the area of the region of overlap between two triangles in the 2D plane. Oddly, I have written up code for the triangle-circle problem, and that works quite well and robustly, but I have trouble with the triangle-triangle problem. I already first check to see if one entirely contains the other, or if the other contains...

How to compute the intersection points of a line and an arbitrary shape?

Is there a way to geometrically compute the intersection points of a line and an arbitrary graphics path? I know where all of the lines and curves are in the path, and I am using the HTML5 canvas element if that helps any. Basically, I have access to all of the canvas drawing commands and their arguments. For instance, if the API was c...

The minimum perimeter convex hull of a subset of a point set

Given n points on the plane. No 3 are collinear. Given the number k. Find the subset of k points, such that the convex hull of the k points has minimum perimeter out of any convex hull of a subset of k points. I can think of a naive method runs in O(n^k k log k). (Find the convex hull of every subset of size k and output the minimum)...

Dividing a plane of points into two equal halves

Given a 2 dimensional plane in which there are n points. I need to generate the equation of a line that divides the plane such that there are n/2 points on one side and n/2 points on the other. (by the way this not home work, I am just trying to solve the problem) ...

What is an efficient algorithm to copy pixels that are inside a quadrangle?

I have two bitmaps, and I want to copy pixels from A to B only when the pixels are inside an area defined by four corners (a quadrangle). Bitmap A and B are the same size and the quadrangle is defined as four {x,y} coordinates in the pixel space of the image. Worst case scenario I can test the center of each pixel against the quad to se...

What is the best way to efficiently calculate which points are close to a given lat/long using MySQL?

I'm trying to design a MySQL schema that can store a list of users with an associated latitude and longitude. I would then, for a given user, like to build a query which can return the nearest 50 users to him/her and sort those users by distance (with the nearest being presented first). Given that there may be many thousands of users ...

comparing original and simplified TINs

Hi, I have two TINs (triangulated irregular network) of a terrain. First one (TIN1) is the original one, let's say with X number of points. And the other (TIN2) is simplified (the number of points were reduced by some decimation algorithm) one where let's say it was build from Y points, where X>Y. Now, how could I do the following compar...

clockwise angle between two line

I want to calculate a clockwise angle between two line segment A and B. So the resulting angle must be between 0 to 360-1 degrees. I've seen all other answers in SO but they gave me negative angles. Thanks. ...

How to split a PathGeometry Polygon by an intersecting line segment

I've got a PathGeometry that I've built from a bunch of LineSegments, and I want to split it into two PathGeometries divided by a line intersecting down the middle of the geometry. Here's what I mean by this picture: http://i30.tinypic.com/2noyvm.png I can go through the LineSegments and create an array of simple line objects (simple ...

Is it possible to generalize a Voronoi diagram into a k-means cluster?

In a n-dimensional Euclidean metric space, given a Voronoi decomposition for a set of S points (computed with Bowyer-Watson algorithm), is it possible to generalize k (with k<S) geometric clusters by converging multiple Dirichlet domains? ...

Google Earth Determining zoom level from bounding box

Hi guys, I got a Windows Forms app making use of Google Earth where users can draw a polygon on the map which is used as a geofence. What I'd like to do is to be able to zoom to the polygon so that it fits nicely on screen with a click of a button. A sort of zoom to fit function. Finding the centre of the polygon and setting the Googl...

Polytope library for simulating billiards orbits

My current research project involves studying billiards orbits in four-dimensional polytopes. One sets into motion a point-mass, starting on one of the facets of the polytope, which follows a straight trajectory within the polytope except on collision with a wall, when it is subjected to an elastic response (i.e., its velocity vector is ...

Determine if a set of points lie on a regular grid

Problem: Suppose you have a collection of points in the 2D plane. I want to know if this set of points sits on a regular grid (if they are a subset of a 2D lattice). I would like some ideas on how to do this. For now, let's say I'm only interested in whether these points form an axis-aligned rectangular grid (that the underlying lattice...

Efficient Packing Algorithm for Irregular Polygons

I'm looking for a packing algorithm which will reduce an irregular polygon into rectangles and right triangles. The algorithm should attempt to use as few such shapes as possible and should be relatively easy to implement (given the difficulty of the challenge). It should also prefer rectangles over triangles where possible. If possibl...

What are the main/interesting problems in computational geometry? What are the introductory problems?

Hi, I'm interested in learning about computational geometry, but I'm not sure where to start. What are the interesting problems that are worked on currently? What are the "introductory problems"? Also, possible advise with respect to the field? Thanks! ...

CGAL half-edge data structure

Hello, I am trying to learn how to use half-edge data structures in CGAL, and I am confused by the following sample of code provided on their website #include <CGAL/HalfedgeDS_default.h> #include <CGAL/HalfedgeDS_decorator.h> struct Traits { typedef int Point_2; }; typedef CGAL_HALFEDGEDS_DEFAULT<Traits> HDS; typedef CGAL::HalfedgeDS...