grid_generator 0.2.10 → 0.2.11
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 +33 -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: 4b4decfd16c0f0358a935123fed5fb0a190d2379d14a37b83e2f0c958d41a624
|
4
|
+
data.tar.gz: 50883416a3a299e9ea384b14777eef77d1767ffb22ff11b7449fb1d79f6c8bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a35b02c742ec97e40f5b674232ab528b00fe7ee401ae47340b1bc0539e29cd3c75e2bfa31349dc9a66a3b6e51da3d59209f3aebbf1d06423b168aea0343e083
|
7
|
+
data.tar.gz: 12e781e8a1d8c0b125b4395a0bdf20b29636a632f2a4b288226f718a6ddac223756db2a06a078797f2dbaf0ec786673c126da1e4fdea780cb29acc6bd3f28f13
|
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,10 +107,29 @@ 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
|
+
|
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
|
119
|
+
end
|
120
|
+
end
|
113
121
|
|
114
|
-
|
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
|
+
angle = Math::PI * 0.4
|
130
|
+
rotator = GridGenerator::Rotator.new(angle: angle, rotation_point: rotation_point)
|
131
|
+
top_right_face_lines_raw.map do |l|
|
132
|
+
rotator.rotate(l) + offset
|
115
133
|
end
|
116
134
|
end
|
117
135
|
|
@@ -126,10 +144,7 @@ module GridGenerator
|
|
126
144
|
ab_intervals = GridGenerator::Helper.intervals(a,b,2)
|
127
145
|
cd_intervals = GridGenerator::Helper.intervals(c,d,2)
|
128
146
|
|
129
|
-
|
130
|
-
line_end = cd_intervals.first + offset
|
131
|
-
|
132
|
-
GridGenerator::Line.new(a: line_start, b: line_end)
|
147
|
+
GridGenerator::Line.new(a: ab_intervals[-1], b: cd_intervals[0]) + offset
|
133
148
|
end
|
134
149
|
end
|
135
150
|
|
@@ -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.11
|
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
|