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., 59 Temple Place - Suite 330, 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 * "a_{ijk} x_i x_j x_k = 0" (in homogeneous coordinates, i,j,k = 0,1,2),
29 * The coefficients are stored in lessicografic order.
31 class CubicCartesianData
35 explicit CubicCartesianData();
36 CubicCartesianData( double a000
, double a001
, double a002
,
37 double a011
, double a012
, double a022
,
38 double a111
, double a112
, double a122
,
52 CubicCartesianData( const double incoeffs
[10] );
54 static CubicCartesianData
invalidData();
58 bool operator==( const CubicCartesianData
& lhs
, const CubicCartesianData
& rhs
);
61 * This function calcs a cartesian cubic equation such that the
62 * given points are on the cubic. There can be at most 9 and at
63 * least 2 point. If there are less than 9, than the coefficients
64 * will be chosen to 1.0 if possible
67 const CubicCartesianData
calcCubicThroughPoints (
68 const std::vector
<Coordinate
>& points
);
70 const CubicCartesianData
calcCubicCuspThroughPoints (
71 const std::vector
<Coordinate
>& points
);
73 const CubicCartesianData
calcCubicNodeThroughPoints (
74 const std::vector
<Coordinate
>& points
);
76 double calcCubicYvalue ( double x
, double ymin
, double ymax
,
77 int root
, CubicCartesianData data
,
78 bool& valid
, int& numroots
);
80 const Coordinate
calcCubicLineIntersect( const CubicCartesianData
& c
,
82 int root
, bool& valid
);
84 void calcCubicLineRestriction ( CubicCartesianData data
,
85 Coordinate p1
, Coordinate dir
,
86 double& a
, double& b
, double& c
, double& d
);
88 const CubicCartesianData
calcCubicTransformation (
89 const CubicCartesianData
& data
,
90 const Transformation
& t
, bool& valid
);