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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20c75acadd433ac0996bca94f79b4c0cc2d761eeefb2936e2012561518b35133
4
- data.tar.gz: ba339e5c041970bacc1975f5cad315d25bee2b7129e2718f5b7f1222e0ab5e95
3
+ metadata.gz: '050718e62b797b07faca97d197b27e721c7c388f2709991c79d7dde62fd51418'
4
+ data.tar.gz: '08c2fc2a2e9aa1262ff5b7ccf5e78564dda5a32cb59bf00d78d00f5b61c667ad'
5
5
  SHA512:
6
- metadata.gz: 39408dd22688cbc4555394b44b323cabce3413cf50ff5611e76dbbeb5b64f366fdaec40bf7ea2c69245b65ddba2f2cdb1d2008d9c41aded5ee2db16b2d8aca45
7
- data.tar.gz: 4683cbe6e067d3aec58aefe3a816ddf11034dab19688294561989bccbcf03ca9389caeade1e1ca002cbb3b83fe7b0d533153fddf0b26f7f8baa046a9e9e7090d
6
+ metadata.gz: 3d0c2eb96e2616998d856d95c5e758f648b86f8cf47f0f2cdb63cbd4ccf69ff72766ae50f41651269e8da5ec559593ae1660607af1e05f03f1fc92fe89b0984c
7
+ data.tar.gz: b43780da3325eb8341ee5ef08818301a7d9cbac365cd19a34dc8dd1ef168ae1b6409107d1f2517144246504da8f3455f53cf965e45693abf3f4b6e4eff1e2acf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grid_generator (0.2.6)
4
+ grid_generator (0.2.7)
5
5
  matrix (~> 0.4.2)
6
6
 
7
7
  GEM
@@ -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
- @connecting_lines ||= pentagon_points.each_with_index.map do |p, i|
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GridGenerator
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grid_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Humphreys