Seamly2D
Code documentation
vspline.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vspline.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "vspline.h"
53 
54 #include <QLineF>
55 
56 #include "vabstractcurve.h"
57 #include "vspline_p.h"
58 #include "../vmisc/vmath.h"
59 
60 #ifdef Q_COMPILER_RVALUE_REFS
61 VSpline &VSpline::operator=(VSpline &&spline) Q_DECL_NOTHROW { Swap(spline); return *this; }
62 #endif
63 
64 void VSpline::Swap(VSpline &spline) Q_DECL_NOTHROW
65 { VAbstractCubicBezier::Swap(spline); std::swap(d, spline.d); }
66 
67 //---------------------------------------------------------------------------------------------------------------------
68 /**
69  * @brief VSpline default constructor
70  */
73 {}
74 
75 //---------------------------------------------------------------------------------------------------------------------
76 /**
77  * @brief VSpline constructor.
78  * @param spline spline from which the copy.
79  */
80 VSpline::VSpline ( const VSpline & spline )
81  :VAbstractCubicBezier(spline), d(spline.d)
82 {}
83 
84 //---------------------------------------------------------------------------------------------------------------------
85 /**
86  * @brief VSpline constructor.
87  * @param p1 first point spline.
88  * @param p4 last point spline.
89  * @param angle1 angle from first point to first control point.
90  * @param angle2 angle from second point to second control point.
91  * @param kCurve coefficient of curvature spline.
92  * @param kAsm1 coefficient of length first control line.
93  * @param kAsm2 coefficient of length second control line.
94  */
95 VSpline::VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
96  qreal kCurve, quint32 idObject, Draw mode)
97  : VAbstractCubicBezier(GOType::Spline, idObject, mode),
98  d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve))
99 {
100  CreateName();
101 }
102 
103 //---------------------------------------------------------------------------------------------------------------------
104 /**
105  * @brief VSpline constructor.
106  * @param p1 first point spline.
107  * @param p2 first control point.
108  * @param p3 second control point.
109  * @param p4 second point spline.
110  */
111 VSpline::VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject,
112  Draw mode)
113  :VAbstractCubicBezier(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4))
114 {
115  CreateName();
116 }
117 
118 
119 //---------------------------------------------------------------------------------------------------------------------
120 /**
121  * @brief VSpline constructor
122  * @param p1 first point spline.
123  * @param p4 first control point.
124  * @param angle1 angle from first point to first control point.
125  * @param angle1Formula formula angle from first point to first control point.
126  * @param angle2 angle from second point to second control point.
127  * @param angle2Formula formula angle from second point to second control point.
128  * @param c1Length length from first point to first control point.
129  * @param c1LengthFormula formula length from first point to first control point.
130  * @param c2Length length from second point to first control point.
131  * @param c2LengthFormula formula length from second point to first control point.
132  */
133 VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2,
134  const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
135  const QString &c2LengthFormula, quint32 idObject, Draw mode)
136  : VAbstractCubicBezier(GOType::Spline, idObject, mode),
137  d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
138  c2LengthFormula))
139 {
140  CreateName();
141 }
142 
143 //---------------------------------------------------------------------------------------------------------------------
144 VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const
145 {
146  const VPointF p1 = GetP1().Rotate(originPoint, degrees);
147  const VPointF p4 = GetP4().Rotate(originPoint, degrees);
148 
149  const QPointF p2 = VPointF::RotatePF(originPoint, static_cast<QPointF>(GetP2()), degrees);
150  const QPointF p3 = VPointF::RotatePF(originPoint, static_cast<QPointF>(GetP3()), degrees);
151 
152  VSpline spl(p1, p2, p3, p4);
153  spl.setName(name() + prefix);
154  spl.setLineColor(getLineColor());
155  spl.SetPenStyle(GetPenStyle());
157  return spl;
158 }
159 
160 //---------------------------------------------------------------------------------------------------------------------
161 VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
162 {
163  const VPointF p1 = GetP1().Flip(axis);
164  const VPointF p4 = GetP4().Flip(axis);
165 
166  const QPointF p2 = VPointF::FlipPF(axis, static_cast<QPointF>(GetP2()));
167  const QPointF p3 = VPointF::FlipPF(axis, static_cast<QPointF>(GetP3()));
168 
169  VSpline spl(p1, p2, p3, p4);
170  spl.setName(name() + prefix);
171  spl.setLineColor(getLineColor());
172  spl.SetPenStyle(GetPenStyle());
174  return spl;
175 }
176 
177 //---------------------------------------------------------------------------------------------------------------------
178 VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
179 {
180  const VPointF p1 = GetP1().Move(length, angle);
181  const VPointF p4 = GetP4().Move(length, angle);
182 
183  const QPointF p2 = VPointF::MovePF(static_cast<QPointF>(GetP2()), length, angle);
184  const QPointF p3 = VPointF::MovePF(static_cast<QPointF>(GetP3()), length, angle);
185 
186  VSpline spl(p1, p2, p3, p4);
187  spl.setName(name() + prefix);
188  spl.setLineColor(getLineColor());
189  spl.SetPenStyle(GetPenStyle());
191  return spl;
192 }
193 
194 //---------------------------------------------------------------------------------------------------------------------
196 {}
197 
198 //---------------------------------------------------------------------------------------------------------------------
199 /**
200  * @brief GetLength return length of spline.
201  * @return length.
202  */
203 qreal VSpline::GetLength () const
204 {
205  return LengthBezier ( static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
206  static_cast<QPointF>(GetP4()));
207 }
208 
209 //---------------------------------------------------------------------------------------------------------------------
210 QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const
211 {
212  QPointF spl1p2;
213  QPointF spl1p3;
214  QPointF spl2p2;
215  QPointF spl2p3;
216  const QPointF cutPoint = CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 );
217 
218  spl1 = VSpline(GetP1(), spl1p2, spl1p3, VPointF(cutPoint));
219  spl2 = VSpline(VPointF(cutPoint), spl2p2, spl2p3, GetP4());
220  return cutPoint;
221 }
222 
223 //---------------------------------------------------------------------------------------------------------------------
224 /**
225  * @brief GetPoints return list with spline points.
226  * @return list of points.
227  */
229 {
230  return GetCubicBezierPoints(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()),
231  static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()));
232 }
233 
234 //---------------------------------------------------------------------------------------------------------------------
235 /**
236  * @brief SplinePoints return list with spline points.
237  * @param p1 first spline point.
238  * @param p4 last spline point.
239  * @param angle1 angle from first point to first control point.
240  * @param angle2 angle from second point to second control point.
241  * @param kAsm1 coefficient of length first control line.
242  * @param kAsm2 coefficient of length second control line.
243  * @param kCurve coefficient of curvature spline.
244  * @return list with spline points.
245  */
246 // cppcheck-suppress unusedFunction
247 QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
248  qreal kAsm2, qreal kCurve)
249 {
250  QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
251  p1pX.setAngle( angle1 );
252  qreal L = 0, radius = 0, angle = 90;
253  radius = QLineF(QPointF(p1.x(), p4.y()), p4).length();
254  L = kCurve * radius * 4 / 3 * tan( angle * M_PI_4 / 180.0 );
255  QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
256  p1p2.setAngle(angle1);
257  QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y());
258  p4p3.setAngle(angle2);
259  QPointF p2 = p1p2.p2();
260  QPointF p3 = p4p3.p2();
261  return GetCubicBezierPoints(p1, p2, p3, p4);
262 }
263 
264 //---------------------------------------------------------------------------------------------------------------------
266 {
267  if ( &spline == this )
268  {
269  return *this;
270  }
272  d = spline.d;
273  return *this;
274 }
275 
276 //---------------------------------------------------------------------------------------------------------------------
277 /**
278  * @brief GetP1 return first spline point.
279  * @return first point.
280  */
282 {
283  return d->p1;
284 }
285 
286 //---------------------------------------------------------------------------------------------------------------------
287 void VSpline::SetP1(const VPointF &p)
288 {
289  d->p1 = p;
290 }
291 
292 //---------------------------------------------------------------------------------------------------------------------
293 /**
294  * @brief GetP2 return first control point.
295  * @return first control point.
296  */
298 {
299  QLineF p1p2(d->p1.x(), d->p1.y(), d->p1.x() + d->c1Length, d->p1.y());
300  p1p2.setAngle(d->angle1);
301  return VPointF(p1p2.p2());
302 }
303 
304 //---------------------------------------------------------------------------------------------------------------------
305 /**
306  * @brief GetP3 return second control point.
307  * @return second control point.
308  */
310 {
311  QLineF p4p3(d->p4.x(), d->p4.y(), d->p4.x() + d->c2Length, d->p4.y());
312  p4p3.setAngle(d->angle2);
313  return VPointF(p4p3.p2());
314 }
315 
316 //---------------------------------------------------------------------------------------------------------------------
317 /**
318  * @brief GetP4 return last spline point.
319  * @return остання точка сплайну.
320  */
322 {
323  return d->p4;
324 }
325 
326 //---------------------------------------------------------------------------------------------------------------------
327 void VSpline::SetP4(const VPointF &p)
328 {
329  d->p4 = p;
330 }
331 
332 //---------------------------------------------------------------------------------------------------------------------
333 /**
334  * @brief GetAngle1 return first angle control line.
335  * @return angle.
336  */
338 {
339  return d->angle1;
340 }
341 
342 //---------------------------------------------------------------------------------------------------------------------
343 /**
344  * @brief GetAngle2 return second angle control line.
345  * @return angle.
346  */
347 qreal VSpline::GetEndAngle() const
348 {
349  return d->angle2;
350 }
351 
352 //---------------------------------------------------------------------------------------------------------------------
354 {
355  return d->angle1F;
356 }
357 
358 //---------------------------------------------------------------------------------------------------------------------
360 {
361  return d->angle2F;
362 }
363 
364 //---------------------------------------------------------------------------------------------------------------------
365 void VSpline::SetStartAngle(qreal angle, const QString &formula)
366 {
367  d->angle1 = angle;
368  d->angle1F = formula;
369 }
370 
371 //---------------------------------------------------------------------------------------------------------------------
372 void VSpline::SetEndAngle(qreal angle, const QString &formula)
373 {
374  d->angle2 = angle;
375  d->angle2F = formula;
376 }
377 
378 //---------------------------------------------------------------------------------------------------------------------
379 qreal VSpline::GetC1Length() const
380 {
381  return d->c1Length;
382 }
383 
384 //---------------------------------------------------------------------------------------------------------------------
385 qreal VSpline::GetC2Length() const
386 {
387  return d->c2Length;
388 }
389 
390 //---------------------------------------------------------------------------------------------------------------------
392 {
393  return d->c1LengthF;
394 }
395 
396 //---------------------------------------------------------------------------------------------------------------------
398 {
399  return d->c2LengthF;
400 }
401 
402 //---------------------------------------------------------------------------------------------------------------------
403 void VSpline::SetC1Length(qreal length, const QString &formula)
404 {
405  d->c1Length = length;
406  d->c1LengthF = formula;
407 }
408 
409 //---------------------------------------------------------------------------------------------------------------------
410 void VSpline::SetC2Length(qreal length, const QString &formula)
411 {
412  d->c2Length = length;
413  d->c2LengthF = formula;
414 }
415 
416 //---------------------------------------------------------------------------------------------------------------------
417 /**
418  * @brief GetKasm1 return coefficient of length first control line.
419  * @return coefficient.
420  */
421 qreal VSpline::GetKasm1() const
422 {
423  return QLineF(static_cast<QPointF>(d->p1), static_cast<QPointF>(GetP2())).length() /
424  VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
425 }
426 
427 //---------------------------------------------------------------------------------------------------------------------
428 /**
429  * @brief GetKasm2 return coefficient of length second control line.
430  * @return coefficient.
431  */
432 qreal VSpline::GetKasm2() const
433 {
434  return QLineF(static_cast<QPointF>(d->p4), static_cast<QPointF>(GetP3())).length() /
435  VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
436 }
437 
438 //---------------------------------------------------------------------------------------------------------------------
439 /**
440  * @brief GetKcurve return coefficient of curvature spline.
441  * @return coefficient
442  */
443 qreal VSpline::GetKcurve() const
444 {
445  return d->kCurve;
446 }
447 
448 //---------------------------------------------------------------------------------------------------------------------
449 int VSpline::Sign(long double ld)
450 {
451  if (qAbs(ld)<0.00000000001)
452  {
453  return 0;
454  }
455  return (ld>0) ? 1 : -1;
456 }
457 
458 //---------------------------------------------------------------------------------------------------------------------
459 /**
460  * @brief Cubic Cubic equation solution. Real coefficients case.
461  *
462  * This method use method Vieta-Cardano for eval cubic equations.
463  * Cubic equation write in form x3+a*x2+b*x+c=0.
464  *
465  * Output:
466  * 3 real roots -> then x is filled with them;
467  * 1 real + 2 complex -> x[0] is real, x[1] is real part of complex roots, x[2] - non-negative imaginary part.
468  *
469  * @param x solution array (size 3).
470  * @param a coefficient
471  * @param b coefficient
472  * @param c coefficient
473  * @return 3 - 3 real roots;
474  * 1 - 1 real root + 2 complex;
475  * 2 - 1 real root + complex roots imaginary part is zero (i.e. 2 real roots).
476  */
477 qint32 VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c)
478 {
479  //To find cubic equation roots in the case of real coefficients, calculated at the beginning
480  const qreal q = (pow(a, 2) - 3*b)/9.;
481  const qreal r = (2*pow(a, 3) - 9*a*b + 27.*c)/54.;
482  if (pow(r, 2) < pow(q, 3))
483  { // equation has three real roots, use formula Vieta
484  const qreal t = acos(r/sqrt(pow(q, 3)))/3.;
485  x.insert(0, -2.*sqrt(q)*cos(t)-a/3);
486  x.insert(1, -2.*sqrt(q)*cos(t + (2*M_2PI/3.)) - a/3.);
487  x.insert(2, -2.*sqrt(q)*cos(t - (2*M_2PI/3.)) - a/3.);
488  return(3);
489  }
490  else
491  { // 1 real root + 2 complex
492  //Formula Cardano
493  const qreal aa = -Sign(r)*pow(fabs(r)+sqrt(pow(r, 2)-pow(q, 3)), 1./3.);
494  const qreal bb = Sign(aa) == 0 ? 0 : q/aa;
495 
496  x.insert(0, aa+bb-a/3.); // Real root
497  x.insert(1, (-0.5)*(aa+bb)-a/3.); //Complex root
498  x.insert(2, (sqrt(3.)*0.5)*fabs(aa-bb)); // Complex root
499  if (qFuzzyIsNull(x.at(2)))
500  {
501  return(2);
502  }
503  return(1);
504  }
505 }
506 
507 //---------------------------------------------------------------------------------------------------------------------
508 QVector<qreal> VSpline::CalcT (qreal curveCoord1, qreal curveCoord2, qreal curveCoord3,
509  qreal curveCoord4, qreal pointCoord) const
510 {
511  const qreal a = -curveCoord1 + 3*curveCoord2 - 3*curveCoord3 + curveCoord4;
512  const qreal b = 3*curveCoord1 - 6*curveCoord2 + 3*curveCoord3;
513  const qreal c = -3*curveCoord1 + 3*curveCoord2;
514  const qreal d = -pointCoord + curveCoord1;
515 
516  QVector<qreal> t = QVector<qreal>(3, -1);
517  Cubic(t, b/a, c/a, d/a);
518 
519  QVector<qreal> retT;
520  for (int i=0; i < t.size(); ++i)
521  {
522  if ( t.at(i) >= 0 && t.at(i) <= 1 )
523  {
524  retT.append(t.at(i));
525  }
526  }
527 
528  return retT;
529 }
530 
531 //---------------------------------------------------------------------------------------------------------------------
532 /**
533  * @brief VSpline::ParamT calculate t coeffient that reprezent point on curve.
534  *
535  * Each point that belongs to Cubic Bézier curve can be shown by coefficient in interval [0; 1].
536  *
537  * @param pBt point on curve
538  * @return t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve.
539  */
540 qreal VSpline::ParamT (const QPointF &pBt) const
541 {
542  QVector<qreal> ts;
543  // Calculate t coefficient for each axis
544  ts += CalcT (GetP1().x(), GetP2().x(), GetP3().x(), GetP4().x(), pBt.x());
545  ts += CalcT (GetP1().y(), GetP2().y(), GetP3().y(), GetP4().y(), pBt.y());
546 
547  if (ts.isEmpty())
548  {
549  return -1; // We don't have candidates
550  }
551 
552  qreal tx = -1;
553  qreal eps = 3; // Error calculation
554 
555  // In morst case we will have 6 result in interval [0; 1].
556  // Here we try find closest to our point.
557  for (int i=0; i< ts.size(); ++i)
558  {
559  const qreal t = ts.at(i);
560  const QPointF p0 = static_cast<QPointF>(GetP1());
561  const QPointF p1 = static_cast<QPointF>(GetP2());
562  const QPointF p2 = static_cast<QPointF>(GetP3());
563  const QPointF p3 = static_cast<QPointF>(GetP4());
564  //The explicit form of the Cubic Bézier curve
565  const qreal pointX = pow(1-t, 3)*p0.x() + 3*pow(1-t, 2)*t*p1.x() + 3*(1-t)*pow(t, 2)*p2.x() + pow(t, 3)*p3.x();
566  const qreal pointY = pow(1-t, 3)*p0.y() + 3*pow(1-t, 2)*t*p1.y() + 3*(1-t)*pow(t, 2)*p2.y() + pow(t, 3)*p3.y();
567 
568  const QLineF line(pBt, QPointF(pointX, pointY));
569  if (line.length() <= eps)
570  {
571  tx = t;
572  eps = line.length(); //Next point should be even closest
573  }
574  }
575 
576  return tx;
577 }
578 
579 //---------------------------------------------------------------------------------------------------------------------
581 {
582  return static_cast<QPointF>(GetP2 ());
583 }
584 
585 //---------------------------------------------------------------------------------------------------------------------
587 {
588  return static_cast<QPointF>(GetP3 ());
589 }
VAbstractCubicBezier & operator=(const VAbstractCubicBezier &curve)
static qreal LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
LengthBezier return spline length using 4 spline point.
virtual void CreateName() Q_DECL_OVERRIDE
static QVector< QPointF > GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
GetCubicBezierPoints return list with cubic bezier curve points.
QString getLineWeight() const
getLineWeight return weight of the lines
void SetPenStyle(const QString &penStyle)
void setLineColor(const QString &color)
void setLineWeight(const QString &lineWeight)
setLineWeight set weight of the lines
QString GetPenStyle() const
void Swap(VAbstractCurve &curve) Q_DECL_NOTHROW
QString getLineColor() const
virtual QString name() const
name return name graphical object.
Definition: vgobject.cpp:148
void setName(const QString &name)
setName set name graphical object.
Definition: vgobject.cpp:158
The VPointF class keep data of point.
Definition: vpointf.h:75
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
Definition: vpointf.cpp:271
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle)
Definition: vpointf.cpp:286
VPointF Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
Definition: vpointf.cpp:146
VPointF Flip(const QLineF &axis, const QString &prefix=QString()) const
Definition: vpointf.cpp:155
qreal y() const
y return y coordinate
Definition: vpointf.cpp:243
VPointF Move(qreal length, qreal angle, const QString &prefix=QString()) const
Definition: vpointf.cpp:164
static QPointF FlipPF(const QLineF &axis, const QPointF &point)
Definition: vpointf.cpp:279
qreal x() const
x return x coordinate
Definition: vpointf.cpp:223
static qreal GetL(const QPointF &p1, const QPointF &p4, qreal kCurve)
Definition: vspline_p.h:227
VSpline class that implements the spline.
Definition: vspline.h:75
virtual qreal GetLength() const Q_DECL_OVERRIDE
GetLength return length of spline.
Definition: vspline.cpp:203
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
Definition: vspline.cpp:144
virtual QPointF GetControlPoint2() const Q_DECL_OVERRIDE
Definition: vspline.cpp:586
static qint32 Cubic(QVector< qreal > &x, qreal a, qreal b, qreal c)
Cubic Cubic equation solution. Real coefficients case.
Definition: vspline.cpp:477
virtual qreal GetC2Length() const Q_DECL_OVERRIDE
Definition: vspline.cpp:385
virtual VPointF GetP4() const Q_DECL_OVERRIDE
GetP4 return last spline point.
Definition: vspline.cpp:321
void SetP4(const VPointF &p)
Definition: vspline.cpp:327
void SetC1Length(qreal length, const QString &formula)
Definition: vspline.cpp:403
QString GetC1LengthFormula() const
Definition: vspline.cpp:391
VSpline()
VSpline default constructor.
Definition: vspline.cpp:71
qreal GetKcurve() const
GetKcurve return coefficient of curvature spline.
Definition: vspline.cpp:443
void SetC2Length(qreal length, const QString &formula)
Definition: vspline.cpp:410
VSpline & operator=(const VSpline &spline)
Definition: vspline.cpp:265
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
GetAngle1 return first angle control line.
Definition: vspline.cpp:337
virtual ~VSpline()
Definition: vspline.cpp:195
void SetP1(const VPointF &p)
Definition: vspline.cpp:287
qreal ParamT(const QPointF &pBt) const
VSpline::ParamT calculate t coeffient that reprezent point on curve.
Definition: vspline.cpp:540
VSpline Flip(const QLineF &axis, const QString &prefix=QString()) const
Definition: vspline.cpp:161
virtual VPointF GetP1() const Q_DECL_OVERRIDE
GetP1 return first spline point.
Definition: vspline.cpp:281
virtual VPointF GetP2() const Q_DECL_OVERRIDE
GetP2 return first control point.
Definition: vspline.cpp:297
QString GetStartAngleFormula() const
Definition: vspline.cpp:353
QString GetEndAngleFormula() const
Definition: vspline.cpp:359
qreal GetKasm1() const
GetKasm1 return coefficient of length first control line.
Definition: vspline.cpp:421
static QVector< QPointF > SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)
SplinePoints return list with spline points.
Definition: vspline.cpp:247
QPointF CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const
CutSpline cut spline.
virtual qreal GetC1Length() const Q_DECL_OVERRIDE
Definition: vspline.cpp:379
void Swap(VSpline &spline) Q_DECL_NOTHROW
Definition: vspline.cpp:64
virtual VPointF GetP3() const Q_DECL_OVERRIDE
GetP3 return second control point.
Definition: vspline.cpp:309
QString GetC2LengthFormula() const
Definition: vspline.cpp:397
VSpline Move(qreal length, qreal angle, const QString &prefix=QString()) const
Definition: vspline.cpp:178
QVector< qreal > CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, qreal pointCoord) const
Definition: vspline.cpp:508
void SetStartAngle(qreal angle, const QString &formula)
Definition: vspline.cpp:365
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list with spline points.
Definition: vspline.cpp:228
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
GetAngle2 return second angle control line.
Definition: vspline.cpp:347
void SetEndAngle(qreal angle, const QString &formula)
Definition: vspline.cpp:372
QSharedDataPointer< VSplineData > d
Definition: vspline.h:143
virtual QPointF GetControlPoint1() const Q_DECL_OVERRIDE
Definition: vspline.cpp:580
static int Sign(long double ld)
Definition: vspline.cpp:449
qreal GetKasm2() const
GetKasm2 return coefficient of length second control line.
Definition: vspline.cpp:432
GOType
Definition: vgeometrydef.h:56
Draw
Definition: vgeometrydef.h:55
#define M_2PI
Definition: vmath.h:27