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.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/rubyllipse.rb +32 -4
- 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: 3738c04c84d4f5266f64bc14349d7c5e781a80da94eba257398dd986ba85afb8
|
|
4
|
+
data.tar.gz: f381cca3160f7bb0119afc2686f98404984dea1aa6c73dd2c9e4a94cac4f319a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 ```
|
|
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
|
|
data/lib/rubyllipse.rb
CHANGED
|
@@ -109,7 +109,7 @@ module Rubyllipse
|
|
|
109
109
|
return
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
def
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
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: []
|