-
Notifications
You must be signed in to change notification settings - Fork 12
/
flag.go
40 lines (34 loc) · 812 Bytes
/
flag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"math"
"github.com/unixpickle/model3d/model3d"
)
const (
FlagHeight = 5.0
FlagWidth = 1.5
FlagThickness = 0.1
FlagPoleRadius = 0.1
FlagRippleRate = math.Pi * 2
FlagRippleDepth = 0.1
)
func GenerateFlag() model3d.Solid {
return model3d.JoinedSolid{
&model3d.Cylinder{
P2: model3d.Z(FlagHeight),
Radius: FlagPoleRadius,
},
FlagFabric(),
}
}
func FlagFabric() model3d.Solid {
return model3d.CheckedFuncSolid(
model3d.XYZ(0, -FlagThickness/2-FlagRippleDepth*2, FlagHeight-FlagWidth),
model3d.XYZ(FlagWidth, FlagThickness/2+FlagRippleDepth*2, FlagHeight),
func(c model3d.Coord3D) bool {
if math.Abs(c.Y-FlagRippleDepth*math.Sin(c.X*FlagRippleRate)) > FlagThickness {
return false
}
return c.X < c.Z-(FlagHeight-FlagWidth)
},
)
}