MCPcopy
hub / github.com/fogleman/ln / Paths4

Method Paths4

ln/sphere.go:52–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func (s *Sphere) Paths4() Paths {
53 var paths Paths
54 var seen []Vector
55 var radii []float64
56 for i := 0; i < 140; i++ {
57 var v Vector
58 var m float64
59 for {
60 v = RandomUnitVector()
61 m = rand.Float64()*0.25 + 0.05
62 ok := true
63 for i, other := range seen {
64 threshold := m + radii[i] + 0.02
65 if other.Sub(v).Length() < threshold {
66 ok = false
67 break
68 }
69 }
70 if ok {
71 seen = append(seen, v)
72 radii = append(radii, m)
73 break
74 }
75 }
76 p := v.Cross(RandomUnitVector()).Normalize()
77 q := p.Cross(v).Normalize()
78 n := rand.Intn(4) + 1
79 for k := 0; k < n; k++ {
80 var path Path
81 for j := 0; j <= 360; j += 5 {
82 a := Radians(float64(j))
83 x := v
84 x = x.Add(p.MulScalar(math.Cos(a) * m))
85 x = x.Add(q.MulScalar(math.Sin(a) * m))
86 x = x.Normalize()
87 x = x.MulScalar(s.Radius).Add(s.Center)
88 path = append(path, x)
89 }
90 paths = append(paths, path)
91 m *= 0.75
92 }
93 }
94 return paths
95}
96
97func (s *Sphere) Paths3() Paths {
98 var paths Paths

Callers

nothing calls this directly

Calls 8

CrossMethod · 0.95
RandomUnitVectorFunction · 0.85
RadiansFunction · 0.85
LengthMethod · 0.80
SubMethod · 0.80
NormalizeMethod · 0.80
MulScalarMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected