@@ -6,64 +6,191 @@ import (
66 "github.com/KEINOS/go-noise/pkg/opensimplex"
77)
88
9- func ExampleNew_one_dimmention () {
10- const seed = 100
9+ // -----------------------------------------------------------------------------
10+ // Noise.Eval32 implementation test
11+ // -----------------------------------------------------------------------------
12+
13+ func ExampleNew_eval32_one_dimmention () {
14+ const (
15+ seed = 100
16+ smoothness = 100
17+ )
1118
1219 p := opensimplex .New (seed )
1320
14- for x := 0. ; x < 3 ; x ++ {
15- fmt .Printf ("float32: %0.0f;%0. 4f\n " , x , p .Eval32 (float32 ( x / 10 ) ))
21+ for x := float32 ( 0 ) ; x < 3 ; x ++ {
22+ fmt .Printf ("%0.4f\n " , p .Eval32 (x / smoothness ))
1623 }
1724
18- for x := 0. ; x < 3 ; x ++ {
19- fmt .Printf ("float64: %0.0f;%0.4f\n " , x , p .Eval64 (x / 10 ))
25+ // Output:
26+ // 0.0000
27+ // 0.0102
28+ // 0.0204
29+ }
30+
31+ func ExampleNew_eval32_two_dimmentions () {
32+ const (
33+ seed = 100
34+ smoothness = 100
35+ )
36+
37+ p := opensimplex .New (seed )
38+
39+ for y := float32 (0 ); y < 2 ; y ++ {
40+ for x := float32 (0 ); x < 2 ; x ++ {
41+ fmt .Printf (
42+ "%0.4f\n " ,
43+ p .Eval32 (x / smoothness , y / smoothness ),
44+ )
45+ }
2046 }
2147
2248 // Output:
23- // float32: 0;0.0000
24- // float32: 1;0.0950
25- // float32: 2;0.1385
26- // float64: 0;0.0000
27- // float64: 1;0.0950
28- // float64: 2;0.1385
49+ // 0000
50+ // 0.0170
51+ // -0.0068
52+ // 0.010
2953}
3054
31- func ExampleNew_three_dimmention () {
32- const seed = 100
55+ func ExampleNew_eval32_three_dimmentions () {
56+ const (
57+ seed = 100
58+ smoothness = 100
59+ )
60+
61+ p := opensimplex .New (seed )
62+
63+ for z := float32 (0 ); z < 2 ; z ++ {
64+ for y := float32 (0 ); y < 2 ; y ++ {
65+ for x := float32 (0 ); x < 2 ; x ++ {
66+ fmt .Printf (
67+ "%0.4f\n " ,
68+ p .Eval32 (x / smoothness , y / smoothness , z / smoothness ),
69+ )
70+ }
71+ }
72+ }
73+
74+ // Output:
75+ // 0.0000
76+ // -0.0062
77+ // 0.0062
78+ // 0.0000
79+ // -0.0171
80+ // -0.0233
81+ // -0.0109
82+ // -0.0171
83+ }
84+
85+ func ExampleNew_eval32_more_than_three_dimmentions () {
86+ const (
87+ seed = 100
88+ )
89+
90+ p := opensimplex .New (seed )
91+
92+ // It only supports up to three dimmentions.
93+ // OpenSimplex itself supports more but currently we strictly limit it to three.
94+ fmt .Printf ("%0.0f" , p .Eval32 (0.0001 , 0.0001 , 0.0001 , 0.0001 ))
95+
96+ // Output: 0
97+ }
98+
99+ // -----------------------------------------------------------------------------
100+ // Noise.Eval64 implementation test
101+ // -----------------------------------------------------------------------------
102+
103+ func ExampleNew_eval64_one_dimmention () {
104+ const (
105+ seed = 100
106+ smoothness = 100
107+ )
108+
109+ p := opensimplex .New (seed )
110+
111+ for x := float64 (0 ); x < 3 ; x ++ {
112+ fmt .Printf (
113+ "%0.4f\n " ,
114+ p .Eval64 (x / smoothness ),
115+ )
116+ }
117+
118+ // Output:
119+ // 0.0000
120+ // 0.0102
121+ // 0.0204
122+ }
123+
124+ func ExampleNew_eval64_two_dimmentions () {
125+ const (
126+ seed = 100
127+ smoothness = 100
128+ )
33129
34130 p := opensimplex .New (seed )
35131
36132 for x := 0. ; x < 2 ; x ++ {
37133 for y := 0. ; y < 2 ; y ++ {
38134 for z := 0. ; z < 2 ; z ++ {
39- fmt .Printf ("float32: %0.0f;%0.0f;%0.0f;%0.4f\n " , x , y , z , p .Eval32 (float32 (x / 10 ), float32 (y / 10 ), float32 (z / 10 )))
135+ fmt .Printf (
136+ "%0.4f\n " ,
137+ p .Eval64 (x / smoothness , y / smoothness , z / smoothness ),
138+ )
40139 }
41140 }
42141 }
43142
143+ // Output:
144+ // 0.0000
145+ // -0.0171
146+ // 0.0062
147+ // -0.0109
148+ // -0.0062
149+ // -0.0233
150+ // 0.0000
151+ // -0.0171
152+ }
153+
154+ func ExampleNew_eval64_three_dimmentions () {
155+ const (
156+ seed = 100
157+ smoothness = 100
158+ )
159+
160+ p := opensimplex .New (seed )
161+
44162 for x := 0. ; x < 2 ; x ++ {
45163 for y := 0. ; y < 2 ; y ++ {
46164 for z := 0. ; z < 2 ; z ++ {
47- fmt .Printf ("float64: %0.0f;%0.0f;%0.0f;%0.4f\n " , x , y , z , p .Eval64 (x / 10 , y / 10 , z / 10 ))
165+ fmt .Printf (
166+ "%0.4f\n " ,
167+ p .Eval64 (x / smoothness , y / smoothness , z / smoothness ),
168+ )
48169 }
49170 }
50171 }
51172
52173 // Output:
53- // float32: 0;0;0;0.0000
54- // float32: 0;0;1;-0.1672
55- // float32: 0;1;0;0.0607
56- // float32: 0;1;1;-0.1040
57- // float32: 1;0;0;-0.0611
58- // float32: 1;0;1;-0.2227
59- // float32: 1;1;0;0.0003
60- // float32: 1;1;1;-0.1585
61- // float64: 0;0;0;0.0000
62- // float64: 0;0;1;-0.1672
63- // float64: 0;1;0;0.0607
64- // float64: 0;1;1;-0.1040
65- // float64: 1;0;0;-0.0611
66- // float64: 1;0;1;-0.2227
67- // float64: 1;1;0;0.0003
68- // float64: 1;1;1;-0.1585
174+ // 0.0000
175+ // -0.0171
176+ // 0.0062
177+ // -0.0109
178+ // -0.0062
179+ // -0.0233
180+ // 0.0000
181+ // -0.0171
182+ }
183+
184+ func ExampleNew_eval64_more_than_three_dimmentions () {
185+ const (
186+ seed = 100
187+ )
188+
189+ p := opensimplex .New (seed )
190+
191+ // It only supports up to three dimmentions.
192+ // OpenSimplex itself supports more but currently we strictly limit it to three.
193+ fmt .Printf ("%0.0f" , p .Eval64 (0.0001 , 0.0001 , 0.0001 , 0.0001 ))
194+
195+ // Output: 0
69196}
0 commit comments