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, 2010, 2014 Henrik Tidefelt
20 ##lookin ..Shapes..Geometry3D
22 rot: [rotate (1,1,1) 30°]
24 screwSeg: (~1cm,1cm,~1cm)<(~1cm,0cm,~1cm)>(~1cm,~1cm,~1cm)--(1cm,~1cm,~2cm)<(1cm,0cm,~2cm)>(1cm,1cm,~2cm)
25 deeper: \ n → [shift (0cm,0cm,n*~2cm)]
26 screw: [scale 1.5] [] (1cm,~1cm,0cm)<(1cm,0cm,0cm)>(1cm,1cm,0cm)--screwSeg--[[deeper 1] screwSeg]--[[deeper 2] screwSeg]--cycle
28 •world: Graphics3D..newGroup
30 •world << Traits..@width:0.3bp & Traits..@stroking:[Traits..gray 0.5] | [Graphics..stroke screw]
35 paintLeg: \ pth → ( [Graphics..stroke pth] & ( Traits..@nonstroking:Traits..RGB..BLACK | [Graphics..fill [shift pth.end.p][][immerse [Geometry..circle 1.5bp]]] ) )
38 [[Data..range '0 markCount-'1].foldl
41 sl: [screw (markStart + i*(1/markCount))*[Numeric..Math..abs screw]]
44 ( Graphics3D..newGroup
45 << Traits..@stroking:Traits..RGB..RED | [paintLeg sl.p--(+(len*sl.T))]
46 << Traits..@stroking:Traits..RGB..GREEN | [paintLeg sl.p--(+(len*sl.N))]
47 << Traits..@stroking:Traits..RGB..BLUE | [paintLeg sl.p--(+([if i = '0 ~1 1]*len*sl.B))]
48 << [shift sl.p+(~2mm,3mm,0mm)] [] [Graphics3D..facing [Layout..center_x [Graphics..TeX [String..sprintf `\textbf{%d}´ i+'1]]]] )
52 •world << [shift (~1.5cm,~1.5cm,0cm)] [] [Graphics3D..facing [Layout..center_x [Graphics..TeX `Odd one out!´]]]
57 world: [rotate (1,1,1) 30°] [] ../world
59 IO..•page << view [] world
60 IO..•page << world >> [shift (~eyew,0cm,0cm)] >> view >> [Geometry..shift (2*eyew,0cm)]