rubyllipse 1.0.4 → 1.0.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/lib/rubyllipse.rb +32 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c822847ee1fcfc6d7c08eaa75ef0defc1c000924cc7397d347cd304691538062
4
- data.tar.gz: 8582215f2cd55512d882b0dbc40b8bbf362b856b1bcb247df9ce648cb6564556
3
+ metadata.gz: 3738c04c84d4f5266f64bc14349d7c5e781a80da94eba257398dd986ba85afb8
4
+ data.tar.gz: f381cca3160f7bb0119afc2686f98404984dea1aa6c73dd2c9e4a94cac4f319a
5
5
  SHA512:
6
- metadata.gz: 44b5acc4eed99686e01deca56ad769f64a34814dea3c3cfd1ebd1fb8ad97961e8a5c24072346edf01b607ebd6fd30bd06cb5cbd12570dd790c6896c38c7b91d3
7
- data.tar.gz: 4c29b9018cef4962ffe92497e06aa43754623e41a510ad2fbca481049835ea4ef4b0e7b134eca86b53fcfe51fa8d4a821105f4080c2f65864ea6b0688bb9ccbf
6
+ metadata.gz: 5c059eb8eb22d82b2b5ab3ff00c0c3cb967541c2d36a556db78edc4908d6b872580c99fb72fe38ded41fc0bf3c10443ae03cfe95399595d53c8021f2bee3d758
7
+ data.tar.gz: 0d28b11b78d542c37910635a15f16586f6d8c8c798d6b0887a9c9d8707fd16df89683f1c628b4466b8e040c1c8cafe5806b7cfc61f856c288a4cd9e44797a4d1
data/README.md CHANGED
@@ -15,7 +15,9 @@ One of the most important aspects of an ```Ellipse``` object is the ```form``` a
15
15
 
16
16
  Another important method is ```give_function!```. It returns a string for the purpose of mainly displaying the function of the ```Ellipse``` object.
17
17
 
18
- You can easily find a point by using the ```get_ordinates_from(abscissa)``` for example: ```Rubyllipse::Ellipse::new(10, 2, [3,3], form:'vertical')::get_ordinates_from(3)``` will return ```[13.0, -7]```. (Added in 1.0.4)
18
+ You can easily find a point by using the ```get_ordinates_for(abscissa)``` for example: ```Rubyllipse::Ellipse::new(10, 2, [3,3], form:'vertical')::get_ordinates_for(3)``` will return ```[13.0, -7]``` and ```get_abscissas_for(ordinate)``` is what you think it is. (Added in 1.0.4 and 1.0.5)
19
+
20
+ You can also compute the points of intersection for the ellipse and the x, y axis with; ```Ellipse.pointsof_intersection_for_x``` and ```Ellipse.pointsof_intersection_for_y```. (added in 1.0.5)
19
21
 
20
22
  Other methods are for accessing the object's attributes and don't need further explanation.
21
23
 
@@ -109,7 +109,7 @@ module Rubyllipse
109
109
  return
110
110
  end
111
111
 
112
- def get_ordinates_from(abscissa)
112
+ def get_ordinates_for(abscissa)
113
113
  abscissa = Float(abscissa)
114
114
 
115
115
  c_x = @center[0]
@@ -134,9 +134,37 @@ module Rubyllipse
134
134
  end
135
135
 
136
136
 
137
- ##new##
138
- def rotate(rotation_angle)
139
- end
137
+ def get_abscissas_for(ordinate)
138
+ ordinate = Float(ordinate)
139
+
140
+ c_x = @center[0]
141
+ c_y = @center[1]
142
+ if @form == 'horizontal'
143
+ a = @minor_radius**2
144
+ b = @major_radius**2
145
+ elsif @form == 'vertical'
146
+ a = @major_radius**2
147
+ b = @minor_radius**2
148
+ end
149
+
150
+ begin
151
+ abscissa1 = Math.sqrt(b)*Math.sqrt(1-((ordinate-c_y)**2/a))+c_x
152
+ abscissa2 = 2*@center[0]-abscissa1
153
+ abscissas = [abscissa1, abscissa2]
154
+ rescue
155
+ puts "this ellipse is not defined for value: #{ordinate}"
156
+ end
157
+
158
+ return abscissas
159
+ end
160
+
161
+ def pointsof_intersection_for_y()
162
+ return [[0, self.get_ordinates_for(0)[0]], [0, self.get_ordinates_for(0)[1]]]
163
+ end
164
+
165
+ def pointsof_intersection_for_x()
166
+ return [[self.get_abscissas_for(0)[0], 0], [self.get_abscissas_for(0)[1], 0]]
167
+ end
140
168
  end
141
169
  end
142
170
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyllipse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burzum
@@ -40,5 +40,5 @@ requirements: []
40
40
  rubygems_version: 3.1.2
41
41
  signing_key:
42
42
  specification_version: 4
43
- summary: A gem for managing ellipses, this version excludes rotated ellipses.
43
+ summary: A gem for managing ellipses, this version still excludes rotated ellipses.
44
44
  test_files: []