/usr/share/octave/packages/nurbs-1.3.10/nrbcirc.m is in octave-nurbs 1.3.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123  | function curve = nrbcirc(radius,center,sang,eang)
% 
% NRBCIRC: Construct a circular arc.
% 
% Calling Sequence:
% 
%   crv = nrbcirc()
%   crv = nrbcirc(radius)
%   crv = nrbcirc(radius,center)
%   crv = nrbcirc(radius,center,sang,eang)
% 
% INPUT:
% 
%   radius	: Radius of the circle, default 1.0
% 
%   center	: Center of the circle, default (0,0,0)
% 
%   sang	: Start angle, default 0 radians (0 degrees)
% 
%   eang	: End angle, default 2*pi radians (360 degrees)
% 
% OUTPUT:
%
%   crv		: NURBS curve for a circular arc.
% 
% Description:
% 
%   Constructs NURBS data structure for a circular arc in the x-y plane. If
%   no rhs arguments are supplied a unit circle with center (0.0,0.0) is
%   constructed. 
% 
%   Angles are defined as positive in the anti-clockwise direction.
%
%    Copyright (C) 2000 Mark Spink
%
%    This program is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.
if nargin < 1
  radius = 1;
end
if nargin < 2
  center = [];
end
   
if nargin < 4
  sang = 0;
  eang = 2*pi;
end
sweep = eang - sang;       % sweep angle of arc
if sweep < 0
  sweep = 2*pi + sweep;
end
     
if abs(sweep) <= pi/2
  narcs = 1;                % number of arc segments
  knots = [0 0 0 1 1 1];
elseif abs(sweep) <= pi
  narcs = 2;
  knots = [0 0 0 0.5 0.5 1 1 1];
elseif abs(sweep) <= 3*pi/2
  narcs = 3;
  knots = [0 0 0 1/3 1/3 2/3 2/3 1 1 1];
else
  narcs = 4;
  knots = [0 0 0 0.25 0.25 0.5 0.5 0.75 0.75 1 1 1];
end
dsweep = sweep/(2*narcs);     % arc segment sweep angle/2
% determine middle control point and weight
wm = cos(dsweep);
x  = radius*wm;
y  = radius*sin(dsweep);
xm = x+y*tan(dsweep);
% arc segment control points
ctrlpt = [ x wm*xm x;    % w*x - coordinate
          -y 0     y;    % w*y - coordinate
           0 0     0;    % w*z - coordinate
           1 wm    1];   % w   - coordinate
      
% build up complete arc from rotated segments
coefs = zeros(4,2*narcs+1);   % nurbs control points of arc
xx = vecrotz(sang + dsweep);
coefs(:,1:3) = xx*ctrlpt;     % rotate to start angle
xx = vecrotz(2*dsweep);
for n = 2:narcs
   m = 2*n+[0 1];
   coefs(:,m) = xx*coefs(:,m-2);
end
% vectrans arc if necessary
if ~isempty(center) 
  xx = vectrans(center);
  coefs = xx*coefs;
end
curve = nrbmak(coefs,knots);
end
%!demo
%! for r = 1:9
%! crv = nrbcirc(r,[],deg2rad(45),deg2rad(315));
%!   nrbplot(crv,50);
%!   hold on;
%! end
%! hold off;
%! axis equal;
%! title('NURBS construction of several 2D arcs.');
 |