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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d34bf3e232b6ba728e1dfb968dc9f176932955a8ef93d9b796c5233f6ed495d
4
- data.tar.gz: f135d7666604b09947e3be7465bdeb4831b8d1b0d49aca20ee4d17346fa53e61
3
+ metadata.gz: 4b4decfd16c0f0358a935123fed5fb0a190d2379d14a37b83e2f0c958d41a624
4
+ data.tar.gz: 50883416a3a299e9ea384b14777eef77d1767ffb22ff11b7449fb1d79f6c8bae
5
5
  SHA512:
6
- metadata.gz: 12f2aea851e3975e67ba4ed59451f6810f1f6c9b7cecee1cac673139b1fb3c76ae2b70b8bb0b37d9bee41fd198674308536c1ae74aa657a3de9f1055c1cec034
7
- data.tar.gz: dd555ce643c53dda16d03d49e6373f140cbedd6fcaccbf2a53447b72a68c781d144b6b78d4be362d7e830ce539b4b44d9a27d19b530a958f9af8f2f2d6287ec8
6
+ metadata.gz: 4a35b02c742ec97e40f5b674232ab528b00fe7ee401ae47340b1bc0539e29cd3c75e2bfa31349dc9a66a3b6e51da3d59209f3aebbf1d06423b168aea0343e083
7
+ data.tar.gz: 12e781e8a1d8c0b125b4395a0bdf20b29636a632f2a4b288226f718a6ddac223756db2a06a078797f2dbaf0ec786673c126da1e4fdea780cb29acc6bd3f28f13
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grid_generator (0.2.10)
4
+ grid_generator (0.2.11)
5
5
  matrix (~> 0.4.2)
6
6
 
7
7
  GEM
@@ -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
- # for svg
91
- def connecting_lines
92
- pentagon_points.each_with_index.map do |p, i|
93
- d = decagon_points[i*2]
94
- line_start = p + offset
95
- line_end = d + offset
96
- GridGenerator::Line.new(a: line_start, b: line_end)
97
- end
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
- # for svg
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
- line_start = ab_intervals.last + offset
112
- line_end = cd_intervals.first + offset
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
- GridGenerator::Line.new(a: line_start, b: line_end)
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
- line_start = ab_intervals.last + offset
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
- def rotate(point)
15
- # subtract rotation point to move point towards 0,0, rotate, then add to move back
16
- (matrix * (point - rotation_point)) + rotation_point
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GridGenerator
4
- VERSION = "0.2.10"
4
+ VERSION = "0.2.11"
5
5
  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.10
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-04 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matrix