grid_generator 0.2.20 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/grid_generator/megaminx/face_projection.rb +104 -11
- data/lib/grid_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97090c1a79ca2451c11e7e1414f93ebdd6fece49ac097fa419e7d2eee589ae3d
|
4
|
+
data.tar.gz: d549f0e473b1741441ec85c8945d6d817f1dae05c7806bb87ea790fde8de0c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 500c2d44cf6fe1e32078fe1723a9714448bcd1da7086b9543426cfc58af38aa63a6fac7e9f2b0a36eda4420d6d6e44f2d53a209b494dfbae48adc442df4042f0
|
7
|
+
data.tar.gz: f3112da44f9b558b4ec7c0c162252f05586dab11fa693548fe245e1bde80bad75de06cbc4d5acc03b0a988d16939803e955406fb0b1b0c6ac3b3e96b1c9bd9b8
|
data/Gemfile.lock
CHANGED
@@ -9,14 +9,18 @@ module GridGenerator
|
|
9
9
|
class FaceProjection
|
10
10
|
# units 30 - pentagon 90 - megaminx - 150
|
11
11
|
# units * 5
|
12
|
-
def initialize(x:, y:, units:, front_face_elements: "", top_right_face_elements: "")
|
12
|
+
def initialize(x:, y:, units:, front_face_elements: "", top_right_face_elements: "", right_face_elements: "", down_face_elements: "", left_face_elements: "", top_left_face_elements: "")
|
13
13
|
@x, @y = x, y
|
14
14
|
@units = units
|
15
15
|
@front_face_elements = front_face_elements.split(',')
|
16
16
|
@top_right_face_elements = top_right_face_elements.split(',')
|
17
|
+
@right_face_elements = right_face_elements.split(',')
|
18
|
+
@down_face_elements = down_face_elements.split(',')
|
19
|
+
@left_face_elements = left_face_elements.split(',')
|
20
|
+
@top_left_face_elements = top_left_face_elements.split(',')
|
17
21
|
end
|
18
22
|
|
19
|
-
attr_reader :x, :y, :units, :front_face_elements, :top_right_face_elements
|
23
|
+
attr_reader :x, :y, :units, :front_face_elements, :top_right_face_elements, :right_face_elements, :down_face_elements, :left_face_elements, :top_left_face_elements
|
20
24
|
|
21
25
|
def offset
|
22
26
|
@offset ||= Matrix.column_vector([x, y])
|
@@ -78,6 +82,26 @@ module GridGenerator
|
|
78
82
|
]
|
79
83
|
end
|
80
84
|
|
85
|
+
def right_pentagon_points
|
86
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.4, rotation_point: rotation_point)
|
87
|
+
@right_pentagon_points ||= top_right_pentagon_points.map { |p| rotator.rotate(p) }
|
88
|
+
end
|
89
|
+
|
90
|
+
def down_pentagon_points
|
91
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.8, rotation_point: rotation_point)
|
92
|
+
@down_pentagon_points ||= top_right_pentagon_points.map { |p| rotator.rotate(p) }
|
93
|
+
end
|
94
|
+
|
95
|
+
def left_pentagon_points
|
96
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.2, rotation_point: rotation_point)
|
97
|
+
@left_pentagon_points ||= top_right_pentagon_points.map { |p| rotator.rotate(p) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def top_left_pentagon_points
|
101
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.6, rotation_point: rotation_point)
|
102
|
+
@top_left_pentagon_points ||= top_right_pentagon_points.map { |p| rotator.rotate(p) }
|
103
|
+
end
|
104
|
+
|
81
105
|
def front_face_lines_raw
|
82
106
|
(0..4).map do |i|
|
83
107
|
a = pentagon_points[i-1] # offset one so first line is top right
|
@@ -93,7 +117,7 @@ module GridGenerator
|
|
93
117
|
end
|
94
118
|
|
95
119
|
def top_right_face_lines_raw
|
96
|
-
(0..4).map do |i|
|
120
|
+
@top_right_face_lines_raw ||= (0..4).map do |i|
|
97
121
|
a = top_right_pentagon_points[i-1] # offset by one so first line is top right
|
98
122
|
b = top_right_pentagon_points[(i)%5]
|
99
123
|
c = top_right_pentagon_points[(i+1)%5]
|
@@ -106,6 +130,26 @@ module GridGenerator
|
|
106
130
|
end
|
107
131
|
end
|
108
132
|
|
133
|
+
def right_face_lines_raw
|
134
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.4, rotation_point: rotation_point)
|
135
|
+
@right_face_lines_raw ||= top_right_face_lines_raw.map { |l| rotator.rotate(l) }
|
136
|
+
end
|
137
|
+
|
138
|
+
def down_face_lines_raw
|
139
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.8, rotation_point: rotation_point)
|
140
|
+
@down_face_lines_raw ||= top_right_face_lines_raw.map { |l| rotator.rotate(l) }
|
141
|
+
end
|
142
|
+
|
143
|
+
def left_face_lines_raw
|
144
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.2, rotation_point: rotation_point)
|
145
|
+
@left_face_lines_raw ||= top_right_face_lines_raw.map { |l| rotator.rotate(l) }
|
146
|
+
end
|
147
|
+
|
148
|
+
def top_left_face_lines_raw
|
149
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.6, rotation_point: rotation_point)
|
150
|
+
@top_left_face_lines_raw ||= top_right_face_lines_raw.map { |l| rotator.rotate(l) }
|
151
|
+
end
|
152
|
+
|
109
153
|
# for svg
|
110
154
|
def connecting_lines
|
111
155
|
pentagon_points.each_with_index.map do |p, i|
|
@@ -121,26 +165,22 @@ module GridGenerator
|
|
121
165
|
|
122
166
|
# for svg
|
123
167
|
def right_face_lines
|
124
|
-
|
125
|
-
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
168
|
+
right_face_lines_raw.map { |l| l + offset }
|
126
169
|
end
|
127
170
|
|
128
171
|
# for svg
|
129
172
|
def down_face_lines
|
130
|
-
|
131
|
-
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
173
|
+
down_face_lines_raw.map { |l| l + offset }
|
132
174
|
end
|
133
175
|
|
134
176
|
# for svg
|
135
177
|
def left_face_lines
|
136
|
-
|
137
|
-
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
178
|
+
left_face_lines_raw.map { |l| l + offset }
|
138
179
|
end
|
139
180
|
|
140
181
|
# for svg
|
141
182
|
def top_left_face_lines
|
142
|
-
|
143
|
-
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
183
|
+
top_left_face_lines_raw.map { |l| l + offset }
|
144
184
|
end
|
145
185
|
|
146
186
|
# for svg
|
@@ -172,6 +212,7 @@ module GridGenerator
|
|
172
212
|
end.compact
|
173
213
|
end
|
174
214
|
|
215
|
+
# for svg
|
175
216
|
def top_right_face_element_shapes
|
176
217
|
top_right_face_elements.each_with_index.map do |element, i|
|
177
218
|
GridGenerator::Megaminx::FaceElementFactory.new(
|
@@ -184,6 +225,58 @@ module GridGenerator
|
|
184
225
|
).build unless element == '-'
|
185
226
|
end.compact
|
186
227
|
end
|
228
|
+
|
229
|
+
def right_face_element_shapes
|
230
|
+
right_face_elements.each_with_index.map do |element, i|
|
231
|
+
GridGenerator::Megaminx::FaceElementFactory.new(
|
232
|
+
x: x,
|
233
|
+
y: y,
|
234
|
+
index: i,
|
235
|
+
face_points: right_pentagon_points,
|
236
|
+
face_lines: right_face_lines_raw,
|
237
|
+
face: element
|
238
|
+
).build unless element == '-'
|
239
|
+
end.compact
|
240
|
+
end
|
241
|
+
|
242
|
+
def down_face_element_shapes
|
243
|
+
down_face_elements.each_with_index.map do |element, i|
|
244
|
+
GridGenerator::Megaminx::FaceElementFactory.new(
|
245
|
+
x: x,
|
246
|
+
y: y,
|
247
|
+
index: i,
|
248
|
+
face_points: down_pentagon_points,
|
249
|
+
face_lines: down_face_lines_raw,
|
250
|
+
face: element
|
251
|
+
).build unless element == '-'
|
252
|
+
end.compact
|
253
|
+
end
|
254
|
+
|
255
|
+
def left_face_element_shapes
|
256
|
+
left_face_elements.each_with_index.map do |element, i|
|
257
|
+
GridGenerator::Megaminx::FaceElementFactory.new(
|
258
|
+
x: x,
|
259
|
+
y: y,
|
260
|
+
index: i,
|
261
|
+
face_points: left_pentagon_points,
|
262
|
+
face_lines: left_face_lines_raw,
|
263
|
+
face: element
|
264
|
+
).build unless element == '-'
|
265
|
+
end.compact
|
266
|
+
end
|
267
|
+
|
268
|
+
def top_left_face_element_shapes
|
269
|
+
top_left_face_elements.each_with_index.map do |element, i|
|
270
|
+
GridGenerator::Megaminx::FaceElementFactory.new(
|
271
|
+
x: x,
|
272
|
+
y: y,
|
273
|
+
index: i,
|
274
|
+
face_points: top_left_pentagon_points,
|
275
|
+
face_lines: top_left_face_lines_raw,
|
276
|
+
face: element
|
277
|
+
).build unless element == '-'
|
278
|
+
end.compact
|
279
|
+
end
|
187
280
|
end
|
188
281
|
end
|
189
282
|
end
|