grid_generator 0.2.6 → 0.2.7
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/helper.rb +15 -0
- data/lib/grid_generator/megaminx/face_projection.rb +24 -1
- 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: '050718e62b797b07faca97d197b27e721c7c388f2709991c79d7dde62fd51418'
|
4
|
+
data.tar.gz: '08c2fc2a2e9aa1262ff5b7ccf5e78564dda5a32cb59bf00d78d00f5b61c667ad'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d0c2eb96e2616998d856d95c5e758f648b86f8cf47f0f2cdb63cbd4ccf69ff72766ae50f41651269e8da5ec559593ae1660607af1e05f03f1fc92fe89b0984c
|
7
|
+
data.tar.gz: b43780da3325eb8341ee5ef08818301a7d9cbac365cd19a34dc8dd1ef168ae1b6409107d1f2517144246504da8f3455f53cf965e45693abf3f4b6e4eff1e2acf
|
data/Gemfile.lock
CHANGED
@@ -3,6 +3,21 @@ module GridGenerator
|
|
3
3
|
def self.distance(a, b)
|
4
4
|
Math.sqrt((b[0,0] - a[0,0])**2 + (b[1,0] - a[1,0])**2)
|
5
5
|
end
|
6
|
+
|
7
|
+
# 1 -> / 2 |
|
8
|
+
# 2 -> / 3 |
|
9
|
+
def self.intervals(a, b, i)
|
10
|
+
dx = b[0,0] - a[0,0]
|
11
|
+
dy = b[1,0] - a[1,0]
|
12
|
+
|
13
|
+
Array.new(i) do |n|
|
14
|
+
interval_x = dx / i
|
15
|
+
interval_y = dy / i
|
16
|
+
x = a[0,0] + (n + 1) * interval_x
|
17
|
+
y = a[1,0] + (n + 1) * interval_y
|
18
|
+
Matrix.column_vector([x, y])
|
19
|
+
end
|
20
|
+
end
|
6
21
|
end
|
7
22
|
end
|
8
23
|
|
@@ -78,7 +78,7 @@ module GridGenerator
|
|
78
78
|
|
79
79
|
# for svg
|
80
80
|
def connecting_lines
|
81
|
-
|
81
|
+
pentagon_points.each_with_index.map do |p, i|
|
82
82
|
d = decagon_points[i*2]
|
83
83
|
offset_p = p + offset
|
84
84
|
offset_d = d + offset
|
@@ -91,6 +91,28 @@ module GridGenerator
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
def front_face_lines
|
95
|
+
(0..4).map do |i|
|
96
|
+
a = pentagon_points[i]
|
97
|
+
b = pentagon_points[(i+1)%5]
|
98
|
+
c = pentagon_points[(i+2)%5]
|
99
|
+
d = pentagon_points[(i+3)%5]
|
100
|
+
|
101
|
+
ab_intervals = GridGenerator::Helper.intervals(a,b,2)
|
102
|
+
cd_intervals = GridGenerator::Helper.intervals(c,d,2)
|
103
|
+
|
104
|
+
line_start = ab_intervals.last + offset
|
105
|
+
line_end = cd_intervals.first + offset
|
106
|
+
|
107
|
+
GridGenerator::BaseLine.new(
|
108
|
+
x1: line_start[0,0],
|
109
|
+
y1: line_start[1,0],
|
110
|
+
x2: line_end[0,0],
|
111
|
+
y2: line_end[1,0]
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
94
116
|
# for svg
|
95
117
|
def decagon_points_string
|
96
118
|
decagon_points.map { |p| p + offset }.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
|
@@ -100,6 +122,7 @@ module GridGenerator
|
|
100
122
|
def pentagon_points_string
|
101
123
|
pentagon_points.map { |p| p + offset }.map { |p| "#{p[0,0].round},#{p[1,0].round}" }.join(' ')
|
102
124
|
end
|
125
|
+
|
103
126
|
end
|
104
127
|
end
|
105
128
|
end
|