-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathshowcase6.cpp
68 lines (53 loc) · 1.58 KB
/
showcase6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
\file
\brief Generates a circle from 2/3 points
*/
//#define HOMOG2D_DEBUGMODE
#include "../../homog2d.hpp"
using namespace h2d;
using namespace h2d::img;
int main( int, const char** )
{
auto nbim = 25; // nb images
auto Hdraw = Homogr().setScale(30).addTranslation(10,10);
auto x0 = 3.;
auto k=1.8;
Point2d p1( 2, 4 );
Point2d p2( 6, 5 );
Segment seg( 1., 1., 4.5, 2.8 );
for( int i=0; i<nbim; i++ )
{
auto angle = i*360./nbim;
auto angle_r = angle * M_PI / 180.;
auto x1 = std::cos(angle_r)*k;
auto y1 = std::sin(angle_r)*k;
Point2d p0( x1+x0, y1+x0);
std::vector<Point2d> v1{ p1, p2, p0 };
std::vector<Point2d> v2{ p1, p0 };
Circle cir1( p0,p1,p2);
Circle cir2( p0,p1 );
auto v1d = Hdraw * v1;
auto v2d = Hdraw * v2;
auto cir1d = Hdraw * cir1;
auto cir2d = Hdraw * cir2;
auto segd = Hdraw * seg;
Image<img::SvgImage> im1( 250, 200 );
auto dpinter= DrawParams().setPointStyle( PtStyle::Diam ).setColor( 20,250,20 );
auto int1 = cir1.intersects( seg );
auto int2 = cir2.intersects( seg );
if( int1() )
for( const auto pt: int1.get() )
draw( im1, Hdraw * pt, dpinter );
if( int2() )
for( const auto pt: int2.get() )
draw( im1, Hdraw * pt, dpinter );
draw( im1, v1d );
cir2d.getBB().draw( im1, DrawParams().setColor(150,200,200) );
segd.draw( im1, DrawParams().setColor(50,50,150) );
cir1d.draw( im1, DrawParams().setColor(250,0,0) );
cir2d.draw( im1, DrawParams().setColor(0,0,250) );
std::ostringstream ossa;
ossa << "showcase6_" << std::setfill('0') << std::setw(2) << i << ".svg";
im1.write( ossa.str() );
}
}