Instrumenting extensions with GPL and copyright notes.
[shapes.git] / resources / extensions / revolutionbody.shext
blob8e2d73bae27215f4e6c8b41c1ebfb9773670c2ed
1 /** This file is part of Shapes.
2  **
3  ** Shapes 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 3 of the License, or
6  ** any later version.
7  **
8  ** Shapes 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 Shapes.  If not, see <http://www.gnu.org/licenses/>.
15  **
16  ** Copyright 2008 Henrik Tidefelt
17  **/
19 makeSectionThreeNormals: \ profile phiSteps thetaSteps .>
21         stepLength: [abs profile] / phiSteps
22         T: [rotate3D dir:(0,0,1) angle: 360° / thetaSteps]
24   [[range '0 phiSteps-'1].foldl
25           \ p e .>
26     {
27                         sl1: [profile e * stepLength]
28                   sl2: [profile ( e + '1 ) * stepLength]
29                         p
30                         &
31                         [facet sl1.p--sl2.p--[T sl2.p]--cycle
32                                  [facetnormal sl1.p ~sl1.N]
33                                  [facetnormal sl2.p ~sl2.N]
34                                  [facetnormal [T sl2.p] [T ~sl2.N]]]
35                         &
36                         [facet sl1.p--[T sl2.p]--[T sl1.p]--cycle
37                                  [facetnormal sl1.p ~sl1.N]
38                                  [facetnormal [T sl2.p] [T ~sl2.N]]
39                                  [facetnormal [T sl1.p] [T ~sl1.N]]]
40                 }
41           null3D
42   ]
45 makeSectionDefaultNormal: \ profile phiSteps thetaSteps .>
47         stepLength: [abs profile] / phiSteps
48         T: [rotate3D dir:(0,0,1) angle: 360° / thetaSteps]
50   [[range '0 phiSteps-'1].foldl
51           \ p e .>
52     {
53                         sl1: [profile e * stepLength]
54                   sl2: [profile ( e + '1 ) * stepLength]
55                         p
56                         &
57                         [facet sl1.p--sl2.p--[T sl2.p]--[T sl1.p]--cycle]
58                 }
59           null3D
60   ]
63 revolutionBody: \ profile phiSteps:36 thetaSteps:36 .>
65         section: [makeSectionDefaultNormal profile phiSteps thetaSteps]
66   [[range '0 thetaSteps-'1].foldl
67     \ p e .>
68         {
69           p
70                 &
71                 [[rotate3D dir:(0,0,1) angle: 360°*((e*1)/thetaSteps)] section]
72         }
73         null3D
74   ]