1
// Copyright (C) 2003 Dominique Devriese <devriese@kde.org>
3
// This program is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU General Public License
5
// as published by the Free Software Foundation; either version 2
6
// of the License, or (at your option) any later version.
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
#ifndef KIG_MISC_CUBIC_COMMON_H
19
#define KIG_MISC_CUBIC_COMMON_H
26
* This class represents an equation of a cubic in the form
27
* \f$ a_{ijk} x_i x_j x_k = 0 \f$ (in homogeneous coordinates,
28
* \f$ i,j,k = 0,1,2 \f$), \f$ i <= j <= k \f$.
29
* The coefficients are stored in lessicografic order.
31
class CubicCartesianData
36
* \ifnot creating-python-scripting-doc
37
* \brief Default Constructor
39
* Constructs a new CubicCartesianData, with all the coeffs
43
explicit CubicCartesianData();
45
* Constructor. Construct a new CubicCartesianData, with the given
48
CubicCartesianData( double a000, double a001, double a002,
49
double a011, double a012, double a022,
50
double a111, double a112, double a122,
64
CubicCartesianData( const double incoeffs[10] );
67
* Create an invalid CubicCartesianData. This is a special state of a
68
* CubicCartesianData that signals that something went wrong..
70
* \see CubicCartesianData::valid
72
* \internal We represent an invalid CubicCartesianData by setting all
73
* the coeffs to positive or negative infinity. This is handy, since
74
* it doesn't require us to adapt most of the functions, it doesn't
75
* need extra space, and most of the times that we should get an
76
* invalid CubicCartesianData, we get one automatically..
78
static CubicCartesianData invalidData();
80
* Return whether this is a valid CubicCartesianData.
82
* \see CubicCartesianData::invalidData
86
* normalize mdata with infinity norm of the coefficients = 1
91
bool operator==( const CubicCartesianData& lhs, const CubicCartesianData& rhs );
94
* This function calcs a cartesian cubic equation such that the
95
* given points are on the cubic. There can be at most 9 and at
96
* least 2 point. If there are less than 9, than the coefficients
97
* will be chosen to 1.0 if possible
99
const CubicCartesianData calcCubicThroughPoints (
100
const std::vector<Coordinate>& points );
102
const CubicCartesianData calcCubicCuspThroughPoints (
103
const std::vector<Coordinate>& points );
105
const CubicCartesianData calcCubicNodeThroughPoints (
106
const std::vector<Coordinate>& points );
108
double calcCubicYvalue ( double x, double ymin, double ymax,
109
int root, CubicCartesianData data,
110
bool& valid, int& numroots );
112
const Coordinate calcCubicLineIntersect( const CubicCartesianData& c,
114
int root, bool& valid );
116
void calcCubicLineRestriction ( CubicCartesianData data,
117
Coordinate p1, Coordinate dir,
118
double& a, double& b, double& c, double& d );
120
const CubicCartesianData calcCubicTransformation (
121
const CubicCartesianData& data,
122
const Transformation& t, bool& valid );