diff --git a/README.md b/README.md index ed2ec02..1767e68 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,39 @@ int main() } ``` -### News ### +### TRYME + +Try the above snippet +[online here](https://godbolt.org/z/d9oqYs34f), +or on your own Debian-style Linux box: +``` +$ sudo apt install build-essentials +$ wget https://raw.githubusercontent.com/skramm/homog2d/master/homog2d.hpp +$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme.cpp +$ g++ tryme.cpp +$ ./a.out +``` +will print: +``` +[7,8] +``` + +#### TRYME2: + +A slightly more significant file is [available here](misc/tryme2.cpp), try this: + +``` +$ wget https://raw.githubusercontent.com/skramm/homog2d/master/misc/tryme2.cpp +$ g++ tryme2.cpp +$ ./a.out +``` + +It will generate this Svg file: + +![tryme2](docs/tryme2.svg) + + +### News - 2025-01-26: fresh 2.12 release, see https://github.com/skramm/homog2d/releases - 2024-04-21: switch to C++17, enable runtime polymorphism using `std::variant`, [see here](docs/homog2d_manual.md#section_rtp) @@ -53,7 +85,7 @@ int main() (see [history](docs/homog2d_history.md) for more) -### Details ## +### Details - Install: to install on your machine, copy file `homog2d.hpp` somewhere where your compiler can reach it, or `$ sudo make install` after cloning repo. This will copy that file in `/usr/local/include`. diff --git a/docs/tryme2.svg b/docs/tryme2.svg new file mode 100644 index 0000000..97b96e6 --- /dev/null +++ b/docs/tryme2.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/misc/homog2d.cbp b/misc/homog2d.cbp index 4b8207d..eef8206 100644 --- a/misc/homog2d.cbp +++ b/misc/homog2d.cbp @@ -233,6 +233,8 @@ + + diff --git a/misc/tryme2.cpp b/misc/tryme2.cpp new file mode 100644 index 0000000..1672e7b --- /dev/null +++ b/misc/tryme2.cpp @@ -0,0 +1,34 @@ + +#include "homog2d.hpp" +using namespace h2d; +using namespace h2d::img; + +template +void +drawPts( Image& im, const T1& shape1, const T2& shape2 )//, Color col ) +{ + auto x = shape1.intersects(shape2); + if( x() ) + draw( im, x.get() ); //, DrawParams().setColor(col) ); +} + +int main() +{ + Image im(300,250); + + Line2d li( Point2d(30,50), Point2d(100,80) ); + li.draw( im, DrawParams().setColor(0,0,250) ); + + FRect r( 40,30,200,180 ); + auto r2 = Homogr(-5.*M_PI/180.) * r; + r2.draw( im, DrawParams().setColor(200,0,0) ); + + Circle cir( 162, 141, 65 ); + cir.draw( im, DrawParams().setColor(0,250,0) ); + + drawPts( im, li, cir ); + drawPts( im, li, r2 ); + drawPts( im, r2, cir ); + + std::cout << im; +}