Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/I3ck/lib_2d
A c++ library for paths defined by points within the 2d space
https://github.com/I3ck/lib_2d
Last synced: 28 days ago
JSON representation
A c++ library for paths defined by points within the 2d space
- Host: GitHub
- URL: https://github.com/I3ck/lib_2d
- Owner: I3ck
- License: mit
- Created: 2015-01-08T22:34:06.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-09T12:09:47.000Z (almost 9 years ago)
- Last Synced: 2024-08-04T02:10:56.710Z (4 months ago)
- Language: C++
- Size: 274 KB
- Stars: 45
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - lib_2d
README
#lib_2d
A c++ library for anything related to points within the 2d space (using floating point data types)
using Catch as testing framework https://github.com/philsquared/Catch##version 0.9.1
##templated
tested for:```cpp
float
double
long double
```##classes
currently, the following classes are supported:```cpp
Point //a point defined with two coordinates (x and y)
PointCloud //a collection Points, without topological information
OrderedPointCloud //a PointCloud with additional information regarding sorting and filtering of points
KdTree //search tree to quickly find nearest neighbors//subclasses of PointCloud
LineSegment //a line segment defined by start and end point
Rectangle //a rectangle defined by width, height and center
Arc //an arc defined by diameter, center, start- and end angle
Ellipse //an ellipse
InterpolationBezier //a bezier curve interpolation
InterpolationLinear //a linear interpolation
InvolutCircle //involut curve of a circle
```##methods
some of the supported methods:```cpp
move_by(...) //moves the Point or PointCloud
mirror_vertically(...) //mirrors the Point or PointCloud at a vertical line (horizontally and point also supported)
rotate(...) //rotate by angle around a center
to_string(...) //write coordinates to a string
from_string(...) //parse from a string
distance_to(...) //calculate distances between points
load(...) //load coordinates from file
to_file(...) //write coordinates to file
bounding_box(...) //the minimum bounding rectangle of a PointCloud
convex_hull(...) //calculate the convex hull of a PointCloud
concave_hull(...) //compareable to the convex hull, while better following the shape of a pointcloud
intersections_with(...) //intersections between paths
sort_x(...) //sort by x (or y)
range(from,to) //get ranges of PointCloud
and_many(more)
```also chainable:
```cpp
path.move_by(...).rotate(...).sort_x(...)
```##compatible with other containers
```cpp
vector< Point > vec = vector >(path.begin(), path.end());
...
PointCloud path = PointCloud(vec.begin(), vec.end());
```##operator overloads
```cpp
== != //equality
+ += //appending to PointCloud
[] //access elements of PointCloud
std::cout << PointCloud << Point; //overloads for streams
```##using lib_2d
add `inc/` to your include path and `#include lib_2d.h` within your code
`/tests/test_lib_2d.cpp` also provides a basic usage example##testing
`make tests`
you can also use
`make clean`##contribute
If you find any bugs, feel free to open an issue
If you'd like other PointClouds than Arc etc. open an issue
Also feel free to open a pull request, in case you added / fixed something yourself