1 /** This file is part of Shapes.
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
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.
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/>.
16 ** Copyright 2008 Henrik Tidefelt
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
27 sl1: [profile e * stepLength]
28 sl2: [profile ( e + '1 ) * stepLength]
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]]]
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]]]
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
53 sl1: [profile e * stepLength]
54 sl2: [profile ( e + '1 ) * stepLength]
57 [facet sl1.p--sl2.p--[T sl2.p]--[T sl1.p]--cycle]
63 revolutionBody: \ profile phiSteps:36 thetaSteps:36 .>
65 section: [makeSectionDefaultNormal profile phiSteps thetaSteps]
66 [[range '0 thetaSteps-'1].foldl
71 [[rotate3D dir:(0,0,1) angle: 360°*((e*1)/thetaSteps)] section]