iLab Neuromorphic Robotics Toolkit  0.1
Geometry-related classes and functions

Includes simple classes for points, rectangles, dimensions, lines, circles, etc.

The geometry classes are meant to be simple and efficient yet provide sufficient versatility. Most classes support the following:

• template typing, so that the geometric primitives can be instantiated for int, float, double, or many other underlying base types. Not all features may work for any underlying base type, depending on what that type supports (e.g., addition of geometry types requires that addition be defined for the underlying base type).
• explicit constructors, which eliminates the risks associated with implicit conversion and construction. This also means that one must be explicit when converting between geometric primitives that use different underlying base types. For example:
nrt::Point2D<int> p(100, 100);
nrt::Point2D<float> pp(p); // ok, explicit construction of pp from p
//pp = p; // does not compile: implicit conversion not allowed in assignment
pp = nrt::Point2D<float>(p); // ok, explicit conversion
Note that clamping and rounding may occur when converting, based on the behavior of nrt::clamped_convert which is used internally by converting geometry constructors, for example:
nrt::Point2D<float> pfl(12.34F, 567.89F);
nrt::Point2D<int> pin(pfl); // pin is (12, 568)
nrt::Point2D<nrt::byte> pby(pfl); // pby is (12, 255)
Finally note that rounding is based on the C++11 std::round() function, which correctly handles both positive and negative numbers (see test-Point.C for examples).
• copy and move constructors and assignment so that it is inexpensive to return geometric primitives from functions.
• operator overloads where they make sense:
• All geometric primitives support equality and inequality operators.
• Most geometric primitives multiplication and division by a double-precision scalar, which scales all coordinates in the primitive.
• Many geometric primitives support a free function `nrt::scale()`, which differs from multiplication in that it will scale the size of the object without changing its position, while multiplication scales all coordinates (so multiplication is appropriate for, e.g., resolution changes while `scale()` is for growing/shrinking an object without moving it).
• Many geometric primitives support a free function `nrt::rotate()` which rotates the primitive about its canonical center.
• Most geometric primitives support an `area()` function that returns the area as a double-precision number.
• Many geometric primitives support addition and subtraction with a Point2D of same template parameter, which corresponds to translation.
• Some geometric primitives support addition and subtraction with another object of their own (e.g., Dims<int> + Dims<int>) but usually product and division of that kind is not supported as it makes little sense.
• read-only access member functions, to fetch elements out of the geometric primitives (e.g., get the center coordinates and the radius of a Circle). No write member functions are provided, instead you should create a new geometric primitive. For example:
nrt::Circle<int> circle(nrt::Point2D<int>(100, 100), 10); // center at (100,100), radius 10
nrt::point2D<int> center = circle.center(); // ok
// We create a new circle instead of trying to modify our existing one:
nrt::Circle<int> newcircle(circle.center() + nrt::Point2D<int>(20, 30),
• a contains(Point2D<U> point) function which returns true if a point is inside the geometric primitive (for Circle, Rectangle, Dims, etc). Any point is ok for this function.

Many examples of use are provided in test-Geometry.C, test-Point.C and other example files.

## Classes

class  nrt::Circle< T >
A simple representation of a circle. More...

class  nrt::Dims< T >
A generic dimensions class. More...

class  nrt::Line< T >
A 2D line segment. More...

class  nrt::Point< T, Dimensions >
A N-Dimensional Point Class. More...

class  nrt::Point2D< T >
A 2-Dimensional Point Class. More...

class  nrt::Point3D< T >
A 3-Dimensional Point Class. More...

class  nrt::Polygon< T >
A 2D polygon representation. More...

class  nrt::Rectangle< T >
A basic rectangle class. More...

class  nrt::RotatedRectangle< T >
A 2D rotated rectangle containing a center point, dimensions, and an angle. More...