/
draw_toon.cc
53 lines (40 loc) · 1.43 KB
/
draw_toon.cc
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
/*
This file is part of the CVD Library.
Copyright (C) 2005 The Authors
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cvd/draw.h>
#include <utility>
#include <TooN/helpers.h>
using namespace TooN;
using namespace std;
namespace CVD {
static double len2(const Vector<2>& v)
{
return v*v;
}
vector<ImageRef> getSolidEllipse(float r1, float r2, float theta)
{
vector<ImageRef> e;
int r = (int) ceil(max(r1, r2) + 1);
Matrix<2> t;
t[0] = makeVector(cos(theta), sin(theta)) / r1;
t[1] = makeVector(-sin(theta), cos(theta)) / r2;
for(int y=-r; y <= r; y++)
for(int x=-r; x <= r; x++)
if(len2(t * makeVector(x, y)) <= 1)
e.push_back(ImageRef(x, y));
return e;
}
};