1 # Created by Octave 3.6.1, Wed Apr 04 09:02:21 2012 UTC <root@t61>
13 # name: <cell-element>
17 BASISFUN: Basis function for B-Spline
21 N = basisfun(iv,uv,p,U)
25 iv - knot span ( from FindSpan() )
26 uv - parametric points
32 N - Basis functions vector(numel(uv)*(p+1))
34 Adapted from Algorithm A2.2 from 'The NURBS BOOK' pg70.
36 Copyright (C) 2000 Mark Spink
37 Copyright (C) 2007 Daniel Claxton
38 Copyright (C) 2009 Carlo de Falco
40 This program is free software: you can redistribute it and/or modify
41 it under the terms of the GNU General Public License as published by
42 the Free Software Foundation, either version 2 of the License, or
43 (at your option) any later version.
47 # name: <cell-element>
51 BASISFUN: Basis function for B-Spline
56 # name: <cell-element>
63 # name: <cell-element>
67 BASISFUNDER: B-Spline Basis function derivatives.
71 ders = basisfunder (ii, pl, uu, k, nd)
75 ii - knot span index (see findspan)
77 uu - parametric points
79 nd - number of derivatives to compute
83 ders - ders(n, i, :) (i-1)-th derivative at n-th point
85 Adapted from Algorithm A2.3 from 'The NURBS BOOK' pg72.
87 Copyright (C) 2009,2011 Rafael Vazquez
89 This program is free software: you can redistribute it and/or modify
90 it under the terms of the GNU General Public License as published by
91 the Free Software Foundation, either version 2 of the License, or
92 (at your option) any later version.
96 # name: <cell-element>
100 BASISFUNDER: B-Spline Basis function derivatives.
104 # name: <cell-element>
111 # name: <cell-element>
115 BSPDEGELEV: Degree elevate a univariate B-Spline.
119 [ic,ik] = bspdegelev(d,c,k,t)
123 d - Degree of the B-Spline.
124 c - Control points, matrix of size (dim,nc).
125 k - Knot sequence, row vector of size nk.
126 t - Raise the B-Spline degree t times.
130 ic - Control points of the new B-Spline.
131 ik - Knot vector of the new B-Spline.
133 Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton
135 This program is free software: you can redistribute it and/or modify
136 it under the terms of the GNU General Public License as published by
137 the Free Software Foundation, either version 2 of the License, or
138 (at your option) any later version.
142 # name: <cell-element>
146 BSPDEGELEV: Degree elevate a univariate B-Spline.
150 # name: <cell-element>
157 # name: <cell-element>
161 BSPDERIV: B-Spline derivative.
165 [dc,dk] = bspderiv(d,c,k)
169 d - degree of the B-Spline
170 c - control points double matrix(mc,nc)
171 k - knot sequence double vector(nk)
175 dc - control points of the derivative double matrix(mc,nc)
176 dk - knot sequence of the derivative double vector(nk)
178 Modified version of Algorithm A3.3 from 'The NURBS BOOK' pg98.
180 Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton
182 This program is free software: you can redistribute it and/or modify
183 it under the terms of the GNU General Public License as published by
184 the Free Software Foundation, either version 2 of the License, or
185 (at your option) any later version.
189 # name: <cell-element>
193 BSPDERIV: B-Spline derivative.
197 # name: <cell-element>
204 # name: <cell-element>
208 BSPEVAL: Evaluate B-Spline at parametric points.
216 d - Degree of the B-Spline.
217 c - Control Points, matrix of size (dim,nc).
218 k - Knot sequence, row vector of size nk.
219 u - Parametric evaluation points, row vector of size nu.
223 p - Evaluated points, matrix of size (dim,nu)
225 Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton, 2010 C. de Falco
227 This program is free software: you can redistribute it and/or modify
228 it under the terms of the GNU General Public License as published by
229 the Free Software Foundation, either version 2 of the License, or
230 (at your option) any later version.
234 # name: <cell-element>
238 BSPEVAL: Evaluate B-Spline at parametric points.
242 # name: <cell-element>
249 # name: <cell-element>
253 BSPKNTINS: Insert knots into a B-Spline
257 [ic,ik] = bspkntins(d,c,k,u)
261 d - spline degree integer
262 c - control points double matrix(mc,nc)
263 k - knot sequence double vector(nk)
264 u - new knots double vector(nu)
268 ic - new control points double matrix(mc,nc+nu)
269 ik - new knot sequence double vector(nk+nu)
271 Modified version of Algorithm A5.4 from 'The NURBS BOOK' pg164.
273 Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton, 2010 Rafael Vazquez
275 This program is free software: you can redistribute it and/or modify
276 it under the terms of the GNU General Public License as published by
277 the Free Software Foundation, either version 2 of the License, or
278 (at your option) any later version.
282 # name: <cell-element>
286 BSPKNTINS: Insert knots into a B-Spline
291 # name: <cell-element>
298 # name: <cell-element>
302 Compute control points of n-th derivatives of a B-spline curve.
304 usage: pk = curvederivcpts (n, p, U, P, d)
305 pk = curvederivcpts (n, p, U, P, d, r1, r2)
307 If r1, r2 are not given, all the control points are computed.
310 n+1 = number of control points
311 p = degree of the spline
312 d = maximum derivative order (d<=p)
315 r1 = first control point to compute
316 r2 = auxiliary index for the last control point to compute
318 pk(k,i) = i-th control point of (k-1)-th derivative, r1 <= i <= r2-k
320 Adaptation of algorithm A3.3 from the NURBS book, pg98.
322 Copyright (C) 2009 Carlo de Falco
324 This program is free software: you can redistribute it and/or modify
325 it under the terms of the GNU General Public License as published by
326 the Free Software Foundation, either version 2 of the License, or
327 (at your option) any later version.
331 # name: <cell-element>
335 Compute control points of n-th derivatives of a B-spline curve.
339 # name: <cell-element>
346 # name: <cell-element>
351 CURVEDERIVEVAL: Compute the derivatives of a B-spline curve.
353 usage: ck = curvederiveval (n, p, U, P, u, d)
357 n+1 = number of control points
366 ck (k+1) = curve differentiated k times
368 Adaptation of algorithm A3.4 from the NURBS book, pg99
370 Copyright (C) 2009 Carlo de Falco
371 Copyright (C) 2010 Rafael Vazquez
373 This program is free software: you can redistribute it and/or modify
374 it under the terms of the GNU General Public License as published by
375 the Free Software Foundation, either version 2 of the License, or
376 (at your option) any later version.
380 # name: <cell-element>
385 CURVEDERIVEVAL: Compute the derivatives of a B-spline curve.
389 # name: <cell-element>
396 # name: <cell-element>
400 DEG2RAD: Convert degrees to radians.
408 deg : Angle in degrees.
412 rad : Angle in radians.
416 Convenient utility function for converting degrees to radians, which are
417 often the required angular units for functions in the NURBS toolbox.
421 // Convert 35 degrees to radians
424 Copyright (C) 2000 Mark Spink
426 This program is free software: you can redistribute it and/or modify
427 it under the terms of the GNU General Public License as published by
428 the Free Software Foundation, either version 2 of the License, or
429 (at your option) any later version.
433 # name: <cell-element>
437 DEG2RAD: Convert degrees to radians.
441 # name: <cell-element>
448 # name: <cell-element>
452 FINDSPAN Find the span of a B-Spline knot vector at a parametric point
456 s = findspan(n,p,u,U)
460 n - number of control points - 1
469 Modification of Algorithm A2.1 from 'The NURBS BOOK' pg68
471 Copyright (C) 2010 Rafael Vazquez
473 This program is free software: you can redistribute it and/or modify
474 it under the terms of the GNU General Public License as published by
475 the Free Software Foundation, either version 2 of the License, or
476 (at your option) any later version.
480 # name: <cell-element>
484 FINDSPAN Find the span of a B-Spline knot vector at a parametric point
489 # name: <cell-element>
496 # name: <cell-element>
500 KNTBRKDEGMULT: Construct an open knot vector by giving the sequence of
501 knots, the degree and the multiplicity.
503 knots = kntbrkdegreg (breaks, degree)
504 knots = kntbrkdegreg (breaks, degree, mult)
508 breaks: sequence of knots.
509 degree: polynomial degree of the splines associated to the knot vector.
510 mult: multiplicity of the knots.
516 If MULT has as many entries as BREAKS, or as the number of interior
517 knots, a different multiplicity will be assigned to each knot. If
518 MULT is not present, it will be taken equal to 1.
520 Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
522 This program is free software: you can redistribute it and/or modify
523 it under the terms of the GNU General Public License as published by
524 the Free Software Foundation, either version 2 of the License, or
525 (at your option) any later version.
529 # name: <cell-element>
533 KNTBRKDEGMULT: Construct an open knot vector by giving the sequence of
538 # name: <cell-element>
545 # name: <cell-element>
549 KNTBRKDEGREG: Construct an open knot vector by giving the sequence of
550 knots, the degree and the regularity.
552 knots = kntbrkdegreg (breaks, degree)
553 knots = kntbrkdegreg (breaks, degree, regularity)
557 breaks: sequence of knots.
558 degree: polynomial degree of the splines associated to the knot vector.
559 regularity: splines regularity.
565 If REGULARITY has as many entries as BREAKS, or as the number of interior
566 knots, a different regularity will be assigned to each knot. If
567 REGULARITY is not present, it will be taken equal to DEGREE-1.
569 Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
571 This program is free software: you can redistribute it and/or modify
572 it under the terms of the GNU General Public License as published by
573 the Free Software Foundation, either version 2 of the License, or
574 (at your option) any later version.
578 # name: <cell-element>
582 KNTBRKDEGREG: Construct an open knot vector by giving the sequence of
587 # name: <cell-element>
594 # name: <cell-element>
598 KNTREFINE: Refine a given knot vector by dividing each interval uniformly,
599 maintaining the continuity in previously existing knots.
601 [rknots] = kntrefine (knots, n_sub, degree, regularity)
602 [rknots, zeta] = kntrefine (knots, n_sub, degree, regularity)
603 [rknots, zeta, new_knots] = kntrefine (knots, n_sub, degree, regularity)
607 knots: initial knot vector.
608 n_sub: number of new knots to be added in each interval.
609 degree: polynomial degree of the refined knot vector
610 regularity: maximum global regularity
614 rknots: refined knot vector
615 zeta: refined knot vector without repetitions
616 new_knots: new knots, to apply the knot insertion
618 The regularity at the new inserted knots is the one given by the user.
619 At previously existing knots, the regularity is the minimum
620 between the previous regularity, and the one given by the user.
621 This ensures optimal convergence rates in the context of IGA.
623 Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
625 This program is free software: you can redistribute it and/or modify
626 it under the terms of the GNU General Public License as published by
627 the Free Software Foundation, either version 2 of the License, or
628 (at your option) any later version.
632 # name: <cell-element>
636 KNTREFINE: Refine a given knot vector by dividing each interval uniformly,
641 # name: <cell-element>
648 # name: <cell-element>
652 KNTUNIFORM: generate uniform open knot vectors in the reference domain.
654 [csi, zeta] = kntuniform (num, degree, regularity)
658 num: number of breaks (in each direction)
659 degree: polynomial degree (in each direction)
660 regularity: global regularity (in each direction)
665 zeta: breaks = knots without repetitions
667 Copyright (C) 2009, 2010 Carlo de Falco
668 Copyright (C) 2011 Rafael Vazquez
670 This program is free software: you can redistribute it and/or modify
671 it under the terms of the GNU General Public License as published by
672 the Free Software Foundation, either version 2 of the License, or
673 (at your option) any later version.
677 # name: <cell-element>
681 KNTUNIFORM: generate uniform open knot vectors in the reference domain.
685 # name: <cell-element>
692 # name: <cell-element>
697 NRB4SURF: Constructs a NURBS bilinear surface.
701 srf = nrb4surf(p11,p12,p21,p22)
705 p11 : Cartesian coordinate of the lhs bottom corner point.
707 p12 : Cartesian coordinate of the rhs bottom corner point.
709 p21 : Cartesian coordinate of the lhs top corner point.
711 p22 : Cartesian coordinate of the rhs top corner point.
715 srf : NURBS bilinear surface, see nrbmak.
719 Constructs a bilinear surface defined by four coordinates.
721 The position of the corner points
731 -------------------> U direction
734 Copyright (C) 2000 Mark Spink
736 This program is free software: you can redistribute it and/or modify
737 it under the terms of the GNU General Public License as published by
738 the Free Software Foundation, either version 2 of the License, or
739 (at your option) any later version.
743 # name: <cell-element>
748 NRB4SURF: Constructs a NURBS bilinear surface.
752 # name: <cell-element>
759 # name: <cell-element>
763 NRBBASISFUN: Basis functions for NURBS
767 B = nrbbasisfun (u, crv)
768 B = nrbbasisfun ({u, v}, srf)
769 [B, N] = nrbbasisfun ({u, v}, srf)
770 [B, N] = nrbbasisfun (p, srf)
774 u or p(1,:,:) - parametric points along u direction
775 v or p(2,:,:) - parametric points along v direction
781 B - Value of the basis functions at the points
782 size(B)=[numel(u),(p+1)] for curves
783 or [numel(u)*numel(v), (p+1)*(q+1)] for surfaces
785 N - Indices of the basis functions that are nonvanishing at each
786 point. size(N) == size(B)
789 Copyright (C) 2009 Carlo de Falco
791 This program is free software: you can redistribute it and/or modify
792 it under the terms of the GNU General Public License as published by
793 the Free Software Foundation, either version 2 of the License, or
794 (at your option) any later version.
798 # name: <cell-element>
802 NRBBASISFUN: Basis functions for NURBS
807 # name: <cell-element>
814 # name: <cell-element>
818 NRBBASISFUNDER: NURBS basis functions derivatives
822 Bu = nrbbasisfunder (u, crv)
823 [Bu, N] = nrbbasisfunder (u, crv)
824 [Bu, Bv] = nrbbasisfunder ({u, v}, srf)
825 [Bu, Bv, N] = nrbbasisfunder ({u, v}, srf)
826 [Bu, Bv, N] = nrbbasisfunder (p, srf)
830 u or p(1,:,:) - parametric points along u direction
831 v or p(2,:,:) - parametric points along v direction
837 Bu - Basis functions derivatives WRT direction u
838 size(Bu)=[numel(u),(p+1)] for curves
839 or [numel(u)*numel(v), (p+1)*(q+1)] for surfaces
841 Bv - Basis functions derivatives WRT direction v
842 size(Bv)=[numel(v),(p+1)] for curves
843 or [numel(u)*numel(v), (p+1)*(q+1)] for surfaces
845 N - Indices of the basis functions that are nonvanishing at each
846 point. size(N) == size(B)
848 Copyright (C) 2009 Carlo de Falco
850 This program is free software: you can redistribute it and/or modify
851 it under the terms of the GNU General Public License as published by
852 the Free Software Foundation, either version 2 of the License, or
853 (at your option) any later version.
857 # name: <cell-element>
861 NRBBASISFUNDER: NURBS basis functions derivatives
866 # name: <cell-element>
873 # name: <cell-element>
878 NRBCIRC: Construct a circular arc.
883 crv = nrbcirc(radius)
884 crv = nrbcirc(radius,center)
885 crv = nrbcirc(radius,center,sang,eang)
889 radius : Radius of the circle, default 1.0
891 center : Center of the circle, default (0,0,0)
893 sang : Start angle, default 0 radians (0 degrees)
895 eang : End angle, default 2*pi radians (360 degrees)
899 crv : NURBS curve for a circular arc.
903 Constructs NURBS data structure for a circular arc in the x-y plane. If
904 no rhs arguments are supplied a unit circle with center (0.0,0.0) is
907 Angles are defined as positive in the anti-clockwise direction.
909 Copyright (C) 2000 Mark Spink
911 This program is free software: you can redistribute it and/or modify
912 it under the terms of the GNU General Public License as published by
913 the Free Software Foundation, either version 2 of the License, or
914 (at your option) any later version.
918 # name: <cell-element>
923 NRBCIRC: Construct a circular arc.
927 # name: <cell-element>
934 # name: <cell-element>
939 NRBCOONS: Construction of a Coons patch.
943 srf = nrbcoons(ucrv1, ucrv2, vcrv1, vcrv2)
947 ucrv1 : NURBS curve defining the bottom U direction boundary of
948 the constructed NURBS surface.
950 ucrv2 : NURBS curve defining the top U direction boundary of
951 the constructed NURBS surface.
953 vcrv1 : NURBS curve defining the bottom V direction boundary of
954 the constructed NURBS surface.
956 vcrv2 : NURBS curve defining the top V direction boundary of
957 the constructed NURBS surface.
961 srf : Coons NURBS surface patch.
965 Construction of a bilinearly blended Coons surface patch from four NURBS
966 curves that define the boundary.
968 The orientation of the four NURBS boundary curves.
976 vcrv1 ^ Surface ^ vcrv2
979 ------->-----------> U direction
985 // Define four NURBS curves and construct a Coons surface patch.
986 pnts = [ 0.0 3.0 4.5 6.5 8.0 10.0;
987 0.0 0.0 0.0 0.0 0.0 0.0;
988 2.0 2.0 7.0 4.0 7.0 9.0];
989 crv1 = nrbmak(pnts, [0 0 0 1/3 0.5 2/3 1 1 1]);
991 pnts= [ 0.0 3.0 5.0 8.0 10.0;
992 10.0 10.0 10.0 10.0 10.0;
993 3.0 5.0 8.0 6.0 10.0];
994 crv2 = nrbmak(pnts, [0 0 0 1/3 2/3 1 1 1]);
996 pnts= [ 0.0 0.0 0.0 0.0;
999 crv3 = nrbmak(pnts, [0 0 0 0.5 1 1 1]);
1001 pnts= [ 10.0 10.0 10.0 10.0 10.0;
1002 0.0 3.0 5.0 8.0 10.0;
1003 9.0 7.0 7.0 10.0 10.0];
1004 crv4 = nrbmak(pnts, [0 0 0 0.25 0.75 1 1 1]);
1006 srf = nrbcoons(crv1, crv2, crv3, crv4);
1007 nrbplot(srf,[20 20],220,45);
1009 Copyright (C) 2000 Mark Spink
1011 This program is free software: you can redistribute it and/or modify
1012 it under the terms of the GNU General Public License as published by
1013 the Free Software Foundation, either version 2 of the License, or
1014 (at your option) any later version.
1018 # name: <cell-element>
1023 NRBCOONS: Construction of a Coons patch.
1027 # name: <cell-element>
1034 # name: <cell-element>
1039 NRBCRVDERIVEVAL: Evaluate n-th order derivatives of a NURBS curve.
1041 usage: skl = nrbcrvderiveval (crv, u, d)
1045 crv : NURBS curve structure, see nrbmak
1047 u : parametric coordinate of the points where we compute the derivatives
1049 d : number of partial derivatives to compute
1054 ck (i, j, l) = i-th component derived j-1 times at the l-th point.
1056 Adaptation of algorithm A4.2 from the NURBS book, pg127
1058 Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
1060 This program is free software: you can redistribute it and/or modify
1061 it under the terms of the GNU General Public License as published by
1062 the Free Software Foundation, either version 2 of the License, or
1063 (at your option) any later version.
1067 # name: <cell-element>
1072 NRBCRVDERIVEVAL: Evaluate n-th order derivatives of a NURBS curve.
1076 # name: <cell-element>
1083 # name: <cell-element>
1087 NRBCTRLPLOT: Plot a NURBS entity along with its control points.
1095 nurbs: NURBS curve or surface, see nrbmak.
1099 Plot the test curve and test surface with their control polygon and
1100 control net, respectively
1102 nrbctrlplot(nrbtestcrv)
1103 nrbctrlplot(nrbtestsrf)
1109 Copyright (C) 2011 Rafael Vazquez
1111 This program is free software: you can redistribute it and/or modify
1112 it under the terms of the GNU General Public License as published by
1113 the Free Software Foundation, either version 2 of the License, or
1114 (at your option) any later version.
1118 # name: <cell-element>
1122 NRBCTRLPLOT: Plot a NURBS entity along with its control points.
1126 # name: <cell-element>
1133 # name: <cell-element>
1138 NRBCYLIND: Construct a cylinder or cylindrical patch.
1143 srf = nrbcylind(height)
1144 srf = nrbcylind(height,radius)
1145 srf = nrbcylind(height,radius,center)
1146 srf = nrbcylind(height,radius,center,sang,eang)
1150 height : Height of the cylinder along the axis, default 1.0
1152 radius : Radius of the cylinder, default 1.0
1154 center : Center of the cylinder, default (0,0,0)
1156 sang : Start angle relative to the origin, default 0.
1158 eang : End angle relative to the origin, default 2*pi.
1162 srf : cylindrical surface patch
1166 Construct a cylinder or cylindrical patch by extruding a circular arc.
1168 Copyright (C) 2000 Mark Spink
1170 This program is free software: you can redistribute it and/or modify
1171 it under the terms of the GNU General Public License as published by
1172 the Free Software Foundation, either version 2 of the License, or
1173 (at your option) any later version.
1177 # name: <cell-element>
1182 NRBCYLIND: Construct a cylinder or cylindrical patch.
1186 # name: <cell-element>
1193 # name: <cell-element>
1198 NRBDEGELEV: Elevate the degree of the NURBS curve, surface or volume.
1202 ecrv = nrbdegelev(crv,utimes);
1203 esrf = nrbdegelev(srf,[utimes,vtimes]);
1204 evol = nrbdegelev(vol,[utimes,vtimes,wtimes]);
1208 crv : NURBS curve, see nrbmak.
1210 srf : NURBS surface, see nrbmak.
1212 vol : NURBS volume, see nrbmak.
1214 utimes : Increase the degree along U direction utimes.
1216 vtimes : Increase the degree along V direction vtimes.
1218 wtimes : Increase the degree along W direction vtimes.
1222 ecrv : new NURBS structure for a curve with degree elevated.
1224 esrf : new NURBS structure for a surface with degree elevated.
1226 evol : new NURBS structure for a volume with degree elevated.
1231 Degree elevates the NURBS curve or surface. This function uses the
1232 B-Spline function bspdegelev, which interface to an internal 'C'
1237 Increase the NURBS surface twice along the V direction.
1238 esrf = nrbdegelev(srf, [0, 2]);
1244 Copyright (C) 2000 Mark Spink, 2010 Rafel Vazquez
1246 This program is free software: you can redistribute it and/or modify
1247 it under the terms of the GNU General Public License as published by
1248 the Free Software Foundation, either version 2 of the License, or
1249 (at your option) any later version.
1253 # name: <cell-element>
1258 NRBDEGELEV: Elevate the degree of the NURBS curve, surface or volume.
1262 # name: <cell-element>
1269 # name: <cell-element>
1274 NRBDERIV: Construct the first and second derivative representation of a
1275 NURBS curve, surface or volume.
1279 ders = nrbderiv (nrb);
1280 [ders, ders2] = nrbderiv (nrb);
1284 nrb : NURBS data structure, see nrbmak.
1288 ders: A data structure that represents the first
1289 derivatives of a NURBS curve, surface or volume.
1290 ders2: A data structure that represents the second
1291 derivatives of a NURBS curve, surface or volume.
1295 The derivatives of a B-Spline are themselves a B-Spline of lower degree,
1296 giving an efficient means of evaluating multiple derivatives. However,
1297 although the same approach can be applied to NURBS, the situation for
1298 NURBS is more complex. We have followed in this function the same idea
1299 that was already used for the first derivative in the function nrbderiv.
1300 The second derivative data structure can be evaluated later with the
1307 Copyright (C) 2000 Mark Spink
1308 Copyright (C) 2010 Carlo de Falco
1309 Copyright (C) 2010, 2011 Rafael Vazquez
1311 This program is free software: you can redistribute it and/or modify
1312 it under the terms of the GNU General Public License as published by
1313 the Free Software Foundation, either version 2 of the License, or
1314 (at your option) any later version.
1318 # name: <cell-element>
1323 NRBDERIV: Construct the first and second derivative representation of a
1328 # name: <cell-element>
1335 # name: <cell-element>
1339 NRBDEVAL: Evaluation of the derivative and second derivatives of NURBS curve, surface or volume.
1341 [pnt, jac] = nrbdeval (crv, dcrv, tt)
1342 [pnt, jac] = nrbdeval (srf, dsrf, {tu tv})
1343 [pnt, jac] = nrbdeval (vol, dvol, {tu tv tw})
1344 [pnt, jac, hess] = nrbdeval (crv, dcrv, dcrv2, tt)
1345 [pnt, jac, hess] = nrbdeval (srf, dsrf, dsrf2, {tu tv})
1346 [pnt, jac, hess] = nrbdeval (vol, dvol, {tu tv tw})
1350 crv, srf, vol - original NURBS curve, surface or volume.
1351 dcrv, dsrf, dvol - NURBS derivative representation of crv, srf
1352 or vol (see nrbderiv2)
1353 dcrv2, dsrf2, dvol2 - NURBS second derivative representation of crv,
1354 srf or vol (see nrbderiv2)
1355 tt - parametric evaluation points
1356 If the nurbs is a surface or a volume then tt is a cell
1357 {tu, tv} or {tu, tv, tw} are the parametric coordinates
1361 pnt - evaluated points.
1362 jac - evaluated first derivatives (Jacobian).
1363 hess - evaluated second derivatives (Hessian).
1365 Copyright (C) 2000 Mark Spink
1366 Copyright (C) 2010 Carlo de Falco
1367 Copyright (C) 2010, 2011 Rafael Vazquez
1369 This program is free software: you can redistribute it and/or modify
1370 it under the terms of the GNU General Public License as published by
1371 the Free Software Foundation, either version 2 of the License, or
1372 (at your option) any later version.
1376 # name: <cell-element>
1380 NRBDEVAL: Evaluation of the derivative and second derivatives of NURBS curve, s
1384 # name: <cell-element>
1391 # name: <cell-element>
1396 NRBEVAL: Evaluate a NURBS at parametric points.
1400 [p,w] = nrbeval(crv,ut)
1401 [p,w] = nrbeval(srf,{ut,vt})
1402 [p,w] = nrbeval(vol,{ut,vt,wt})
1403 [p,w] = nrbeval(srf,pts)
1407 crv : NURBS curve, see nrbmak.
1409 srf : NURBS surface, see nrbmak.
1411 vol : NURBS volume, see nrbmak.
1413 ut : Parametric evaluation points along U direction.
1415 vt : Parametric evaluation points along V direction.
1417 wt : Parametric evaluation points along W direction.
1419 pts : Array of scattered points in parametric domain
1423 p : Evaluated points on the NURBS curve, surface or volume as
1424 Cartesian coordinates (x,y,z). If w is included on the lhs argument
1425 list the points are returned as homogeneous coordinates (wx,wy,wz).
1427 w : Weights of the homogeneous coordinates of the evaluated
1428 points. Note inclusion of this argument changes the type
1429 of coordinates returned in p (see above).
1433 Evaluation of NURBS curves, surfaces or volume at parametric points along
1434 the U, V and W directions. Either homogeneous coordinates are returned
1435 if the weights are requested in the lhs arguments, or as Cartesian coordinates.
1436 This function utilises the 'C' interface bspeval.
1440 Evaluate the NURBS circle at twenty points from 0.0 to 1.0
1443 ut = linspace(0.0,1.0,20);
1444 p = nrbeval(nrb,ut);
1450 Copyright (C) 2000 Mark Spink
1451 Copyright (C) 2010 Carlo de Falco
1452 Copyright (C) 2010, 2011 Rafael Vazquez
1454 This program is free software: you can redistribute it and/or modify
1455 it under the terms of the GNU General Public License as published by
1456 the Free Software Foundation, either version 2 of the License, or
1457 (at your option) any later version.
1461 # name: <cell-element>
1466 NRBEVAL: Evaluate a NURBS at parametric points.
1470 # name: <cell-element>
1477 # name: <cell-element>
1482 NRBEXPORT: export NURBS geometries to a format compatible with the one used in GeoPDEs (version 0.6).
1486 nrbexport (nurbs, filename);
1490 nurbs : NURBS curve, surface or volume, see nrbmak.
1491 filename : name of the output file.
1496 The data of the nurbs structure is written in the file, in a format
1497 that can be read by GeoPDEs.
1499 Copyright (C) 2011 Rafael Vazquez
1501 This program is free software: you can redistribute it and/or modify
1502 it under the terms of the GNU General Public License as published by
1503 the Free Software Foundation, either version 2 of the License, or
1504 (at your option) any later version.
1508 # name: <cell-element>
1513 NRBEXPORT: export NURBS geometries to a format compatible with the one used in
1517 # name: <cell-element>
1524 # name: <cell-element>
1529 NRBEXTRACT: construct NURBS curves by extracting the boundaries of a NURBS surface, or NURBS surfaces by extracting the boundary of a NURBS volume.
1533 crvs = nrbextract(surf);
1537 surf : NURBS surface or volume, see nrbmak.
1541 crvs : array of NURBS curves or NURBS surfaces extracted.
1545 Constructs either an array of four NURBS curves, by extracting the boundaries
1546 of a NURBS surface, or an array of six surfaces, by extracting the boundaries
1547 of a NURBS volume. The new entities are ordered in the following way
1553 5: W = 0 (only for volumes)
1554 6: W = 1 (only for volumes)
1556 Copyright (C) 2010 Rafael Vazquez
1558 This program is free software: you can redistribute it and/or modify
1559 it under the terms of the GNU General Public License as published by
1560 the Free Software Foundation, either version 2 of the License, or
1561 (at your option) any later version.
1565 # name: <cell-element>
1570 NRBEXTRACT: construct NURBS curves by extracting the boundaries of a NURBS sur
1574 # name: <cell-element>
1581 # name: <cell-element>
1586 NRBEXTRUDE: Construct a NURBS surface by extruding a NURBS curve, or
1587 construct a NURBS volume by extruding a NURBS surface.
1591 srf = nrbextrude(crv,vec);
1595 crv : NURBS curve or surface to extrude, see nrbmak.
1597 vec : Vector along which the entity is extruded.
1601 srf : NURBS surface or volume constructed.
1605 Constructs either a NURBS surface by extruding a NURBS curve along a
1606 defined vector, or a NURBS volume by extruding a NURBS surface. In the
1607 first case, the NURBS curve forms the U direction of the surface edge, and
1608 is extruded along the vector in the V direction. In the second case, the
1609 original surface forms the U and V direction of the volume, and is extruded
1610 along the W direction.
1614 Form a hollow cylinder by extruding a circle along the z-axis.
1616 srf = nrbextrude(nrbcirc, [0,0,1]);
1618 Copyright (C) 2000 Mark Spink
1619 Copyright (C) 2010 Rafael Vazquez
1621 This program is free software: you can redistribute it and/or modify
1622 it under the terms of the GNU General Public License as published by
1623 the Free Software Foundation, either version 2 of the License, or
1624 (at your option) any later version.
1628 # name: <cell-element>
1633 NRBEXTRUDE: Construct a NURBS surface by extruding a NURBS curve, or
1638 # name: <cell-element>
1645 # name: <cell-element>
1650 NRBKNTINS: Insert a single or multiple knots into a NURBS curve,
1655 icrv = nrbkntins(crv,iuknots);
1656 isrf = nrbkntins(srf,{iuknots ivknots});
1657 ivol = nrbkntins(vol,{iuknots ivknots iwknots});
1661 crv : NURBS curve, see nrbmak.
1663 srf : NURBS surface, see nrbmak.
1665 srf : NURBS volume, see nrbmak.
1667 iuknots : Knots to be inserted along U direction.
1669 ivknots : Knots to be inserted along V direction.
1671 iwknots : Knots to be inserted along W direction.
1675 icrv : new NURBS structure for a curve with knots inserted.
1677 isrf : new NURBS structure for a surface with knots inserted.
1679 ivol : new NURBS structure for a volume with knots inserted.
1683 Inserts knots into the NURBS data structure, these can be knots at
1684 new positions or at the location of existing knots to increase the
1685 multiplicity. Note that the knot multiplicity cannot be increased
1686 beyond the order of the spline. Knots along the V direction can only
1687 inserted into NURBS surfaces, not curve that are always defined along
1688 the U direction. This function use the B-Spline function bspkntins,
1689 which interfaces to an internal 'C' routine.
1693 Insert two knots into a curve, one at 0.3 and another
1696 icrv = nrbkntins(crv, [0.3 0.4 0.4])
1698 Insert into a surface two knots as (1) into the U knot
1699 sequence and one knot into the V knot sequence at 0.5.
1701 isrf = nrbkntins(srf, {[0.3 0.4 0.4] [0.5]})
1709 No knot multiplicity will be increased beyond the order of the spline.
1711 Copyright (C) 2000 Mark Spink, 2010 Rafael Vazquez
1713 This program is free software: you can redistribute it and/or modify
1714 it under the terms of the GNU General Public License as published by
1715 the Free Software Foundation, either version 2 of the License, or
1716 (at your option) any later version.
1720 # name: <cell-element>
1725 NRBKNTINS: Insert a single or multiple knots into a NURBS curve,
1730 # name: <cell-element>
1737 # name: <cell-element>
1741 NRBKNTPLOT: Plot a NURBS entity with the knots subdivision.
1749 nurbs: NURBS curve, surface or volume, see nrbmak.
1753 Plot the test surface with its knot vector
1755 nrbkntplot(nrbtestsrf)
1761 Copyright (C) 2011 Rafael Vazquez
1763 This program is free software: you can redistribute it and/or modify
1764 it under the terms of the GNU General Public License as published by
1765 the Free Software Foundation, either version 2 of the License, or
1766 (at your option) any later version.
1770 # name: <cell-element>
1774 NRBKNTPLOT: Plot a NURBS entity with the knots subdivision.
1778 # name: <cell-element>
1785 # name: <cell-element>
1790 NRBLINE: Construct a straight line.
1795 crv = nrbline(p1,p2)
1799 p1 : 2D or 3D cartesian coordinate of the start point.
1801 p2 : 2D or 3D cartesian coordinate of the end point.
1805 crv : NURBS curve for a straight line.
1809 Constructs NURBS data structure for a straight line. If no rhs
1810 coordinates are included the function returns a unit straight
1811 line along the x-axis.
1813 Copyright (C) 2000 Mark Spink
1815 This program is free software: you can redistribute it and/or modify
1816 it under the terms of the GNU General Public License as published by
1817 the Free Software Foundation, either version 2 of the License, or
1818 (at your option) any later version.
1822 # name: <cell-element>
1827 NRBLINE: Construct a straight line.
1831 # name: <cell-element>
1838 # name: <cell-element>
1843 NRBMAK: Construct the NURBS structure given the control points
1848 nurbs = nrbmak(cntrl,knots);
1852 cntrl : Control points, these can be either Cartesian or
1853 homogeneous coordinates.
1855 For a curve the control points are represented by a
1856 matrix of size (dim,nu), for a surface a multidimensional
1857 array of size (dim,nu,nv), for a volume a multidimensional array
1858 of size (dim,nu,nv,nw). Where nu is number of points along
1859 the parametric U direction, nv the number of points along
1860 the V direction and nw the number of points along the W direction.
1861 dim is the dimension. Valid options
1863 2 .... (x,y) 2D Cartesian coordinates
1864 3 .... (x,y,z) 3D Cartesian coordinates
1865 4 .... (wx,wy,wz,w) 4D homogeneous coordinates
1867 knots : Non-decreasing knot sequence spanning the interval
1868 [0.0,1.0]. It's assumed that the geometric entities
1869 are clamped to the start and end control points by knot
1870 multiplicities equal to the spline order (open knot vector).
1871 For curve knots form a vector and for surfaces (volumes)
1872 the knots are stored by two (three) vectors for U and V (and W)
1873 in a cell structure {uknots vknots} ({uknots vknots wknots}).
1877 nurbs : Data structure for representing a NURBS entity
1881 Both curves and surfaces are represented by a structure that is
1882 compatible with the Spline Toolbox from Mathworks
1884 nurbs.form .... Type name 'B-NURBS'
1885 nurbs.dim .... Dimension of the control points
1886 nurbs.number .... Number of Control points
1887 nurbs.coefs .... Control Points
1888 nurbs.order .... Order of the spline
1889 nurbs.knots .... Knot sequence
1891 Note: the control points are always converted and stored within the
1892 NURBS structure as 4D homogeneous coordinates. A curve is always stored
1893 along the U direction, and the vknots element is an empty matrix. For
1894 a surface the spline order is a vector [du,dv] containing the order
1895 along the U and V directions respectively. For a volume the order is
1896 a vector [du dv dw]. Recall that order = degree + 1.
1900 This function is used as a convenient means of constructing the NURBS
1901 data structure. Many of the other functions in the toolbox rely on the
1902 NURBS structure been correctly defined as shown above. The nrbmak not
1903 only constructs the proper structure, but also checks for consistency.
1904 The user is still free to build his own structure, in fact a few
1905 functions in the toolbox do this for convenience.
1909 Construct a 2D line from (0.0,0.0) to (1.5,3.0).
1910 For a straight line a spline of order 2 is required.
1911 Note that the knot sequence has a multiplicity of 2 at the
1912 start (0.0,0.0) and end (1.0 1.0) in order to clamp the ends.
1914 line = nrbmak([0.0 1.5; 0.0 3.0],[0.0 0.0 1.0 1.0]);
1917 Construct a surface in the x-y plane i.e
1919 ^ (0.0,1.0) ------------ (1.0,1.0)
1925 | (0.0,0.0) ------------ (1.0,0.0)
1927 |------------------------------------>
1930 coefs = cat(3,[0 0; 0 1],[1 1; 0 1]);
1931 knots = {[0 0 1 1] [0 0 1 1]}
1932 plane = nrbmak(coefs,knots);
1933 nrbplot(plane, [2 2]);
1935 Copyright (C) 2000 Mark Spink, 2010 Rafael Vazquez
1937 This program is free software: you can redistribute it and/or modify
1938 it under the terms of the GNU General Public License as published by
1939 the Free Software Foundation, either version 2 of the License, or
1940 (at your option) any later version.
1944 # name: <cell-element>
1949 NRBMAK: Construct the NURBS structure given the control points
1954 # name: <cell-element>
1961 # name: <cell-element>
1966 NRBNUMBASISFUN: Numbering of basis functions for NURBS
1970 N = nrbnumbasisfun (u, crv)
1971 N = nrbnumbasisfun ({u, v}, srf)
1972 N = nrbnumbasisfun (p, srf)
1976 u or p(1,:,:) - parametric points along u direction
1977 v or p(2,:,:) - parametric points along v direction
1983 N - Indices of the basis functions that are nonvanishing at each
1984 point. size(N) == size(B)
1986 Copyright (C) 2009 Carlo de Falco
1988 This program is free software: you can redistribute it and/or modify
1989 it under the terms of the GNU General Public License as published by
1990 the Free Software Foundation, either version 2 of the License, or
1991 (at your option) any later version.
1995 # name: <cell-element>
2000 NRBNUMBASISFUN: Numbering of basis functions for NURBS
2005 # name: <cell-element>
2012 # name: <cell-element>
2017 NRBPLOT: Plot a NURBS curve or surface, or the boundary of a NURBS volume.
2022 nrbplot (nrb, subd, p, v)
2026 nrb : NURBS curve, surface or volume, see nrbmak.
2028 npnts : Number of evaluation points, for a surface or volume, a row
2029 vector with the number of points along each direction.
2031 [p,v] : property/value options
2033 Valid property/value pairs include:
2035 Property Value/{Default}
2036 -----------------------------------
2042 Plot the test surface with 20 points along the U direction
2043 and 30 along the V direction
2045 nrbplot(nrbtestsrf, [20 30])
2047 Copyright (C) 2000 Mark Spink
2048 Copyright (C) 2010 Carlo de Falco, Rafael Vazquez
2050 This program is free software: you can redistribute it and/or modify
2051 it under the terms of the GNU General Public License as published by
2052 the Free Software Foundation, either version 2 of the License, or
2053 (at your option) any later version.
2057 # name: <cell-element>
2062 NRBPLOT: Plot a NURBS curve or surface, or the boundary of a NURBS volume.
2066 # name: <cell-element>
2073 # name: <cell-element>
2078 NRBRECT: Construct NURBS representation of a rectangular curve.
2084 crv = nrbrect(width, height)
2088 size : Size of the square (width = height).
2090 width : Width of the rectangle (along x-axis).
2092 height : Height of the rectangle (along y-axis).
2096 crv : NURBS curve, see nrbmak.
2101 Construct a rectangle or square in the x-y plane with the bottom
2102 lhs corner at (0,0,0). If no rhs arguments provided the function
2103 constructs a unit square.
2105 Copyright (C) 2000 Mark Spink
2107 This program is free software: you can redistribute it and/or modify
2108 it under the terms of the GNU General Public License as published by
2109 the Free Software Foundation, either version 2 of the License, or
2110 (at your option) any later version.
2114 # name: <cell-element>
2119 NRBRECT: Construct NURBS representation of a rectangular curve.
2123 # name: <cell-element>
2130 # name: <cell-element>
2135 NRBREVERSE: Reverse the evaluation direction of a NURBS curve or surface.
2139 rnrb = nrbreverse(nrb);
2143 nrb : NURBS data structure, see nrbmak.
2147 rnrb : Reversed NURBS.
2151 Utility function to reverse the evaluation direction of a NURBS
2154 Copyright (C) 2000 Mark Spink
2156 This program is free software: you can redistribute it and/or modify
2157 it under the terms of the GNU General Public License as published by
2158 the Free Software Foundation, either version 2 of the License, or
2159 (at your option) any later version.
2163 # name: <cell-element>
2168 NRBREVERSE: Reverse the evaluation direction of a NURBS curve or surface.
2172 # name: <cell-element>
2179 # name: <cell-element>
2184 NRBREVOLVE: Construct a NURBS surface by revolving a NURBS curve, or
2185 construct a NURBS volume by revolving a NURBS surface.
2189 srf = nrbrevolve(crv,pnt,vec[,ang])
2193 crv : NURBS curve or surface to revolve, see nrbmak.
2195 pnt : Coordinates of the point used to define the axis
2198 vec : Vector defining the direction of the rotation axis.
2200 ang : Angle to revolve the curve, default 2*pi
2204 srf : constructed surface or volume
2208 Construct a NURBS surface by revolving the profile NURBS curve around
2209 an axis defined by a point and vector.
2213 Construct a sphere by rotating a semicircle around a x-axis.
2215 crv = nrbcirc(1.0,[0 0 0],0,pi);
2216 srf = nrbrevolve(crv,[0 0 0],[1 0 0]);
2217 nrbplot(srf,[20 20]);
2223 1) vectrans the point to the origin (0,0,0)
2224 2) rotate the vector into alignment with the z-axis
2226 for each control point along the curve
2228 3) determine the radius and angle of control
2230 4) construct a circular arc in the x-y plane with
2231 this radius and start angle and sweep angle theta
2232 5) combine the arc and profile, coefs and weights.
2236 6) rotate and vectrans the surface back into position
2237 by reversing 1 and 2.
2240 Copyright (C) 2000 Mark Spink
2241 Copyright (C) 2010 Rafael Vazquez
2243 This program is free software: you can redistribute it and/or modify
2244 it under the terms of the GNU General Public License as published by
2245 the Free Software Foundation, either version 2 of the License, or
2246 (at your option) any later version.
2250 # name: <cell-element>
2255 NRBREVOLVE: Construct a NURBS surface by revolving a NURBS curve, or
2260 # name: <cell-element>
2267 # name: <cell-element>
2271 NRBRULED: Construct a ruled surface between two NURBS curves.
2275 srf = nrbruled(crv1, crv2)
2279 crv1 : First NURBS curve, see nrbmak.
2281 crv2 : Second NURBS curve, see nrbmak.
2285 srf : Ruled NURBS surface.
2289 Constructs a ruled surface between two NURBS curves. The ruled surface is
2290 ruled along the V direction.
2294 Construct a ruled surface between a semicircle and a straight line.
2296 cir = nrbcirc(1,[0 0 0],0,pi);
2297 line = nrbline([-1 0.5 1],[1 0.5 1]);
2298 srf = nrbruled(cir,line);
2299 nrbplot(srf,[20 20]);
2301 Copyright (C) 2000 Mark Spink
2303 This program is free software: you can redistribute it and/or modify
2304 it under the terms of the GNU General Public License as published by
2305 the Free Software Foundation, either version 2 of the License, or
2306 (at your option) any later version.
2310 # name: <cell-element>
2314 NRBRULED: Construct a ruled surface between two NURBS curves.
2318 # name: <cell-element>
2325 # name: <cell-element>
2330 NRBSURFDERIVEVAL: Evaluate n-th order derivatives of a NURBS surface
2332 usage: skl = nrbsurfderiveval (srf, [u; v], d)
2336 srf : NURBS surface structure, see nrbmak
2338 u, v : parametric coordinates of the point where we compute the
2341 d : number of partial derivatives to compute
2346 skl (i, j, k, l) = i-th component derived j-1,k-1 times at the
2349 Adaptation of algorithm A4.4 from the NURBS book, pg137
2351 Copyright (C) 2009 Carlo de Falco
2353 This program is free software: you can redistribute it and/or modify
2354 it under the terms of the GNU General Public License as published by
2355 the Free Software Foundation, either version 2 of the License, or
2356 (at your option) any later version.
2360 # name: <cell-element>
2365 NRBSURFDERIVEVAL: Evaluate n-th order derivatives of a NURBS surface
2370 # name: <cell-element>
2377 # name: <cell-element>
2381 NRBTESTCRV: Constructs a simple test curve.
2383 Copyright (C) 2000 Mark Spink
2385 This program is free software: you can redistribute it and/or modify
2386 it under the terms of the GNU General Public License as published by
2387 the Free Software Foundation, either version 2 of the License, or
2388 (at your option) any later version.
2392 # name: <cell-element>
2396 NRBTESTCRV: Constructs a simple test curve.
2400 # name: <cell-element>
2407 # name: <cell-element>
2411 NRBTESTSRF: Constructs a simple test surface.
2413 Copyright (C) 2000 Mark Spink
2415 This program is free software: you can redistribute it and/or modify
2416 it under the terms of the GNU General Public License as published by
2417 the Free Software Foundation, either version 2 of the License, or
2418 (at your option) any later version.
2422 # name: <cell-element>
2426 NRBTESTSRF: Constructs a simple test surface.
2430 # name: <cell-element>
2437 # name: <cell-element>
2442 NRBTFORM: Apply transformation matrix to the NURBS.
2446 tnurbs = nrbtform(nurbs,tmatrix);
2450 nurbs : NURBS data structure (see nrbmak for details).
2452 tmatrix : Transformation matrix, a matrix of size (4,4) defining
2453 a single or multiple transformations.
2457 tnurbs : The return transformed NURBS data structure.
2461 The NURBS is transform as defined a transformation matrix of size (4,4),
2462 such as a rotation, translation or change in scale. The transformation
2463 matrix can define a single transformation or multiple series of
2464 transformations. The matrix can be simple constructed by the functions
2465 vecscale, vectrans, vecrotx, vecroty, and vecrotz.
2469 Rotate a square by 45 degrees about the z axis.
2471 rsqr = nrbtform(nrbrect(), vecrotz(deg2rad(45)));
2472 nrbplot(rsqr, 1000);
2476 vecscale, vectrans, vecrotx, vecroty, vecrotz
2478 Copyright (C) 2000 Mark Spink
2479 Copyright (C) 2010 Rafael Vazquez
2481 This program is free software: you can redistribute it and/or modify
2482 it under the terms of the GNU General Public License as published by
2483 the Free Software Foundation, either version 2 of the License, or
2484 (at your option) any later version.
2488 # name: <cell-element>
2493 NRBTFORM: Apply transformation matrix to the NURBS.
2497 # name: <cell-element>
2504 # name: <cell-element>
2509 NRBTRANSP: Transpose a NURBS surface, by swapping U and V directions.
2513 tsrf = nrbtransp(srf)
2517 srf : NURBS surface, see nrbmak.
2521 tsrf : NURBS surface with U and V diretions transposed.
2525 Utility function that transposes a NURBS surface, by swapping U and
2526 V directions. NURBS curves cannot be transposed.
2528 Copyright (C) 2000 Mark Spink
2530 This program is free software: you can redistribute it and/or modify
2531 it under the terms of the GNU General Public License as published by
2532 the Free Software Foundation, either version 2 of the License, or
2533 (at your option) any later version.
2537 # name: <cell-element>
2542 NRBTRANSP: Transpose a NURBS surface, by swapping U and V directions.
2546 # name: <cell-element>
2553 # name: <cell-element>
2557 NUMBASISFUN: List non-zero Basis functions for B-Spline in a given knot-span
2561 N = numbasisfun(i,u,p,U)
2565 i - knot span ( from FindSpan() )
2566 u - parametric point
2572 N - Basis functions (numel(u)x(p+1))
2574 Copyright (C) 2009 Carlo de Falco
2576 This program is free software: you can redistribute it and/or modify
2577 it under the terms of the GNU General Public License as published by
2578 the Free Software Foundation, either version 2 of the License, or
2579 (at your option) any later version.
2583 # name: <cell-element>
2587 NUMBASISFUN: List non-zero Basis functions for B-Spline in a given knot-span
2592 # name: <cell-element>
2599 # name: <cell-element>
2604 RAD2DEG: Convert radians to degrees.
2612 rad : Angle in radians.
2616 deg : Angle in degrees.
2620 Convenient utility function for converting radians to degrees, which are
2621 often the required angular units for functions in the NURBS toolbox.
2625 Convert 0.3 radians to degrees
2629 Copyright (C) 2000 Mark Spink
2631 This program is free software: you can redistribute it and/or modify
2632 it under the terms of the GNU General Public License as published by
2633 the Free Software Foundation, either version 2 of the License, or
2634 (at your option) any later version.
2638 # name: <cell-element>
2643 RAD2DEG: Convert radians to degrees.
2647 # name: <cell-element>
2654 # name: <cell-element>
2659 SURFDERIVCPTS: Compute control points of n-th derivatives of a NURBS surface.
2661 usage: pkl = surfderivcpts (n, p, U, m, q, V, P, d)
2665 n+1, m+1 = number of control points
2669 d = derivative order
2673 pkl (k+1, l+1, i+1, j+1) = i,jth control point
2674 of the surface differentiated k
2675 times in the u direction and l
2676 times in the v direction
2678 Adaptation of algorithm A3.7 from the NURBS book, pg114
2680 Copyright (C) 2009 Carlo de Falco
2682 This program is free software: you can redistribute it and/or modify
2683 it under the terms of the GNU General Public License as published by
2684 the Free Software Foundation, either version 2 of the License, or
2685 (at your option) any later version.
2689 # name: <cell-element>
2694 SURFDERIVCPTS: Compute control points of n-th derivatives of a NURBS surface.
2698 # name: <cell-element>
2705 # name: <cell-element>
2710 SURFDERIVEVAL: Compute the derivatives of a B-spline surface
2712 usage: skl = surfderiveval (n, p, U, m, q, V, P, u, v, d)
2716 n+1, m+1 = number of control points
2720 u,v = evaluation points
2721 d = derivative order
2725 skl (k+1, l+1) = surface differentiated k
2726 times in the u direction and l
2727 times in the v direction
2729 Adaptation of algorithm A3.8 from the NURBS book, pg115
2731 Copyright (C) 2009 Carlo de Falco
2733 This program is free software: you can redistribute it and/or modify
2734 it under the terms of the GNU General Public License as published by
2735 the Free Software Foundation, either version 2 of the License, or
2736 (at your option) any later version.
2740 # name: <cell-element>
2745 SURFDERIVEVAL: Compute the derivatives of a B-spline surface
2751 # name: <cell-element>
2758 # name: <cell-element>
2763 TBASISFUN: Compute a B- or T-Spline basis function, and its derivatives, from its local knot vector.
2767 [N, Nder] = tbasisfun (u, p, U)
2768 [N, Nder] = tbasisfun ([u; v], [p q], {U, V})
2769 [N, Nder] = tbasisfun ([u; v; w], [p q r], {U, V, W})
2773 u or [u; v] : points in parameter space where the basis function is to be
2776 U or {U, V} : local knot vector
2778 p or [p q] : polynomial order of the basis function
2782 N : basis function evaluated at the given parametric points
2783 Nder : basis function gradient evaluated at the given parametric points
2785 Copyright (C) 2009 Carlo de Falco
2786 Copyright (C) 2012 Rafael Vazquez
2788 This program is free software: you can redistribute it and/or modify
2789 it under the terms of the GNU General Public License as published by
2790 the Free Software Foundation, either version 2 of the License, or
2791 (at your option) any later version.
2795 # name: <cell-element>
2800 TBASISFUN: Compute a B- or T-Spline basis function, and its derivatives, from
2804 # name: <cell-element>
2811 # name: <cell-element>
2816 VECANGLE: An alternative to atan, returning an arctangent in the
2821 ang = vecmag2(num,dum)
2825 num : Numerator, vector of size (1,nv).
2826 dem : Denominator, vector of size (1,nv).
2829 ang : Arctangents, row vector of angles.
2833 The components of the vector ang are the arctangent of the corresponding
2834 enties of num./dem. This function is an alternative for
2835 atan, returning an angle in the range 0 to 2*pi.
2839 Find the atan(1.2,2.0) and atan(1.5,3.4) using vecangle
2841 ang = vecangle([1.2 1.5], [2.0 3.4]);
2843 Copyright (C) 2000 Mark Spink
2845 This program is free software: you can redistribute it and/or modify
2846 it under the terms of the GNU General Public License as published by
2847 the Free Software Foundation, either version 2 of the License, or
2848 (at your option) any later version.
2852 # name: <cell-element>
2857 VECANGLE: An alternative to atan, returning an arctangent in the
2862 # name: <cell-element>
2869 # name: <cell-element>
2874 VECCROSS: The cross product of two vectors.
2878 cross = veccross(vec1,vec2);
2882 vec1 : An array of column vectors represented by a matrix of
2883 vec2 size (dim,nv), where is the dimension of the vector and
2884 nv the number of vectors.
2888 cross : Array of column vectors, each element is corresponding
2889 to the cross product of the respective components in vec1
2894 Cross product of two vectors.
2898 Determine the cross products of:
2899 (2.3,3.4,5.6) and (1.2,4.5,1.2)
2900 (5.1,0.0,2.3) and (2.5,3.2,4.0)
2902 cross = veccross([2.3 5.1; 3.4 0.0; 5.6 2.3],[1.2 2.5; 4.5 3.2; 1.2 4.0]);
2904 Copyright (C) 2000 Mark Spink
2906 This program is free software: you can redistribute it and/or modify
2907 it under the terms of the GNU General Public License as published by
2908 the Free Software Foundation, either version 2 of the License, or
2909 (at your option) any later version.
2913 # name: <cell-element>
2918 VECCROSS: The cross product of two vectors.
2922 # name: <cell-element>
2929 # name: <cell-element>
2934 VECDOT: The dot product of two vectors.
2938 dot = vecdot(vec1,vec2);
2942 vec1 : An array of column vectors represented by a matrix of
2943 vec2 size (dim,nv), where is the dimension of the vector and
2944 nv the number of vectors.
2948 dot : Row vector of scalars, each element corresponding to
2949 the dot product of the respective components in vec1 and
2954 Scalar dot product of two vectors.
2958 Determine the dot product of
2959 (2.3,3.4,5.6) and (1.2,4.5,1.2)
2960 (5.1,0.0,2.3) and (2.5,3.2,4.0)
2962 dot = vecdot([2.3 5.1; 3.4 0.0; 5.6 2.3],[1.2 2.5; 4.5 3.2; 1.2 4.0]);
2964 Copyright (C) 2000 Mark Spink
2966 This program is free software: you can redistribute it and/or modify
2967 it under the terms of the GNU General Public License as published by
2968 the Free Software Foundation, either version 2 of the License, or
2969 (at your option) any later version.
2973 # name: <cell-element>
2978 VECDOT: The dot product of two vectors.
2982 # name: <cell-element>
2989 # name: <cell-element>
2994 VECMAG: Magnitude of the vectors.
3002 vec : An array of column vectors represented by a matrix of
3003 size (dim,nv), where is the dimension of the vector and
3004 nv the number of vectors.
3008 mvec : Magnitude of the vectors, vector of size (1,nv).
3012 Determines the magnitude of the vectors.
3016 Find the magnitude of the two vectors (0.0,2.0,1.3) and (1.5,3.4,2.3)
3018 mvec = vecmag([0.0 1.5; 2.0 3.4; 1.3 2.3]);
3020 Copyright (C) 2000 Mark Spink
3022 This program is free software: you can redistribute it and/or modify
3023 it under the terms of the GNU General Public License as published by
3024 the Free Software Foundation, either version 2 of the License, or
3025 (at your option) any later version.
3029 # name: <cell-element>
3034 VECMAG: Magnitude of the vectors.
3038 # name: <cell-element>
3045 # name: <cell-element>
3050 VECMAG2: Squared magnitude of a set of vectors.
3058 vec : An array of column vectors represented by a matrix of
3059 size (dim,nv), where dim is the dimension of the vector and
3060 nv the number of vectors.
3064 mvec : Squared magnitude of the vectors, vector of size (1,nv).
3068 Determines the squared magnitude of the vectors.
3072 Find the squared magnitude of the two vectors (0.0,2.0,1.3)
3075 mvec = vecmag2([0.0 1.5; 2.0 3.4; 1.3 2.3]);
3077 Copyright (C) 2000 Mark Spink
3079 This program is free software: you can redistribute it and/or modify
3080 it under the terms of the GNU General Public License as published by
3081 the Free Software Foundation, either version 2 of the License, or
3082 (at your option) any later version.
3086 # name: <cell-element>
3091 VECMAG2: Squared magnitude of a set of vectors.
3095 # name: <cell-element>
3102 # name: <cell-element>
3107 VECNORM: Normalise the vectors.
3111 nvec = vecnorn(vec);
3115 vec : An array of column vectors represented by a matrix of
3116 size (dim,nv), where is the dimension of the vector and
3117 nv the number of vectors.
3121 nvec : Normalised vectors, matrix the smae size as vec.
3125 Normalises the array of vectors, returning the unit vectors.
3129 Normalise the two vectors (0.0,2.0,1.3) and (1.5,3.4,2.3)
3131 nvec = vecnorm([0.0 1.5; 2.0 3.4; 1.3 2.3]);
3133 Copyright (C) 2000 Mark Spink
3135 This program is free software: you can redistribute it and/or modify
3136 it under the terms of the GNU General Public License as published by
3137 the Free Software Foundation, either version 2 of the License, or
3138 (at your option) any later version.
3142 # name: <cell-element>
3147 VECNORM: Normalise the vectors.
3151 # name: <cell-element>
3158 # name: <cell-element>
3163 VECROT: Transformation matrix for a rotation around the axis given by a vector.
3167 rx = vecrot (angle, vector);
3171 angle : rotation angle defined in radians
3172 vector : vector defining the rotation axis
3176 rx : (4x4) Transformation matrix.
3181 Return the (4x4) Transformation matrix for a rotation about the x axis
3182 by the defined angle.
3188 Copyright (C) 2011 Rafael Vazquez
3190 This program is free software: you can redistribute it and/or modify
3191 it under the terms of the GNU General Public License as published by
3192 the Free Software Foundation, either version 2 of the License, or
3193 (at your option) any later version.
3197 # name: <cell-element>
3202 VECROT: Transformation matrix for a rotation around the axis given by a vecto
3206 # name: <cell-element>
3213 # name: <cell-element>
3218 VECROTX: Transformation matrix for a rotation around the x axis.
3222 rx = vecrotx(angle);
3226 angle : rotation angle defined in radians
3230 rx : (4x4) Transformation matrix.
3235 Return the (4x4) Transformation matrix for a rotation about the x axis
3236 by the defined angle.
3241 [ 0 cos(angle) -sin(angle) 0]
3242 [ 0 sin(angle) cos(angle) 0]
3247 Rotate the NURBS line (0.0 0.0 0.0) - (3.0 3.0 3.0) by 45 degrees
3250 line = nrbline([0.0 0.0 0.0],[3.0 3.0 3.0]);
3251 trans = vecrotx(%pi/4);
3252 rline = nrbtform(line, trans);
3258 Copyright (C) 2000 Mark Spink
3260 This program is free software: you can redistribute it and/or modify
3261 it under the terms of the GNU General Public License as published by
3262 the Free Software Foundation, either version 2 of the License, or
3263 (at your option) any later version.
3267 # name: <cell-element>
3272 VECROTX: Transformation matrix for a rotation around the x axis.
3276 # name: <cell-element>
3283 # name: <cell-element>
3288 VECROTY: Transformation matrix for a rotation around the y axis.
3292 ry = vecroty(angle);
3296 angle : rotation angle defined in radians
3300 ry : (4x4) Transformation matrix.
3305 Return the (4x4) Transformation matrix for a rotation about the y axis
3306 by the defined angle.
3310 [ cos(angle) 0 sin(angle) 0]
3312 [ -sin(angle) 0 cos(angle) 0]
3317 Rotate the NURBS line (0.0 0.0 0.0) - (3.0 3.0 3.0) by 45 degrees
3320 line = nrbline([0.0 0.0 0.0],[3.0 3.0 3.0]);
3321 trans = vecroty(%pi/4);
3322 rline = nrbtform(line, trans);
3328 Copyright (C) 2000 Mark Spink
3330 This program is free software: you can redistribute it and/or modify
3331 it under the terms of the GNU General Public License as published by
3332 the Free Software Foundation, either version 2 of the License, or
3333 (at your option) any later version.
3337 # name: <cell-element>
3342 VECROTY: Transformation matrix for a rotation around the y axis.
3346 # name: <cell-element>
3353 # name: <cell-element>
3358 VECROTZ: Transformation matrix for a rotation around the z axis.
3362 rz = vecrotz(angle);
3366 angle : rotation angle defined in radians
3370 rz : (4x4) Transformation matrix.
3375 Return the (4x4) Transformation matrix for a rotation about the z axis
3376 by the defined angle.
3380 [ cos(angle) -sin(angle) 0 0]
3381 [ -sin(angle) cos(angle) 0 0]
3387 Rotate the NURBS line (0.0 0.0 0.0) - (3.0 3.0 3.0) by 45 degrees
3390 line = nrbline([0.0 0.0 0.0],[3.0 3.0 3.0]);
3391 trans = vecrotz(%pi/4);
3392 rline = nrbtform(line, trans);
3398 Copyright (C) 2000 Mark Spink
3400 This program is free software: you can redistribute it and/or modify
3401 it under the terms of the GNU General Public License as published by
3402 the Free Software Foundation, either version 2 of the License, or
3403 (at your option) any later version.
3407 # name: <cell-element>
3412 VECROTZ: Transformation matrix for a rotation around the z axis.
3416 # name: <cell-element>
3423 # name: <cell-element>
3428 VECSCALE: Transformation matrix for a scaling.
3436 svec : A vectors defining the scaling along the x,y and z axes.
3441 ss : Scaling Transformation Matrix
3445 Returns a (4x4) Transformation matrix for scaling.
3456 Scale up the NURBS line (0.0,0.0,0.0) - (1.0,1.0,1.0) by 3 along
3457 the x-axis, 2 along the y-axis and 4 along the z-axis.
3459 line = nrbline([0.0 0.0 0.0],[1.0 1.0 1.0]);
3460 trans = vecscale([3.0 2.0 4.0]);
3461 sline = nrbtform(line, trans);
3467 Copyright (C) 2000 Mark Spink, 2007 Daniel Claxton
3469 This program is free software: you can redistribute it and/or modify
3470 it under the terms of the GNU General Public License as published by
3471 the Free Software Foundation, either version 2 of the License, or
3472 (at your option) any later version.
3476 # name: <cell-element>
3481 VECSCALE: Transformation matrix for a scaling.
3485 # name: <cell-element>
3492 # name: <cell-element>
3497 VECTRANS: Transformation matrix for a translation.
3505 tvec : A vectors defining the translation along the x,y and
3506 z axes. i.e. [tx, ty, ty]
3510 st : Translation Transformation Matrix
3514 Returns a (4x4) Transformation matrix for translation.
3525 Translate the NURBS line (0.0,0.0,0.0) - (1.0,1.0,1.0) by 3 along
3526 the x-axis, 2 along the y-axis and 4 along the z-axis.
3528 line = nrbline([0.0 0.0 0.0],[1.0 1.0 1.0]);
3529 trans = vectrans([3.0 2.0 4.0]);
3530 tline = nrbtform(line, trans);
3536 Copyright (C) 2000 Mark Spink
3538 This program is free software: you can redistribute it and/or modify
3539 it under the terms of the GNU General Public License as published by
3540 the Free Software Foundation, either version 2 of the License, or
3541 (at your option) any later version.
3545 # name: <cell-element>
3550 VECTRANS: Transformation matrix for a translation.