10#include <private/qnumeric_p.h>
81 d =
qAbs( (x4x1)*(
b->y1 -
b->y2) - (y4y1)*(
b->x1 -
b->x2) )
82 +
qAbs( (x4x1)*(
b->y1 -
b->y3) - (y4y1)*(
b->x1 -
b->x3) );
88 if (
d < bezier_flattening_threshold * l ||
levels[
top] == 0) {
94 std::tie(
b[1],
b[0]) =
b->split();
117 d =
qAbs( (x4x1)*(
b->y1 -
b->y2) - (y4y1)*(
b->x1 -
b->x2) )
118 +
qAbs( (x4x1)*(
b->y1 -
b->y3) - (y4y1)*(
b->x1 -
b->x3) );
124 if (
d < bezier_flattening_threshold * l ||
levels[
top] == 0) {
130 std::tie(
b[1],
b[0]) =
b->split();
142 res.reserve((numInfPoints + 1) * 3 * 2);
145 for (
int i = 0;
i < numInfPoints + 1;
i++) {
146 qreal t1 = (
i < numInfPoints) ? infPoints[
i] : 1;
157 const QRectF bounds =
b.bounds();
162 const QPointF cp1 =
b.pt1() +
f * (qcp -
b.pt1());
163 const QPointF cp2 =
b.pt4() +
f * (qcp -
b.pt4());
166 return qMax(
d1.length(),
d2.length()) / dim;
172 const QLineF st =
b.startTangent();
173 const QLineF et =
b.endTangent();
181 Q_ASSERT((tspan > 0) && !(tspan > 1));
182 static constexpr qreal MinimumTSpan = 0.1;
185 if (tspan < MinimumTSpan ||
scoreQuadratic(*
this, qcp) < errorLimit) {
189 std::pair<QBezier, QBezier> halves =
split();
190 halves.first.addToQuadratics(
p, tspan / 2, errorLimit);
191 halves.second.addToQuadratics(
p, tspan / 2, errorLimit);
197 auto isValidRoot = [](
qreal r) {
210 const qreal p =
n.pt3().x() *
n.pt2().y();
211 const qreal q =
n.pt4().x() *
n.pt2().y();
212 const qreal r =
n.pt2().x() *
n.pt3().y();
213 const qreal s =
n.pt4().x() *
n.pt3().y();
215 const qreal a = 36 * ((-3 *
p) + (2 *
q) + (3 *
r) -
s);
218 const qreal b = -18 * (((3 *
p) -
q) - (3 *
r));
224 const qreal root1 = (
b + sqr) /
a;
225 const qreal root2 = (
b - sqr) /
a;
228 if (isValidRoot(root1))
229 tpoints[
res++] = root1;
231 tpoints[
res++] = root2;
233 if (
res == 2 && tpoints[0] > tpoints[1])
234 qSwap(tpoints[0], tpoints[1]);
270 return QRectF(xmin, ymin, xmax-xmin, ymax-ymin);
286 const int divisions = 4;
289 for (
int i = 1;
i < divisions; ++
i,
t +=
spacing) {
293 if (
qAbs(
d - o2) > max_dist_line)
298 if (l !=
qreal(0.0)) {
299 d =
qAbs( normalPoint.
x()*(
p1.y() -
p2.y()) - normalPoint.
y()*(
p1.x() -
p2.x()) ) / l;
300 if (
d > max_dist_normal)
342 (orig->
y1 - orig->
y2)*(orig->
y1 - orig->
y2) *
343 (orig->
x3 - orig->
x4)*(orig->
x3 - orig->
x4) +
344 (orig->
y3 - orig->
y4)*(orig->
y3 - orig->
y4);
346 (orig->
y1 - orig->
y2)*(orig->
y3 - orig->
y4);
362 for (
int i = 1;
i < np - 1; ++
i) {
364 QPointF next_normal =
next.normalVector().unitVector().p2();
366 QPointF normal_sum = prev_normal + next_normal;
369 + prev_normal.
y() * next_normal.
y();
375 points_shifted[
i] =
points[
i] + k * normal_sum;
378 prev_normal = next_normal;
381 points_shifted[np - 1] =
points[np - 1] +
offset * prev_normal;
384 points_shifted[
map[2]], points_shifted[
map[3]]);
394#define KAPPA qreal(0.5522847498)
401 normals[0] =
QPointF(
b->y2 -
b->y1,
b->x1 -
b->x2);
406 normals[2] =
QPointF(
b->y4 -
b->y3,
b->x3 -
b->x4);
407 dist =
qSqrt(normals[2].
x()*normals[2].
x() + normals[2].
y()*normals[2].
y());
412 normals[1] =
QPointF(
b->x1 -
b->x2 -
b->x3 +
b->x4,
b->y1 -
b->y2 -
b->y3 +
b->y4);
413 normals[1] /= -1*
qSqrt(normals[1].
x()*normals[1].
x() + normals[1].
y()*normals[1].
y());
417 for (
int i = 0;
i < 2; ++
i) {
418 qreal cos_a = normals[
i].
x()*normals[
i+1].
x() + normals[
i].
y()*normals[
i+1].
y();
426 if (angles[0] + angles[1] > 1.) {
428 normals[1] = -normals[1];
429 angles[0] = 1. - angles[0];
430 angles[1] = 1. - angles[1];
440 for (
int i = 0;
i < 2; ++
i) {
443 o->x1 = circle[
i].
x();
444 o->y1 = circle[
i].
y();
445 o->x2 = circle[
i].
x() - normals[
i].
y()*kappa;
446 o->y2 = circle[
i].
y() + normals[
i].
x()*kappa;
447 o->x3 = circle[
i+1].
x() + normals[
i+1].
y()*kappa;
448 o->y3 = circle[
i+1].
y() - normals[
i+1].
x()*kappa;
449 o->x4 = circle[
i+1].
x();
450 o->y4 = circle[
i+1].
y();
473 while (
b >= beziers) {
474 int stack_segments =
b - beziers + 1;
475 if ((stack_segments == 10) || (
o - curveSegments == maxSegments - stack_segments)) {
476 threshold *=
qreal(1.5);
477 if (threshold >
qreal(2.0))
484 }
else if (
res ==
Ok) {
487 }
else if (
res ==
Circle && maxSegments - (
o - curveSegments) >= 2) {
493 std::tie(
b[1],
b[0]) =
b->split();
499 while (
b >= beziers) {
509 Q_ASSERT(
o - curveSegments <= maxSegments);
510 return o - curveSegments;
516 dbg <<
'[' <<
bz.x1<<
", " <<
bz.y1 <<
"], "
517 <<
'[' <<
bz.x2 <<
", " <<
bz.y2 <<
"], "
518 <<
'[' <<
bz.x3 <<
", " <<
bz.y3 <<
"], "
519 <<
'[' <<
bz.x4 <<
", " <<
bz.y4 <<
']';
545 const auto halves =
split();
613 return t0 > 0 &&
t0 < 1;
620 return t0 > 0 &&
t0 < 1;
621 }
else if (reciprocal > 0) {
624 t0 = (-
b - temp)/(2*
a);
625 t1 = (-
b + temp)/(2*
a);
633 if (
t0 > 0 &&
t0 < 1)
635 if (
t1 > 0 &&
t1 < 1)
669 t += (lastBigger -
t) *
qreal(0.5);
682 if (
t0 == 0 &&
t1 == 1)
qreal tForY(qreal t0, qreal t1, qreal y) const
static QBezier fromPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
std::pair< QBezier, QBezier > split() const
QPointF pointAt(qreal t) const
void parameterSplitLeft(qreal t, QBezier *left)
qreal tAtLength(qreal len) const
QPolygonF toPolygon(qreal bezier_flattening_threshold=0.5) const
int shifted(QBezier *curveSegments, int maxSegmets, qreal offset, float threshold) const
int inflectionPoints(qreal *tpoints) const
QBezier bezierOnInterval(qreal t0, qreal t1) const
static void coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &d)
int stationaryYPoints(qreal &t0, qreal &t1) const
QBezier mapBy(const QTransform &transform) const
qreal length(qreal error=0.01) const
void addToQuadratics(QPolygonF *p, qreal tspan=1.0, qreal errorLimit=0.2) const
QPointF normalVector(qreal t) const
void addIfClose(qreal *length, qreal error) const
void addToPolygon(QPolygonF *p, qreal bezier_flattening_threshold=0.5) const
QPolygonF toQuadratics(qreal errorLimit=0.2) const
QBezier getSubRange(qreal t0, qreal t1) const
QLineF unitVector() const
Returns the unit vector for this line, i.e a line starting at the same point as this line with a leng...
qreal length() const
Returns the length of the line.
IntersectionType intersects(const QLineF &l, QPointF *intersectionPoint=nullptr) const
constexpr QLineF normalVector() const
Returns a line that is perpendicular to this line with the same starting point and length.
constexpr QPointF p2() const
Returns the line's end point.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtCore\reentrant
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
static QPointF quadraticForCubic(const QBezier &b)
static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offset, qreal threshold)
static qreal scoreQuadratic(const QBezier &b, QPointF qcp)
static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
#define QT_WARNING_DISABLE_FLOAT_COMPARE
DBusConnection const char DBusError * error
bool qIsFinite(qfloat16 f) noexcept
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
qfloat16 qSqrt(qfloat16 f)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLenum GLuint GLintptr offset
GLuint GLenum GLenum transform
GLfixed GLfixed GLint GLint GLfixed points
GLfixed GLfixed GLfixed y2
GLdouble GLdouble GLdouble GLdouble q
static qreal dot(const QPointF &a, const QPointF &b)
std::uniform_real_distribution dist(1, 2.5)
[2]