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
31
namespace
Tracer
{
32
38
template
<
class
T>
39
struct
Curvature
40
{
41
Curvature
(
Point<T>
p0
,
Point<T>
c1
,
Point<T>
p2
) :
42
p0
(
p0
),
c1
(
c1
),
p2
(
p2
)
43
{}
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
67
Point<T>
p0
,
c1
,
p2
;
68
};
69
70
template
<
class
T>
71
T
Curvature<T>::operator()
(T t)
const
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
78
template
<
class
T>
79
T
Curvature<T>::xPrime
(T t)
const
80
{
81
return
(1-t)*2*(c1.x-p0.x) + t*2*(p2.x-c1.x);
82
}
83
84
template
<
class
T>
85
T
Curvature<T>::yPrime
(T t)
const
86
{
87
return
(1-t)*2*(c1.y-p0.y) + t*2*(p2.y-c1.y);
88
}
89
90
template
<
class
T>
91
T
Curvature<T>::xPrimePrime
()
const
92
{
93
return
2 * (p2.x - 2*c1.x + p0.x);
94
}
95
96
template
<
class
T>
97
T
Curvature<T>::yPrimePrime
()
const
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 :
Tracer
Definition
kopftracer2011.cpp:44
num
int num
Definition
scribble.cpp:47
Tracer::Curvature
Curvature function for a quadratic Bézier curve where the points are know.
Definition
curvature.h:40
Tracer::Curvature::p2
Point< T > p2
Definition
curvature.h:67
Tracer::Curvature::xPrimePrime
T xPrimePrime() const
The second derivative of x.
Definition
curvature.h:91
Tracer::Curvature::yPrimePrime
T yPrimePrime() const
The second derivative of y.
Definition
curvature.h:97
Tracer::Curvature::Curvature
Curvature(Point< T > p0, Point< T > c1, Point< T > p2)
Definition
curvature.h:41
Tracer::Curvature::c1
Point< T > c1
Definition
curvature.h:67
Tracer::Curvature::operator()
T operator()(T t) const
Definition
curvature.h:71
Tracer::Curvature::xPrime
T xPrime(T t) const
The derivative of x.
Definition
curvature.h:79
Tracer::Curvature::yPrime
T yPrime(T t) const
The derivative of y.
Definition
curvature.h:85
Tracer::Curvature::p0
Point< T > p0
Definition
curvature.h:67
Tracer::Point
Definition
point.h:32
src
3rdparty
libdepixelize
priv
curvature.h
Generated on Sun Jul 13 2025 04:02:13 for Inkscape by
1.9.8