Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
curvature.h
Go to the documentation of this file.
1/* This file is part of the libdepixelize project
2 Copyright (C) 2013 Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
3
4 GNU Lesser General Public License Usage
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published by the
7 Free Software Foundation; either version 2.1 of the License, or (at your
8 option) any later version.
9 You should have received a copy of the GNU Lesser General Public License
10 along with this library. If not, see <http://www.gnu.org/licenses/>.
11
12 GNU General Public License Usage
13 Alternatively, this library may be used under the terms of the GNU General
14 Public License as published by the Free Software Foundation, either version
15 2 of the License, or (at your option) any later version.
16 You should have received a copy of the GNU General Public License along with
17 this library. If not, see <http://www.gnu.org/licenses/>.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23*/
24
25#ifndef LIBDEPIXELIZE_TRACER_CURVATURE_H
26#define LIBDEPIXELIZE_TRACER_CURVATURE_H
27
28#include "point.h"
29#include <cmath>
30
31namespace Tracer {
32
38template<class T>
40{
44
45 T operator()(T t) const;
46
50 T xPrime(T t) const;
51
55 T yPrime(T t) const;
56
60 T xPrimePrime() const;
61
65 T yPrimePrime() const;
66
68};
69
70template<class T>
72{
73 T num = xPrime(t) * yPrimePrime() - yPrime(t) * xPrimePrime();
74 T den = std::pow(xPrime(t) * xPrime(t) + yPrime(t) * yPrime(t), T(3) / 2);
75 return num / den;
76}
77
78template<class T>
80{
81 return (1-t)*2*(c1.x-p0.x) + t*2*(p2.x-c1.x);
82}
83
84template<class T>
86{
87 return (1-t)*2*(c1.y-p0.y) + t*2*(p2.y-c1.y);
88}
89
90template<class T>
92{
93 return 2 * (p2.x - 2*c1.x + p0.x);
94}
95
96template<class T>
98{
99 return 2 * (p2.y - 2*c1.y + p0.y);
100}
101
102} // namespace Tracer
103
104#endif // LIBDEPIXELIZE_TRACER_CURVATURE_H
105
106/*
107 Local Variables:
108 mode:c++
109 c-file-style:"stroustrup"
110 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111 indent-tabs-mode:nil
112 fill-column:99
113 End:
114*/
115// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
int num
Definition scribble.cpp:47
Curvature function for a quadratic Bézier curve where the points are know.
Definition curvature.h:40
Point< T > p2
Definition curvature.h:67
T xPrimePrime() const
The second derivative of x.
Definition curvature.h:91
T yPrimePrime() const
The second derivative of y.
Definition curvature.h:97
Curvature(Point< T > p0, Point< T > c1, Point< T > p2)
Definition curvature.h:41
Point< T > c1
Definition curvature.h:67
T operator()(T t) const
Definition curvature.h:71
T xPrime(T t) const
The derivative of x.
Definition curvature.h:79
T yPrime(T t) const
The derivative of y.
Definition curvature.h:85
Point< T > p0
Definition curvature.h:67