Module geometry

Source
Expand description

bracket-geometry provides some geometric primitives (Point, Point3D, Rect), support functions and distance calculations. It also includes Bresenham’s line algorithm, a vector line algorithm, and Bresenham’s Circle algorithm.

Structs§

Bresenham
Line-drawing iterator
BresenhamCircle
An implementation of [Bresenham’s circle algorithm]. [Bresenham’s circle algorithm]: http://members.chello.at/~easyfilter/bresenham.html Derived from the line_drawing crate, but specialized to use BTerm’s types.
BresenhamCircleNoDiag
A version of the Bresenham circle that does not make diagonal jumps
BresenhamInclusive
New type over Bresenham which include the end points when iterated over.
Degrees
Convenience type: you can define an angle in Degrees and it is convertible to Radians (and vice versa)
Point
Helper struct defining a 2D point in space.
Point3
Helper struct defining a 2D point in space.
Radians
Convenience type: you can define an angle in Radians and it is convertible to Degrees (and vice versa)
Rect
Defines a two-dimensional rectangle.
RectF
Defines a rectangle with floating-point coordinates.
VectorLine
Define a line using a fast 2D vector. It may not be as pixel-perfect as Bresenham, but with vectorization it is sometimes faster for a quick line solution.

Enums§

DistanceAlg
Enumeration of available 2D Distance algorithms
LineAlg
Enumeration of available 2D Distance algorithms

Functions§

line2d
Plots a line between two 2D points and returns a vector of points along the line.
line2d_bresenham
Uses a Bresenham’s algorithm to plot a line between two points. On some CPUs, this is faster than Bresenham.
line2d_vector
Uses a 2D vector algorithm to plot a line between two points. On some CPUs, this is faster than Bresenham.
project_angle
From a given start point, project forward radius units at an angle of angle_radians degrees. 0 Degrees is north (negative Y), 90 degrees is east (positive X)

Type Aliases§

PointF
A 2D floating-point position.