Updating documentation and examples with new core namespaces
[shapes.git] / resources / extensions / Shapes / Graphics3D / elementary.shext
bloba4e152f98c6a394bfa2988351c8ab307d90b2853
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, 2014, 2015 Henrik Tidefelt
17  **/
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
28    \ p e →
29       p & [[Geometry3D..rotate (0,0,1) e*deltaAngle] oneSide]
30     Graphics3D..null]
33 block: \ x1 y1 z1 x2 y2 z2 →
34   (
35     [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y2,z1)--(x1,y2,z1)--cycle]
36     &
37     [Graphics3D..facet (x1,y1,z2)--(x2,y1,z2)--(x2,y2,z2)--(x1,y2,z2)--cycle]
38     &
39     [Graphics3D..facet (x1,y1,z1)--(x2,y1,z1)--(x2,y1,z2)--(x1,y1,z2)--cycle]
40     &
41     [Graphics3D..facet (x1,y2,z1)--(x2,y2,z1)--(x2,y2,z2)--(x1,y2,z2)--cycle]
42     &
43     [Graphics3D..facet (x1,y1,z1)--(x1,y1,z2)--(x1,y2,z2)--(x1,y2,z1)--cycle]
44     &
45     [Graphics3D..facet (x2,y1,z1)--(x2,y1,z2)--(x2,y2,z2)--(x2,y2,z1)--cycle]
46   )