Go to the documentation of this file.
5 #ifndef GLVERTEX_BEZIER_H
6 #define GLVERTEX_BEZIER_H
19 bool lalign =
true,
bool ralign =
true)
30 bool lalign =
true,
bool ralign =
true)
65 vec2 p12 = (1-w)*p1 + w*p2;
66 vec2 p23 = (1-w)*p2 + w*p3;
67 vec2 p34 = (1-w)*p3 + w*p4;
68 vec2 p123 = (1-w)*p12 + w*p23;
69 vec2 p234 = (1-w)*p23 + w*p34;
70 vec2 p1234 = (1-w)*p123 + w*p234;
87 return((p2-p1)/(ld+rd));
96 for (
int i=1; i<=steps; i++)
109 p2 = p1 + factor*
distance()*direction;
112 left->p3 = left->p4 - factor*left->distance()*direction;
118 p3 = p4 - factor*
distance()*direction;
121 right->p2 = right->p1 + factor*right->distance()*direction;
135 left->p4 = p1 = (left->p4+p1)/2;
139 right->p1 = p4 = (right->p1+p4)/2;
150 if (d > 0) lf1 *= ld/d;
151 if (lf1 > 1) lf1 = 1;
154 if (d > 0) rf1 *= rd/d;
155 if (rf1 > 1) rf1 = 1;
158 if (ld > 0) lf2 *= d/ld;
159 if (lf2 > 1) lf2 = 1;
162 if (rd > 0) rf2 *= d/rd;
163 if (rf2 > 1) rf2 = 1;
166 if (left->p3 == left->p4)
167 left->p3 = left->p4 - factor*lf2*(left->p4-left->p1);
171 p2 = p1 + factor*lf1*(p4-p1);
175 p3 = p4 - factor*rf1*(p4-p1);
178 if (right->p2 == right->p1)
179 right->p2 = right->p1 + factor*rf2*(right->p4-right->p1);
183 vec2 n = nearestPointOnLine(p1, left->p3, p2);
190 vec2 n = nearestPointOnLine(p4, p3, right->p2);
226 bool align_left, align_right;
233 double l = (p-a).
dot(d);
242 {
return(out <<
"curve2D(" << c.p1 <<
", " << c.p2 <<
", " << c.p3 <<
", " << c.p4 <<
")");}
251 bool lalign =
true,
bool ralign =
true)
257 align_right = ralign;
262 bool lalign =
true,
bool ralign =
true)
270 align_right = ralign;
297 vec3 p12 = (1-w)*p1 + w*p2;
298 vec3 p23 = (1-w)*p2 + w*p3;
299 vec3 p34 = (1-w)*p3 + w*p4;
300 vec3 p123 = (1-w)*p12 + w*p23;
301 vec3 p234 = (1-w)*p23 + w*p34;
302 vec3 p1234 = (1-w)*p123 + w*p234;
313 if (mode < 0) rd = 0;
314 if (mode > 0) ld = 0;
319 return((p2-p1)/(ld+rd));
328 for (
int i=1; i<=steps; i++)
341 p2 = p1 + factor*
distance()*direction;
344 left->p3 = left->p4 - factor*left->
distance()*direction;
350 p3 = p4 - factor*
distance()*direction;
353 right->p2 = right->p1 + factor*right->
distance()*direction;
367 left->p4 = p1 = (left->p4+p1)/2;
371 right->p1 = p4 = (right->p1+p4)/2;
382 if (d > 0) lf1 *= ld/d;
383 if (lf1 > 1) lf1 = 1;
386 if (d > 0) rf1 *= rd/d;
387 if (rf1 > 1) rf1 = 1;
390 if (ld > 0) lf2 *= d/ld;
391 if (lf2 > 1) lf2 = 1;
394 if (rd > 0) rf2 *= d/rd;
395 if (rf2 > 1) rf2 = 1;
398 if (left->p3 == left->p4)
399 left->p3 = left->p4 - factor*lf2*(left->p4-left->p1);
403 p2 = p1 + factor*lf1*(p4-p1);
407 p3 = p4 - factor*rf1*(p4-p1);
410 if (right->p2 == right->p1)
411 right->p2 = right->p1 + factor*rf2*(right->p4-right->p1);
415 vec3 n = nearestPointOnLine(p1, left->p3, p2);
422 vec3 n = nearestPointOnLine(p4, p3, right->p2);
462 bool align_left, align_right;
469 double l = (p-a).
dot(d);
478 {
return(out <<
"curve3D(" << c.p1 <<
", " << c.p2 <<
", " << c.p3 <<
", " << c.p4 <<
")");}
486 : std::vector<lgl_BezierCurve2D>()
490 : std::vector<lgl_BezierCurve2D>()
496 : std::vector<lgl_BezierCurve2D>()
502 : std::vector<lgl_BezierCurve2D>()
516 else if (size() == 1)
519 bool lalign = at(0).align_left;
532 vec2 p1 = at(size()-1).p4;
533 bool ralign = at(size()-1).align_right;
549 at(n-1).align_right =
false;
556 addPoint(at(0).p1, at(0).align_left);
565 return(at(0).p1 == at(n-1).p4);
576 return(at(0).
start());
587 return(at(n-1).
end());
598 else if (w > 1) w -= 1;
603 if (n == 0)
return(
vec2(0));
606 int i = (int)floor(s);
621 return(at(i).evaluate(t));
630 if (mode < 0) rd = 0;
631 if (mode > 0) ld = 0;
636 return((p2-p1)/(ld+rd));
645 if (mode < 0) rd = 0;
646 if (mode > 0) ld = 0;
663 for (
int i=0; i<n; i++)
670 void align(
unsigned int index,
vec2 direction,
double factor = (sqrt(2.0)-1)*4/3)
675 at(index).alignLeft(direction, index>0?&at(index-1):(
closed()?&at(size()-1):NULL), factor);
677 at(index-1).alignRight(direction, index<size()?&at(index):(
closed()?&at(0):NULL), factor);
684 align(0, direction, factor);
690 align(size(), direction, factor);
699 for (
int i=0; i<n; i++)
702 at(i).alignCurves(&at(i-1), &at(i+1), factor);
704 at(i).alignCurves(&at(i-1),
closed()?&at(0):NULL, factor);
706 at(i).alignCurves(
closed()?&at(n-1):NULL, &at(i+1), factor);
708 at(i).alignCurves(NULL, NULL, factor);
717 for (
int i=0; i<n; i++)
726 for (
int i=0; i<n; i++)
735 for (
int i=0; i<n; i++)
739 double first(
int steps,
bool *
align = NULL)
743 bool noalign =
false;
745 if (n>0 && !at(0).align_left) noalign =
true;
753 double last(
int steps)
757 double u = 1+0.5/steps;
768 double next(
double w,
int steps,
bool *
align = NULL,
double minstep = 1E-12)
772 double d = 1.0/steps;
776 int a = (int)floor(s);
779 int b = (int)floor(t);
781 for (
int i=a; i<b; i++)
786 if (i<n && at(i).align_right) ralign =
true;
787 if (i+1<n && at(i+1).align_left) lalign =
true;
789 bool noalign = !lalign && !ralign;
796 double u = (double)(i+1)/n;
816 for (
unsigned int i=0; i<p.size(); i++)
818 if (i > 0) out <<
", ";
833 : std::vector<lgl_BezierCurve3D>()
837 : std::vector<lgl_BezierCurve3D>()
843 : std::vector<lgl_BezierCurve3D>()
849 : std::vector<lgl_BezierCurve3D>()
863 else if (size() == 1)
866 bool lalign = at(0).align_left;
879 vec3 p1 = at(size()-1).p4;
880 bool ralign = at(size()-1).align_right;
896 at(n-1).align_right =
false;
903 addPoint(at(0).p1, at(0).align_left);
912 return(at(0).p1 == at(n-1).p4);
923 return(at(0).
start());
934 return(at(n-1).
end());
945 else if (w > 1) w -= 1;
950 if (n == 0)
return(
vec3(0));
953 int i = (int)floor(s);
968 return(at(i).evaluate(t));
977 if (mode < 0) rd = 0;
978 if (mode > 0) ld = 0;
983 return((p2-p1)/(ld+rd));
992 for (
int i=0; i<n; i++)
999 void align(
unsigned int index,
vec2 direction,
double factor = (sqrt(2.0)-1)*4/3)
1001 if (index <= size())
1004 at(index).alignLeft(direction, index>0?&at(index-1):NULL, factor);
1006 at(index-1).alignRight(direction, index<size()?&at(index):NULL, factor);
1014 at(0).alignLeft(direction, NULL, factor);
1021 at(size()-1).alignRight(direction, NULL, factor);
1030 for (
int i=0; i<n; i++)
1033 at(i).alignCurves(&at(i-1), &at(i+1), factor);
1035 at(i).alignCurves(&at(i-1),
closed()?&at(0):NULL, factor);
1037 at(i).alignCurves(
closed()?&at(n-1):NULL, &at(i+1), factor);
1039 at(i).alignCurves(NULL, NULL, factor);
1048 for (
int i=0; i<n; i++)
1057 for (
int i=0; i<n; i++)
1066 for (
int i=0; i<n; i++)
1076 double first(
int steps,
bool *
align = NULL)
1080 bool noalign =
false;
1082 if (n>0 && !at(0).align_left) noalign =
true;
1090 double last(
int steps)
1094 double u = 1+0.5/steps;
1105 double next(
double w,
int steps,
bool *
align = NULL,
double minstep = 1E-12)
1109 double d = 1.0/steps;
1113 int a = (int)floor(s);
1116 int b = (int)floor(t);
1118 for (
int i=a; i<b; i++)
1120 bool lalign =
false;
1121 bool ralign =
false;
1123 if (i<n && at(i).align_right) ralign =
true;
1124 if (i+1<n && at(i+1).align_left) lalign =
true;
1126 bool noalign = !lalign && !ralign;
1131 if (noalign || b>=n)
1133 double u = (double)(i+1)/n;
1135 if (u > w + minstep)
1153 for (
unsigned int i=0; i<p.size(); i++)
1155 if (i > 0) out <<
", ";
1170 : std::vector<lgl_BezierPath2D>()
1174 : std::vector<lgl_BezierPath2D>()
1180 : std::vector<lgl_BezierPath2D>()
1186 : std::vector<lgl_BezierPath2D>()
1194 unsigned int num = 0;
1198 for (
int i=0; i<n; i++)
1199 if (at(i).size() > num)
1210 if (n == 0)
return(
vec2(0));
1217 int p1 = (int)floor(p);
1220 if (p1 < 0) p1 += n;
1223 if (p2 < 0) p2 += n;
1225 vec2 v1 = at(p1).evaluate(w);
1226 vec2 v2 = at(p2).evaluate(w);
1228 t = 0.5*sin((t-0.5)*PI)+0.5;
1230 return((1-t)*v1+t*v2);
1240 if (mode < 0) rd = 0;
1241 if (mode > 0) ld = 0;
1246 return((p2-p1)/(ld+rd));
1250 vec2 normal(
double v,
double w,
int mode = 0,
double d = 0.001)
const
1255 if (mode < 0) rd = 0;
1256 if (mode > 0) ld = 0;
1272 for (
int i=0; i<n; i++)
1281 for (
int i=0; i<n; i++)
1282 at(i).rotate(angle);
1290 for (
int i=0; i<n; i++)
1302 : std::vector<lgl_BezierPath3D>()
1306 : std::vector<lgl_BezierPath3D>()
1312 : std::vector<lgl_BezierPath3D>()
1318 : std::vector<lgl_BezierPath3D>()
1326 unsigned int num = 0;
1330 for (
int i=0; i<n; i++)
1331 if (at(i).size() > num)
1342 if (n == 0)
return(
vec3(0));
1349 int p1 = (int)floor(p);
1352 if (p1 < 0) p1 += n;
1355 if (p2 < 0) p2 += n;
1357 vec3 v1 = at(p1).evaluate(w);
1358 vec3 v2 = at(p2).evaluate(w);
1360 t = 0.5*sin((t-0.5)*PI)+0.5;
1362 return((1-t)*v1+t*v2);
1372 if (mode < 0) rd = 0;
1373 if (mode > 0) ld = 0;
1378 return((p2-p1)/(ld+rd));
1386 for (
int i=0; i<n; i++)
1395 for (
int i=0; i<n; i++)
1404 for (
int i=0; i<n; i++)
1419 out <<
"multipath3D(";
1421 for (
unsigned int i=0; i<m.size(); i++)
1423 if (i > 0) out <<
", ";
1439 p11 = p12 = p21 = p22 =
1440 p13 = p14 = p23 = p24 =
1441 p31 = p32 = p41 = p42 =
1442 p33 = p34 = p43 = p44 =
vec3(0,0,0);
1448 p11 = p12 = p21 = p22 = a;
1449 p13 = p14 = p23 = p24 = b;
1450 p31 = p32 = p41 = p42 = c;
1451 p33 = p34 = p43 = p44 = d;
1459 p11 = a1; p12 = b1; p13 = c1; p14 = d1;
1460 p21 = a2; p22 = b2; p23 = c2; p24 = d2;
1461 p31 = a3; p32 = b3; p33 = c3; p34 = d3;
1462 p41 = a4; p42 = b4; p43 = c4; p44 = d4;
1487 return(0.5*(p2-p1+p4-p3)/d);
1503 vec3 du = p2-p1+p6-p5+p8-p7;
1504 vec3 dv = p4-p3+p7-p8+p6-p5;
1516 double factor = (sqrt(2.0)-1)*4/3)
1518 align(leftbottom, bottom, left,
this, factor);
1519 align(bottom, rightbottom,
this, right, factor);
1520 align(left,
this, lefttop, top, factor);
1521 align(
this, right, top, righttop, factor);
1602 vec3 p11, p12, p13, p14;
1603 vec3 p21, p22, p23, p24;
1604 vec3 p31, p32, p33, p34;
1605 vec3 p41, p42, p43, p44;
1611 double l = (p-o).
dot(n);
1619 if (d ==
vec3(0))
return(nearestPointOnPlane(p1, o, n));
1620 double l = (p1-o).
dot(n) / d.
dot(n);
1627 double factor = (sqrt(2.0)-1)*4/3)
1636 center += leftbottom->p14;
1642 center += rightbottom->p11;
1648 center += lefttop->p44;
1654 center += righttop->p41;
1658 center = center / count;
1663 leftbottom->p14 = center;
1666 rightbottom->p11 = center;
1669 lefttop->p44 = center;
1672 righttop->p41 = center;
1681 left += leftbottom->p11;
1687 left += lefttop->p41;
1691 left = left / leftcount;
1700 right += rightbottom->p14;
1706 right += righttop->p44;
1710 right = right / rightcount;
1715 int bottomcount = 0;
1719 bottom += leftbottom->p44;
1725 bottom += rightbottom->p41;
1729 bottom = bottom / bottomcount;
1738 top += lefttop->p14;
1744 top += righttop->p11;
1748 top = top / topcount;
1753 if (leftbottom->p13 == leftbottom->p14)
1754 leftbottom->p13 = center + factor*(left-center);
1757 if (lefttop->p43 == lefttop->p44)
1758 lefttop->p43 = center + factor*(left-center);
1763 if (rightbottom->p12 == rightbottom->p11)
1764 rightbottom->p12 = center + factor*(right-center);
1767 if (righttop->p42 == righttop->p41)
1768 righttop->p42 = center + factor*(right-center);
1773 if (leftbottom->p24 == leftbottom->p14)
1774 leftbottom->p24 = center + factor*(bottom-center);
1777 if (rightbottom->p21 == rightbottom->p11)
1778 rightbottom->p21 = center + factor*(bottom-center);
1783 if (lefttop->p34 == lefttop->p44)
1784 lefttop->p34 = center + factor*(top-center);
1787 if (righttop->p31 == righttop->p41)
1788 righttop->p31 = center + factor*(top-center);
1797 left += leftbottom->p13;
1803 left += lefttop->p43;
1807 left = left / leftcount;
1811 right =
vec3(0,0,0);
1816 right += rightbottom->p12;
1822 right += righttop->p42;
1826 right = right / rightcount;
1830 bottom =
vec3(0,0,0);
1835 bottom += leftbottom->p24;
1841 bottom += rightbottom->p21;
1845 bottom = bottom / bottomcount;
1854 top += lefttop->p34;
1860 top += righttop->p31;
1864 top = top / topcount;
1869 if (leftcount>0 && rightcount>0) du = right - left;
1870 else if (leftcount > 0) du = center - left;
1871 else du = right - center;
1875 if (bottomcount>0 && topcount>0) dv = top - bottom;
1876 else if (bottomcount > 0) dv = center - bottom;
1877 else dv = top - center;
1884 if (leftcount>0 && rightcount>0) left = projectPointOnPlane(left, right, center, n);
1885 else if (leftcount > 0) left = nearestPointOnPlane(left, center, n);
1887 if (rightcount>0 && leftcount>0) right = projectPointOnPlane(right, left, center, n);
1888 else if (rightcount > 0) right = nearestPointOnPlane(right, center, n);
1890 if (bottomcount>0 && topcount>0) bottom = projectPointOnPlane(bottom, top, center, n);
1891 else if (bottomcount > 0) bottom = nearestPointOnPlane(bottom, center, n);
1893 if (topcount>0 && bottomcount>0) top = projectPointOnPlane(top, bottom, center, n);
1894 else if (topcount > 0) top = nearestPointOnPlane(top, center, n);
1899 leftbottom->p13 = left;
1902 lefttop->p43 = left;
1905 rightbottom->p12 = right;
1908 righttop->p42 = right;
1911 leftbottom->p24 = bottom;
1914 rightbottom->p21 = bottom;
1920 righttop->p31 = top;
1925 if (leftbottom->p23 == leftbottom->p14)
1926 leftbottom->p23 = center + left-center + bottom-center;
1929 if (rightbottom->p22 == rightbottom->p11)
1930 rightbottom->p22 = center + right-center + bottom-center;
1933 if (lefttop->p33 == lefttop->p44)
1934 lefttop->p33 = center + left-center + top-center;
1937 if (righttop->p32 == righttop->p41)
1938 righttop->p32 = center + right-center + top-center;
1943 leftbottom->p23 = nearestPointOnPlane(leftbottom->p23, center, n);
1946 rightbottom->p22 = nearestPointOnPlane(rightbottom->p22, center, n);
1949 lefttop->p33 = nearestPointOnPlane(lefttop->p33, center, n);
1952 righttop->p32 = nearestPointOnPlane(righttop->p32, center, n);
1962 out << p.p11 <<
", " << p.p12 <<
", " << p.p13 <<
", " << p.p14 <<
", ";
1963 out << p.p21 <<
", " << p.p22 <<
", " << p.p23 <<
", " << p.p24 <<
", ";
1964 out << p.p31 <<
", " << p.p32 <<
", " << p.p33 <<
", " << p.p34 <<
", ";
1965 out << p.p41 <<
", " << p.p42 <<
", " << p.p43 <<
", " << p.p44;
1981 if (cols>=2 && rows>=2)
1983 point.resize(cols*rows,
vec3(0,0,0));
1984 patch.resize((cols-1)*(rows-1));
1998 void set(
int i,
int j,
vec3 p)
2000 if (cols>=2 && rows>=2)
2002 point[i+j*cols] = p;
2010 if (cols>=2 && rows>=2)
2012 for (
int i=0; i<cols-1; i++)
2013 for (
int j=0; j<rows-1; j++)
2014 patch[i+j*(cols-1)] =
lgl_BezierPatch(p(i, j+1), p(i+1, j+1), p(i, j), p(i+1, j));
2016 for (
int i=0; i<cols-1; i++)
2017 for (
int j=0; j<rows-1; j++)
2018 P(i, j)->
alignPatches(P(i-1, j), P(i+1, j), P(i, j-1), P(i, j+1),
2019 P(i-1, j-1), P(i+1, j-1), P(i-1, j+1), P(i+1, j+1));
2026 if (cols<2 || rows<2)
2027 return(
vec3(0,0,0));
2039 int i = (int)floor(u);
2040 int j = (int)floor(v);
2081 return(0.5*(p2-p1+p4-p3)/d);
2097 vec3 du = p2-p1+p6-p5+p8-p7;
2098 vec3 dv = p4-p3+p7-p8+p6-p5;
2108 int n = point.size();
2110 for (
int i=0; i<n; i++)
2119 int n = point.size();
2121 for (
int i=0; i<n; i++)
2122 point[i] = q * point[i];
2130 int n = point.size();
2132 for (
int i=0; i<n; i++)
2155 std::vector<vec3> point;
2156 std::vector<lgl_BezierPatch> patch;
2158 vec3 p(
int i,
int j)
2160 return(point[i+j*cols]);
2165 if (i<0 || i>cols-2 || j<0 || j>rows-2)
2168 return(&patch[i+j*(cols-1)]);
2179 for (
unsigned int i=0; i<m.point.size(); i++)
2181 if (i > 0) out <<
", ";
double length(int steps=100) const
compute length of curve
Definition: glvertex_bezier.h:91
void rotate(double angle)
rotate multi-path
Definition: glvertex_bezier.h:1277
vec2 gradient(double w, int mode=0, double d=0.001) const
evaluate the gradient of the 2D bezier path
Definition: glvertex_bezier.h:625
void rotate(double angle, vec3 axis)
rotate multi-path
Definition: glvertex_bezier.h:1409
vec3 normal(double u, double v, double d=0.001) const
compute the normal of the surface patch
Definition: glvertex_bezier.h:1491
vec3 evaluate(double u, double v)
evaluate the bezier mesh
Definition: glvertex_bezier.h:2024
void rotate(double angle, vec3 axis)
rotate path
Definition: glvertex_bezier.h:1071
void scale(vec3 s)
scale patch
Definition: glvertex_bezier.h:1573
void rotate(double angle)
rotate path
Definition: glvertex_bezier.h:722
void straighten()
disable alignment for the last added point
Definition: glvertex_bezier.h:544
void translate(vec2 v)
translate multi-path
Definition: glvertex_bezier.h:1268
vec3 evaluate(double w) const
evaluate the 3D bezier path
Definition: glvertex_bezier.h:940
bool closed() const
is the 3D bezier path a closed path?
Definition: glvertex_bezier.h:907
void translate(vec3 v)
translate multi-path
Definition: glvertex_bezier.h:1382
3D bezier curve
Definition: glvertex_bezier.h:245
unsigned int getMaxCurves() const
get the maximum number of curves in the multi-path
Definition: glvertex_bezier.h:1324
vec3 normal(double u, double v, double d=0.001)
compute the normal of the bezier mesh
Definition: glvertex_bezier.h:2085
vec2 normal(double v, double w, int mode=0, double d=0.001) const
compute the normal of the 2D bezier multi-path
Definition: glvertex_bezier.h:1250
vec2 start()
start point
Definition: glvertex_bezier.h:571
void rotate(quat q)
rotate mesh
Definition: glvertex_bezier.h:2117
vec3 end()
end point
Definition: glvertex_bezier.h:929
void rotate(double angle, vec3 axis)
rotate mesh
Definition: glvertex_bezier.h:2139
vec3 evaluate(double u, double v) const
evaluate the surface patch
Definition: glvertex_bezier.h:1469
double distance()
calculate distance of start and end point
Definition: glvertex_bezier.h:289
lgl_BezierCurve2D(vec2 a, vec2 b, bool lalign=true, bool ralign=true)
create 2D bezier curve from 2 control points
Definition: glvertex_bezier.h:18
vec3 gradient(double v, double w, int mode=0, double d=0.001) const
evaluate the gradient of the 3D bezier multi-path
Definition: glvertex_bezier.h:1367
vec2 gradient(double v, double w, int mode=0, double d=0.001) const
evaluate the gradient of the 2D bezier multi-path
Definition: glvertex_bezier.h:1235
void scale(vec2 s)
scale curve
Definition: glvertex_bezier.h:217
double dot(const vec3 &v) const
inner product
Definition: glslmath.h:429
void rotate(quat q)
rotate curve
Definition: glvertex_bezier.h:438
vec3 normalize() const
normalize vector to unit length
Definition: glslmath.h:528
double length(int steps=100) const
compute length of path
Definition: glvertex_bezier.h:658
2D double vector
Definition: glslmath.h:108
vec3 gradient(double u, double v, double d=0.001)
evaluate the gradient of the bezier mesh
Definition: glvertex_bezier.h:2074
void align(unsigned int index, vec2 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align two consecutive control points of the 3D bezier path
Definition: glvertex_bezier.h:999
bezier mesh consisting of multiple bezier surface patches
Definition: glvertex_bezier.h:1973
void alignLeft(vec2 direction, lgl_BezierCurve2D *left=NULL, double factor=(sqrt(2.0) -1) *4/3)
auto-align the left control point of the 2D bezier curve
Definition: glvertex_bezier.h:107
void translate(vec2 v)
translate curve
Definition: glvertex_bezier.h:197
void translate(vec3 v)
translate curve
Definition: glvertex_bezier.h:429
unsigned int addPoint(vec3 p, bool align=true)
add a point to the 3D bezier path
Definition: glvertex_bezier.h:856
vec2 evaluate(double w) const
evaluate the 2D bezier path
Definition: glvertex_bezier.h:593
std::ostream & operator<<(std::ostream &out, const lgl_BezierCurve2D &c)
output operator
Definition: glvertex_bezier.h:241
void close()
close the 3D bezier path by reduplicating the first point
Definition: glvertex_bezier.h:900
vec3 gradient(double w, int mode=0, double d=0.001) const
evaluate the gradient of the 3D bezier curve
Definition: glvertex_bezier.h:308
3D bezier path consisting of multiple bezier curves
Definition: glvertex_bezier.h:828
void alignLeft(vec2 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align the left-most control point of the 2D bezier path
Definition: glvertex_bezier.h:682
void scale(vec3 s)
scale curve
Definition: glvertex_bezier.h:447
bezier surface patch
Definition: glvertex_bezier.h:1433
void alignCurves(double factor=(sqrt(2.0) -1) *4/3)
auto-align the curves of the 2D bezier path
Definition: glvertex_bezier.h:694
void scale(vec3 s)
scale multi-path
Definition: glvertex_bezier.h:1400
vec2 normalize() const
normalize vector to unit length
Definition: glslmath.h:229
void translate(vec3 v)
translate path
Definition: glvertex_bezier.h:1044
void alignRight(vec3 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align the right-most control point of the 3D bezier path
Definition: glvertex_bezier.h:1018
void rotate(quat q)
rotate path
Definition: glvertex_bezier.h:1053
void alignLeft(vec3 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align the left-most control point of the 3D bezier path
Definition: glvertex_bezier.h:1011
vec2 end()
end point
Definition: glvertex_bezier.h:51
void translate(vec3 v)
translate mesh
Definition: glvertex_bezier.h:2106
3D double vector
Definition: glslmath.h:372
container for linear interpolation of 2D bezier paths
Definition: glvertex_bezier.h:1165
2x2 double matrix
Definition: glslmath.h:1130
void alignCurves(lgl_BezierCurve2D *left, lgl_BezierCurve2D *right, double factor=(sqrt(2.0) -1) *4/3)
auto-align the control points of the 2D bezier curve
Definition: glvertex_bezier.h:125
void translate(vec3 v)
translate patch
Definition: glvertex_bezier.h:1525
void scale(vec2 s)
scale multi-path
Definition: glvertex_bezier.h:1286
2D bezier curve
Definition: glvertex_bezier.h:13
unsigned int addPoint(vec2 p, bool align=true)
add a point to the 2D bezier path
Definition: glvertex_bezier.h:509
lgl_BezierCurve3D(vec3 a, vec3 b, bool lalign=true, bool ralign=true)
create 3D bezier curve from 2 control points
Definition: glvertex_bezier.h:250
vec3 evaluate(double v, double w) const
evaluate the 3D bezier multi-path
Definition: glvertex_bezier.h:1338
void alignRight(vec2 direction, lgl_BezierCurve2D *right=NULL, double factor=(sqrt(2.0) -1) *4/3)
auto-align the right control point of the 2D bezier curve
Definition: glvertex_bezier.h:116
vec3 gradient(double u, double v, double d=0.001) const
evaluate the gradient of the surface patch
Definition: glvertex_bezier.h:1480
vec2 evaluate(double v, double w) const
evaluate the 2D bezier multi-path
Definition: glvertex_bezier.h:1206
void alignPatches(lgl_BezierPatch *left, lgl_BezierPatch *right, lgl_BezierPatch *bottom, lgl_BezierPatch *top, lgl_BezierPatch *leftbottom, lgl_BezierPatch *rightbottom, lgl_BezierPatch *lefttop, lgl_BezierPatch *righttop, double factor=(sqrt(2.0) -1) *4/3)
auto-align the control points of the surface patch
Definition: glvertex_bezier.h:1512
vec2 gradient(double w, int mode=0, double d=0.001) const
evaluate the gradient of the 2D bezier curve
Definition: glvertex_bezier.h:76
void scale(vec2 s)
scale path
Definition: glvertex_bezier.h:731
vec3 cross(const vec3 &v) const
cross product (0,0,-1)/(-1,0,0)=(0,1,0)
Definition: glslmath.h:433
unsigned int getMaxCurves() const
get the maximum number of curves in the multi-path
Definition: glvertex_bezier.h:1192
friend std::ostream & operator<<(std::ostream &out, const lgl_BezierMesh &m)
output operator
Definition: glvertex_bezier.h:2175
void alignCurves(lgl_BezierCurve3D *left, lgl_BezierCurve3D *right, double factor=(sqrt(2.0) -1) *4/3)
auto-align the control points of the 3D bezier curve
Definition: glvertex_bezier.h:357
static quat rotate(double angle, const vec3 &v)
create rotating quaternion
Definition: glslmath.h:3036
vec3 evaluate(double w) const
evaluate the 3D bezier curve
Definition: glvertex_bezier.h:295
lgl_BezierCurve2D(vec2 a, vec2 b, vec2 c, vec2 d, bool lalign=true, bool ralign=true)
create 2D bezier curve from 4 control points
Definition: glvertex_bezier.h:29
void scale(vec3 s)
scale path
Definition: glvertex_bezier.h:1062
quaternion
Definition: glslmath.h:2972
void align()
auto-align the bezier surface patches
Definition: glvertex_bezier.h:2008
void alignRight(vec3 direction, lgl_BezierCurve3D *right=NULL, double factor=(sqrt(2.0) -1) *4/3)
auto-align the right control point of the 3D bezier curve
Definition: glvertex_bezier.h:348
void straighten()
disable alignment for the last added point
Definition: glvertex_bezier.h:891
vec3 start()
start point
Definition: glvertex_bezier.h:277
double dot(const vec2 &a, const vec2 &b)
inner product
Definition: glslmath.h:241
vec3 gradient(double w, int mode=0, double d=0.001) const
evaluate the gradient of the 3D bezier path
Definition: glvertex_bezier.h:972
vec2 end()
end point
Definition: glvertex_bezier.h:582
vec3 start()
start point
Definition: glvertex_bezier.h:918
lgl_BezierCurve3D(vec3 a, vec3 b, vec3 c, vec3 d, bool lalign=true, bool ralign=true)
create 3D bezier curve from 4 control points
Definition: glvertex_bezier.h:261
void alignLeft(vec3 direction, lgl_BezierCurve3D *left=NULL, double factor=(sqrt(2.0) -1) *4/3)
auto-align the left control point of the 3D bezier curve
Definition: glvertex_bezier.h:339
void alignCurves(double factor=(sqrt(2.0) -1) *4/3)
auto-align the curves of the 3D bezier path
Definition: glvertex_bezier.h:1025
void rotate(quat q)
rotate multi-path
Definition: glvertex_bezier.h:1391
void scale(vec3 s)
scale mesh
Definition: glvertex_bezier.h:2128
vec2 normalize(const vec2 &v)
normalization to unit length
Definition: glslmath.h:237
void rotate(double angle, vec3 axis)
rotate patch
Definition: glvertex_bezier.h:1597
double length(int steps=100) const
compute length of path
Definition: glvertex_bezier.h:987
vec2 normal(double w, int mode=0, double d=0.001) const
compute the normal of the 2D bezier path
Definition: glvertex_bezier.h:640
vec2 evaluate(double w) const
evaluate the 2D bezier curve
Definition: glvertex_bezier.h:63
void align(unsigned int index, vec2 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align two consecutive control points of the 2D bezier path
Definition: glvertex_bezier.h:670
static mat2 rotate(double angle)
create rotation matrix
Definition: glslmath.h:1295
void rotate(quat q)
rotate patch
Definition: glvertex_bezier.h:1549
vec2 start()
start point
Definition: glvertex_bezier.h:45
2D bezier path consisting of multiple bezier curves
Definition: glvertex_bezier.h:481
void rotate(double angle, vec3 axis)
rotate curve
Definition: glvertex_bezier.h:456
void translate(vec2 v)
translate path
Definition: glvertex_bezier.h:713
void rotate(double angle)
rotate curve
Definition: glvertex_bezier.h:206
double length(int steps=100) const
compute length of curve
Definition: glvertex_bezier.h:323
vec3 end()
end point
Definition: glvertex_bezier.h:283
void close()
close the 2D bezier path by reduplicating the first point
Definition: glvertex_bezier.h:553
bool closed() const
is the 2D bezier path a closed path?
Definition: glvertex_bezier.h:560
container for linear interpolation of 3D bezier paths
Definition: glvertex_bezier.h:1297
void alignRight(vec2 direction, double factor=(sqrt(2.0) -1) *4/3)
auto-align the right-most control point of the 2D bezier path
Definition: glvertex_bezier.h:688
double distance()
calculate distance of start and end point
Definition: glvertex_bezier.h:57