computational-geometry

Mesh Grid Simplification

I have a few 1000s triangles connected in a 2D mesh grid. It represents water flow. This grid is a delaunay triangulation. I need to merge the triangles back into a minimal amount of simple polygons such that each polygon is constraint not to have interior holes. The output polygons should be the same shape. Is there a known algorithm f...

Find the biggest rectangular area consisting only of 2 types of letter in a given MxN board.

Possible duplicate: http://stackoverflow.com/questions/2301733 I need help with a problem. Given a MxN board represented with M letters (a-z) in each of the N lines, i have to find the biggest area in which there are only 2 types of letters in it. The area must have rectangular shape. Here's an example : 4x4: AAAA ABBC BBCA DCAA ...

Fastest way to get the set of convex polygons formed by Voronoi line segments

I used Fortune's Algorithm to find the Voronoi diagram of a set of points. What I get back is a list of line segments, but I need to know which segments form closed polygons, and put them together in an object hashed by the original point they surround. What might be the fastest way to find these?? Should I save some crucial informatio...

Get the Area of a 3D surface

I have a 3D surface, (think about the xy plane). The plane can be slanted. (think about a slope road). Given a list of 3D coordinates that define the surface( Point3D1, Point3D2, Point3D3, and so on), how to calculate the area of the surface? Note that my question here is analogous to finding area in 2D plane. In 2D plane we have a l...

Compute the Centroid of a 3D Planar Polygon

This is a similar question to this one here. Given a list of 3D coordinates that define the surface( Point3D1, Point3D2, Point3D3, and so on), how to calculate the centroid of the surface? In 2D the computation is given by the following formula: What about the 3D analogue? ...

How do I find the k-nearest values in n-dimensional space?

I read about kd-trees but they are inefficient when the dimensionality of the space is high. I have a database of value and I want to find the values that are within a certain hamming distance of the query. For instance, the database is a list of 32-bit numbers and I want to find all numbers that differ from the query value by less tha...

Polygon packing 2D

Hi! I have problem of packing 2 arbitrary polygons. I.e. we have 2 arbitrary polygons. We are to find such placement of this polygons (we could make rotations and movements), when rectangle, which circumscribes this polygons has minimal area. I know, that this is a NP-complete problem. I want to choose an efficient algorithm for solvin...

Detecting the axis of rotation from a pointcloud

I'm trying to auto-detect the axis of rotation on a 3d pointcloud. In other words, if I took a small 3d pointcloud, chose a single axis of rotation, and make several copies of the points at different rotation angles, then I get a larger pointcloud. The input to my algorithm is the larger pointcloud, and the desired output is the sing...

Nesting maximum amount of shapes on a surface

In industry, there is often a problem where you need to calculate the most efficient use of material, be it fabric, wood, metal etc. So the starting point is X amount of shapes of given dimensions, made out of polygons and/or curved lines, and target is another polygon of given dimensions. I assume many of the current CAM suites implem...

When can a freely moving sphere escape from a ‘cage’ defined by a set of impassible coordinates?

Hopefully there are some computational geometry folks here who can help me out with the following problem - Please imagine that I take a freely moving ball in 3-space and create a 'cage' around it by defining a set of impassible coordinates, Sc (i.e. points in 3-space that no part of the diffusing ball is allowed to overlap). These poi...

Coordinate geometry operations in images/discrete space

I have images which have line segments, rays etc. I am representing these line segments using Bresenham algorithm (means whatever coordinates I get using this algorithm between two points). Now I want to do operations such as finding intersection point between two line segments, finding the projection of one vector onto other etc... The...

Points, Lines, and Polygons on Spheres with C/C++

My application is to represent shapes on the Earth's (using a sphere is sufficient) surface. Those can be points, lines, and polygons. Coordinates should be defined by using degrees or radians (just like geographic coordinates). A (straight) line for example should be defined by two coordinates and use the great circle (http://en.wiki...

Merging and splitting overlapping rectangles to produce non-overlapping ones

I am looking for an algorithm as follows: Given a set of possibly overlapping rectangles (All of which are "not rotated", can be uniformly represented as (left,top,right,bottom) tuplets, etc...), it returns a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area. It seems simple enough at first glance, but ...

How do I determine when two moving points become visible to each other?

Suppose I have two points, Point1 and Point2. At any given time, these points may be at different positions-- they are not necessarily static. Point1 is located at some position at time t, and its position is defined by the continuous functions x1(t) and y1(t) giving the x and y coordinates at time t. These functions are not differenti...

Draw a parallel line

I have x1,y1 and x2,y2 which forms a line segment. How can I get another line x3,y3 - x4,y4 which is parallel to the first line as in the picture. I can simply add n to x1 and x2 to get a parallel line but it is not what i wanted. I want the lines to be as parallel in the picture. ...

An implementation of Sharir's or Aurenhammer's deterministic algorithm for calculating the intersection/union of 'N' circles

The problem of finding the intersection/union of 'N' discs/circles on a flat plane was first proposed by M. I. Shamos in his 1978 thesis: Shamos, M. I. “Computational Geometry” Ph.D. thesis, Yale Univ., New Haven, CT 1978. Since then, in 1985, Micha Sharir presented an O(n log2n) time and O(n) space deterministic algorithm for the disc...

Ray-triangle intersetion

Hello! How can I test intersesion ray and triangle, and if it exist how to get distance from ray origin to intersection point?? What optimization I can use, if in my program I've got to check 1 ray to ~10000 triangles ?? ...

Directional Map Search

Hello, I am trying so write a bit of code that will search for a given point on a map, but in a given arc of a compass bearing. e.g. 45 degress (north-east), 20 degrees either side. So far I have got a SQL command that will give me the results in a given radius, need some help on how to filter it to a direction. SELECT * FROM (SELECT ...

Polygon Chain - Conversion to non-crossing while preserving shape?

I have polygon chains similar to the following... ...given the chain in the image, how would I go about calculating a chain that defines the same shape but without crossing paths? Specifically, in the case of the image's input chain, the result I want looks like this: A1, A2, Intersect between A2 and A3, Intersect between A3 and A4,...

Fast way to compute the minimal distance of two sets of k-dimensional vectors

I two sets of k-dimensional vectors, where k is around 500 and the number of vectors is usually smaller. I want to compute the (arbitrarily defined) minimal distance between the two sets. A naive approach would be this: (loop for a in set1 for b in set2 minimizing (distance a b)) However, this requires O(n² * distance) com...