Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/KoCurveFit.cpp
Show All 31 Lines | 29 | /* | |||
---|---|---|---|---|---|
32 | from "Graphics Gems", Academic Press, 1990 | 32 | from "Graphics Gems", Academic Press, 1990 | ||
33 | 33 | | |||
34 | http://tog.acm.org/resources/GraphicsGems/gems/FitCurves.c | 34 | http://tog.acm.org/resources/GraphicsGems/gems/FitCurves.c | ||
35 | http://tog.acm.org/resources/GraphicsGems/gems/README | 35 | http://tog.acm.org/resources/GraphicsGems/gems/README | ||
36 | */ | 36 | */ | ||
37 | 37 | | |||
38 | class FitVector { | 38 | class FitVector { | ||
39 | public: | 39 | public: | ||
40 | FitVector(const QPointF &p) { | 40 | FitVector(const QPointF &p) | ||
41 | m_X = p.x(); | 41 | : m_X(p.x()) | ||
42 | m_Y = p.y(); | 42 | , m_Y(p.y()) | ||
43 | { | ||||
43 | } | 44 | } | ||
44 | 45 | | |||
45 | FitVector() { | 46 | FitVector() | ||
46 | m_X = 0; | 47 | : m_X(0) | ||
47 | m_Y = 0; | 48 | , m_Y(0) | ||
49 | { | ||||
48 | } | 50 | } | ||
49 | 51 | | |||
50 | FitVector(const QPointF &a, const QPointF &b) { | 52 | FitVector(const QPointF &a, const QPointF &b) | ||
51 | m_X = a.x() - b.x(); | 53 | : m_X(a.x() - b.x()) | ||
52 | m_Y = a.y() - b.y(); | 54 | , m_Y(a.y() - b.y()) | ||
55 | { | ||||
53 | } | 56 | } | ||
54 | 57 | | |||
55 | void normalize() { | 58 | void normalize() { | ||
56 | qreal len = length(); | 59 | qreal len = length(); | ||
57 | if (qFuzzyCompare(len, qreal(0.0))) { | 60 | if (qFuzzyCompare(len, qreal(0.0))) { | ||
58 | return; | 61 | return; | ||
59 | } | 62 | } | ||
60 | m_X /= len; m_Y /= len; | 63 | m_X /= len; m_Y /= len; | ||
▲ Show 20 Lines • Show All 517 Lines • Show Last 20 Lines |