Algorithmic Solutions > LEDA > LEDA Guide > Geometry > Generators for Geometric Objects


Generators for Geometric Objects

There is a frequent need to generate geometric objects, random or otherwise.

Generators for Random Points

There are generators for random points in squares, in discs, near circles, and on circles. For each generator there is a version that generates a single point and a version that generates a list of points. See the Manual Page Point Generators for details.

All generators are available for point, rat_point, d3_point, and d3_rat_point.

Example of Generators for Random Points

Generating Polygons

There are three generators for polygons.
	POLYGON reg_n_gon(int n,CIRCLE C, double epsilon);
	POLYGON n_gon(int n, CIRCLE C, double epsilon);
	POLYGON hilbert(int n, RAT_TYPE x1, RAT_TYPE y1, RAT_TYPE x2, RAT_TYPE y2);

The first generates a regular n-gon. With the rational kernel the vertices of the n-gon are guaranteed to lie on the circle, with the floating point kernel they are only guaranteed to lie near C.
The second generator generates a (nearly) regular n-gon whose vertices lie near the circle C. For the floating point kernel both generators are equivalent. For the rational kernel the second function generates an n-gon with floating point arithmetic and then converts the resulting polygon to a rat_polygon.
The last generator generates the Hilbert polygon of order n within the rectangle with boundary (x1, y1) and (x2, y2).

We use the notation POLYGON (CIRCLE) to indicate that the algorithms work both for polygon (circle) and rat_polygon (rat_circle). RAT_TYPE is double for the floating point kernel and Rational for the rational kernel. (More information on Writing Kernel Independent Code.)

Example of Generators for Polygons

See also:

Data Types for 2D Geometry

Data Types for 3-D Geometry

Linear Lists

Writing Kernel Independent Code


Geometry

Advanced Data types for 2-D geometry

Geometry Algorithms

GeoWin


Manual Entries:

Manual Page Point Generators

Manual Page Polygon




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH