grid_generator 0.2.10 → 0.2.12
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/line.rb +10 -0
- data/lib/grid_generator/megaminx/face_projection.rb +48 -18
- data/lib/grid_generator/rotator.rb +12 -3
- data/lib/grid_generator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2e4ae2eb50929918c9de39208ddf4eaccaafdc56c53dc13774d398aa70f52e3
|
4
|
+
data.tar.gz: 5a7c155861ff0725f985660ef3727d18e834a42f770c8e030f73c8c145e1e88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adbf1a09e9839148113816c35920bad39d61128bb20f9dac8a30b0af6e8953cab5103cd7e682ea050a6a6de61ae9fecfb501bc1172b662b8642a749e8758d6b
|
7
|
+
data.tar.gz: a096f60c701cb163b94c79034961cefc8b3f6f65554dbd7f530fe4723878eae1377a1b32891c51ee9fd719697a391106b5916a2b7904df6ad101ac4953b0e4b1
|
data/Gemfile.lock
CHANGED
data/lib/grid_generator/line.rb
CHANGED
@@ -12,6 +12,16 @@ module GridGenerator
|
|
12
12
|
self.b == other.b
|
13
13
|
end
|
14
14
|
|
15
|
+
def +(offset)
|
16
|
+
if offset.class == Matrix
|
17
|
+
new_a = a + offset
|
18
|
+
new_b = b + offset
|
19
|
+
self.class.new(a: new_a, b: new_b)
|
20
|
+
else
|
21
|
+
raise ArgumentError, "Offset must be Matrix"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
15
25
|
def x1
|
16
26
|
a[0,0]
|
17
27
|
end
|
@@ -87,18 +87,17 @@ module GridGenerator
|
|
87
87
|
]
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
def right_pentagon_points
|
91
|
+
@right_pentagon_points ||= [
|
92
|
+
decagon_points[2],
|
93
|
+
decagon_points[3],
|
94
|
+
decagon_points[4],
|
95
|
+
pentagon_points[2],
|
96
|
+
pentagon_points[1]
|
97
|
+
]
|
98
98
|
end
|
99
|
-
|
100
|
-
|
101
|
-
def top_right_face_lines
|
99
|
+
|
100
|
+
def top_right_face_lines_raw
|
102
101
|
(0..4).map do |i|
|
103
102
|
a = top_right_pentagon_points[i]
|
104
103
|
b = top_right_pentagon_points[(i+1)%5]
|
@@ -108,13 +107,47 @@ module GridGenerator
|
|
108
107
|
ab_intervals = GridGenerator::Helper.intervals(a,b,2)
|
109
108
|
cd_intervals = GridGenerator::Helper.intervals(c,d,2)
|
110
109
|
|
111
|
-
|
112
|
-
|
110
|
+
GridGenerator::Line.new(a: ab_intervals[-1], b: cd_intervals[0])
|
111
|
+
end
|
112
|
+
end
|
113
113
|
|
114
|
-
|
114
|
+
# for svg
|
115
|
+
def connecting_lines
|
116
|
+
pentagon_points.each_with_index.map do |p, i|
|
117
|
+
d = decagon_points[i*2]
|
118
|
+
GridGenerator::Line.new(a: p, b: d) + offset
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
122
|
+
# for svg
|
123
|
+
def top_right_face_lines
|
124
|
+
top_right_face_lines_raw.map { |l| l + offset }
|
125
|
+
end
|
126
|
+
|
127
|
+
# for svg
|
128
|
+
def right_face_lines
|
129
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.4, rotation_point: rotation_point)
|
130
|
+
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
131
|
+
end
|
132
|
+
|
133
|
+
# for svg
|
134
|
+
def down_face_lines
|
135
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 0.8, rotation_point: rotation_point)
|
136
|
+
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
137
|
+
end
|
138
|
+
|
139
|
+
# for svg
|
140
|
+
def left_face_lines
|
141
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.2, rotation_point: rotation_point)
|
142
|
+
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
143
|
+
end
|
144
|
+
|
145
|
+
# for svg
|
146
|
+
def top_left_face_lines
|
147
|
+
rotator = GridGenerator::Rotator.new(angle: Math::PI * 1.6, rotation_point: rotation_point)
|
148
|
+
top_right_face_lines_raw.map { |l| rotator.rotate(l) + offset }
|
149
|
+
end
|
150
|
+
|
118
151
|
# for svg
|
119
152
|
def front_face_lines
|
120
153
|
(0..4).map do |i|
|
@@ -126,10 +159,7 @@ module GridGenerator
|
|
126
159
|
ab_intervals = GridGenerator::Helper.intervals(a,b,2)
|
127
160
|
cd_intervals = GridGenerator::Helper.intervals(c,d,2)
|
128
161
|
|
129
|
-
|
130
|
-
line_end = cd_intervals.first + offset
|
131
|
-
|
132
|
-
GridGenerator::Line.new(a: line_start, b: line_end)
|
162
|
+
GridGenerator::Line.new(a: ab_intervals[-1], b: cd_intervals[0]) + offset
|
133
163
|
end
|
134
164
|
end
|
135
165
|
|
@@ -11,9 +11,18 @@ module GridGenerator
|
|
11
11
|
|
12
12
|
attr_reader :angle, :matrix, :rotation_point
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
# subtract rotation point to move point towards 0,0, rotate, then add to move back
|
15
|
+
def rotate(obj)
|
16
|
+
case obj
|
17
|
+
when Matrix
|
18
|
+
(matrix * (obj - rotation_point)) + rotation_point
|
19
|
+
when GridGenerator::Line
|
20
|
+
new_a = rotate(obj.a)
|
21
|
+
new_b = rotate(obj.b)
|
22
|
+
GridGenerator::Line.new(a: new_a, b: new_b)
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Object must be Matrix or Line"
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grid_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Humphreys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matrix
|