← comparison · doc/geometry.md

Geometry

Jngen provides two point classes: Point with long long coordinates and Pointf with long double coordinates. Standard operations like addition, subtraction, dot and cross products are supported. Similarly, classes Polygon and Polygonf are provided. A special class GeometryRandom is used for generating objects, all interaction goes via its global instance rndg.

Point is basically a structure with two fields: x and y. Polygon is basically an Array of Points.

Like most Jngen objects, Point and Polygon can be printed to streams and modified with output modifiers.

If you are looking for an SVG drawing tool, please refer to this page.

Generators (rndg static methods)

Point point(long long C)

Pointf pointf(long double C)

Point point(long long min, long long max)

Pointf pointf(long double min, long double max)

Point point(long long x1, long long y1, long long x2, long long y2)

Pointf pointf(long double x1, long double y1, long double x2, long double y2)

Polygon convexPolygon(int n, long long C)

Polygon convexPolygon(int n, long long min, long long max)

Polygon convexPolygon(int n, long long x1, long long y1, long long x2, long long y2)

then n points are randomly selected from it.

TArray<Point> pointsInGeneralPosition(int n, long long C)

TArray<Point> pointsInGeneralPosition(int n, long long min, long long max)

TArray<Point> pointsInGeneralPosition(int n, long long x1, long long y1, long long x2, long long y2)

Point and Pointf operators

Here is the list of operators supported for Point and Pointf. All of them are declared const, excluding those which explicitly modify their arguments.

For Pointf comparisons of floating point values are done with eps presision. The default value is 10-9. It can be overridden with setEps function.

Polygon and Polygonf methos

Polygon inherits TArray<Point> so has it supports standard Array methods like .sort(), .choice() and so on. However, it provides a couple of additional methods.

Polygon& shift(const Point& vector)

Polygon shifted(const Point& vector) const

Polygon& reflect()

Polygon reflected() const