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, 2014, 2015 Henrik Tidefelt
19 cylinderWall: \ radius height sides →
21 deltaAngle: 360° / sides
22 r: radius * ( 2 / ( 1 + [Numeric..Math..cos deltaAngle / 2] ) )
23 oneSide: [Graphics3D..facet (r,0m,0m)--(r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],0m)--(r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],height)--(r,0m,height)--cycle
24 [Graphics3D..facetnormal (r,0m,0m) (1,0,0)]
25 [Graphics3D..facetnormal (r*[Numeric..Math..cos deltaAngle],r*[Numeric..Math..sin deltaAngle],0m) ([Numeric..Math..cos deltaAngle],[Numeric..Math..sin deltaAngle],0)] ]
27 [[Data..range '0 sides-'1].foldl
29 p & [[Geometry3D..rotate (0,0,1) e*deltaAngle] oneSide]
33 block: \ x1 y1 z1 x2 y2 z2 →
35 [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y2,z1)--(x1,y2,z1)--cycle]
37 [Graphics3D..facet (x1,y1,z2)--(x2,y1,z2)--(x2,y2,z2)--(x1,y2,z2)--cycle]
39 [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y1,z2)--(x1,y1,z2)--cycle]
41 [Graphics3D..facet (x1,y2,z1)--(x2,y2,z1)--(x2,y2,z2)--(x1,y2,z2)--cycle]
43 [Graphics3D..facet (x1,y1,z1)--(x1,y1,z2)--(x1,y2,z2)--(x1,y2,z1)--cycle]
45 [Graphics3D..facet (x2,y1,z1)--(x2,y1,z2)--(x2,y2,z2)--(x2,y2,z1)--cycle]