~ubuntu-branches/ubuntu/precise/octave-nurbs/precise

« back to all changes in this revision

Viewing changes to src/curvederivcpts.cc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Weber
  • Date: 2011-04-20 21:53:46 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110420215346-mtrs63hlmsh5yuaz
Tags: 1.3.3-1
* New upstream release
* Bump standards version to 3.9.1, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
## Copyright (C) 2009 Carlo de Falco
3
 
## 
4
 
## This program is free software; you can redistribute it and/or modify
5
 
## it under the terms of the GNU General Public License as published by
6
 
## the Free Software Foundation; either version 2 of the License, or
7
 
## (at your option) any later version.
8
 
## 
9
 
## This program is distributed in the hope that it will be useful,
10
 
## but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
## GNU General Public License for more details.
13
 
## 
14
 
## You should have received a copy of the GNU General Public License
15
 
## along with Octave; see the file COPYING.  If not, see
16
 
## <http://www.gnu.org/licenses/>.
17
 
 
18
 
## Author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
19
 
## Created: 2009-09-09
 
1
/* Copyright (C) 2009 Carlo de Falco
 
2
 
 
3
   This program is free software: you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation, either version 2 of the License, or
 
6
   (at your option) any later version.
 
7
 
 
8
   This program is distributed in the hope that it will be useful,
 
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
   GNU General Public License for more details.
 
12
 
 
13
   You should have received a copy of the GNU General Public License
 
14
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
15
*/
21
16
 
22
17
#include <octave/oct.h>
24
19
 
25
20
 
26
21
DEFUN_DLD(curvederivcpts, args, nargout,"\
27
 
\nCURVEDERIVCPTS: Compute control points of n-th derivatives of a NURBS curve.\n \
 
22
\nCURVEDERIVCPTS: Compute control points of n-th derivatives of a B-spline curve.\n \
28
23
\n \
29
24
\n usage: pk = curvederivcpts (n, p, U, P, d) \
 
25
\n        pk = curvederivcpts (n, p, U, P, d, r1 r2) \
 
26
\n \
 
27
\n If r1, r2 are not given, all the control points are computed. \
30
28
\n \
31
29
\n  INPUT: \
32
30
\n         n+1 = number of control points \
34
32
\n         d   = maximum derivative order (d<=p) \
35
33
\n         U   = knots \
36
34
\n         P   = control points \
 
35
\n         r1  = first control point to compute \
 
36
\n         r2  = auxiliary index for the last control point to compute \
 
37
\n\
37
38
\n  OUTPUT: \
38
 
\n         pk(k,i) = i-th control point (k-1)-th derivative \
 
39
\n         pk(k,i) = i-th control point (k-1)-th derivative, r1 <= i <= r2-k \
39
40
\n \
40
41
\n Adaptation of algorithm A3.3 from the NURBS book\n")
41
42
 
49
50
  NDArray P = args(3).array_value ();
50
51
  octave_idx_type d = args(4).idx_type_value ();
51
52
 
52
 
  octave_idx_type r1, r2;
53
 
  if (args.length () <= 5)
54
 
    { r1 = 0; r2 = n; }
55
 
  else if (args.length () == 7)
 
53
  octave_idx_type r1(0), r2(n);
 
54
  if (args.length () == 7)
56
55
    {
57
56
      r1 = args (5).idx_type_value ();
58
57
      r2 = args (6).idx_type_value ();
59
58
    }
60
 
  else
 
59
  else  if (args.length () > 5)
61
60
    print_usage ();
62
61
 
63
62
  if (! error_state)