English 中文(简体)
Creating a surface of triangles from a set of 2D points
原标题:
  • 时间:2009-11-18 16:40:39
  •  标签:
  • set
  • geometry

I have a set of points and I need to convert the set to (non-overlapping) triangles (or a big polygon if equivalent)...

The application: I have a list of locations (latitude,longitude) from a country, and I need to find if a given point is inside the counrty or not...

X         X                   *---------*                       *---------*
                              |      / |                      |           
                              |    /   |                      |             
     X         x      =>      |    *    |    *      = or =>     |              *
                              |   /    |   /                   |             /
                              | /      | /                     |           /
X         X                   *---------*                       *---------*

Is there an easy way or do I need a PhD to code it?

Or with a huge polygon? I found http://en.wikipedia.org/wiki/Point_in_polygon

Thx, JD

问题回答

It would actually be easier to calculate the final polygon than constructing the polygon from triangles.

What you re looking for is the convex hull of a set of points. Many different algorithms exist to do this.

In my algorithms class, we studied the gift-wrapping algorithm (a.k.a.: The Jarvis March). It s fairly simple, but faster solutions exist.

If you want to construct the full polygon mesh, you would have to run a triangulation algorithm such as the Delaunay triangulation.

Your question text and question title point us in rather different directions. Do you want to figure out:

  • a triangulation from a set of points (Google for Delauny triangulation); or

  • the polygon which encloses your set of points (convex hull) or

  • whether a given lat,long pair is inside a country or not (point in polygon -- but this means that you have to have a polygonal representation of your country, and I guarantee that for some countries it won t be a nice convex polygon).

No, you shouldn t need a PhD to code this, they re all fairly well-documented problems in computational geometry. You ll be able to find open source software for all of the above. Your biggest problem is likely to be finding a polygonal representation of every country you are interested in.

Use Delaunay triangulation or other .

There s a library named qhull (http://www.qhull.org/) for doing this kind of job. It s solid enough to use in Blender, OGRE3D, and other apps that get serious use, and has APIs for more then just C/C++. It can even be used on the command line with simple text files of data for manual experimentation.

No need for a PhD, just a license to install 8D

There are others, but mostly of use to researchers or for special applications.





相关问题
Bounding ellipse

I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn t have to be axis aligned. This ...

Line segment in a triangle

How can we check if a line segment falls partially or fully inside a triangle? Cheers.

Line Segments from a point

I have a point p, and 2 line segments in a 2D plane. Point p is a location of view from where camera is looking towards the line segments. I want to check if line segment 1 is partially or fully ...

Creating a surface of triangles from a set of 2D points

I have a set of points and I need to convert the set to (non-overlapping) triangles (or a big polygon if equivalent)... The application: I have a list of locations (latitude,longitude) from a country,...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Delete holes in a Polygon

I have a polygon determined by an Array of Points. This polygon is crossing itself making some holes in the polygon itself. My questions is: How can I omit this holes and just get the exterior ...

Finding cycle of 3 nodes ( or triangles) in a graph

I am working with complex networks. I want to find group of nodes which forms a cycle of 3 nodes (or triangles) in a given graph. As my graph contains about million edges, using a simple iterative ...

热门标签