rubyllipse 1.0.3 → 1.0.4
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 +4 -1
- data/lib/rubyllipse.rb +37 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c822847ee1fcfc6d7c08eaa75ef0defc1c000924cc7397d347cd304691538062
|
4
|
+
data.tar.gz: 8582215f2cd55512d882b0dbc40b8bbf362b856b1bcb247df9ce648cb6564556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44b5acc4eed99686e01deca56ad769f64a34814dea3c3cfd1ebd1fb8ad97961e8a5c24072346edf01b607ebd6fd30bd06cb5cbd12570dd790c6896c38c7b91d3
|
7
|
+
data.tar.gz: 4c29b9018cef4962ffe92497e06aa43754623e41a510ad2fbca481049835ea4ef4b0e7b134eca86b53fcfe51fa8d4a821105f4080c2f65864ea6b0688bb9ccbf
|
data/README.md
CHANGED
@@ -15,8 +15,11 @@ 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)
|
19
|
+
|
18
20
|
Other methods are for accessing the object's attributes and don't need further explanation.
|
19
21
|
|
22
|
+
|
20
23
|
## Notes
|
21
24
|
If you used the module and found something odd, bad, please send me an e-mail; I am still new to Ruby.
|
22
|
-
|
25
|
+
|
data/lib/rubyllipse.rb
CHANGED
@@ -14,6 +14,9 @@ module Rubyllipse
|
|
14
14
|
elsif @form == 'vertical'
|
15
15
|
@vertexes = [[@center[0], @center[0]+@major_radius], [@center[0], @center[0]-@major_radius]]
|
16
16
|
@co_vertexes = [[@center[0]+@minor_radius, @center[1]], [@center[0]-@minor_radius, @center[1]]]
|
17
|
+
elsif @form == 'tilted'
|
18
|
+
@vertexes = vertexes
|
19
|
+
@co_vertexes = co_vertexes
|
17
20
|
end
|
18
21
|
|
19
22
|
@radii = [@major_radius, @minor_radius]
|
@@ -29,8 +32,10 @@ module Rubyllipse
|
|
29
32
|
@focii = [[@center[0]+@focal_length, @center[1]], [@center[0]-@focal_length, @center[1]]]
|
30
33
|
elsif @form == 'vertical'
|
31
34
|
@focii = [[@center[0], @center[1]+@focal_length], [@center[0], @center[1]-@focal_length]]
|
35
|
+
elsif @form == 'tilted'
|
36
|
+
@focii = focii
|
32
37
|
end
|
33
|
-
|
38
|
+
|
34
39
|
@eccentricity = Float(@focal_length)/@major_radius
|
35
40
|
end
|
36
41
|
|
@@ -92,20 +97,48 @@ module Rubyllipse
|
|
92
97
|
return equation
|
93
98
|
end
|
94
99
|
|
95
|
-
def move_horizontally(distance)
|
100
|
+
def move_horizontally!(distance)
|
96
101
|
@center = [@center[0]+distance, @center[1]]
|
97
102
|
self.initialize(@major_radius, @minor_radius, @center, form:@form)
|
98
103
|
return
|
99
104
|
end
|
100
105
|
|
101
|
-
def move_vertically(distance)
|
106
|
+
def move_vertically!(distance)
|
102
107
|
@center = [@center[0], @center[1]+distance]
|
103
108
|
self.initialize(@major_radius, @minor_radius, @center, form:@form)
|
104
109
|
return
|
105
110
|
end
|
111
|
+
|
112
|
+
def get_ordinates_from(abscissa)
|
113
|
+
abscissa = Float(abscissa)
|
114
|
+
|
115
|
+
c_x = @center[0]
|
116
|
+
c_y = @center[1]
|
117
|
+
if @form == 'horizontal'
|
118
|
+
a = @minor_radius**2
|
119
|
+
b = @major_radius**2
|
120
|
+
elsif @form == 'vertical'
|
121
|
+
a = @major_radius**2
|
122
|
+
b = @minor_radius**2
|
123
|
+
end
|
124
|
+
|
125
|
+
begin
|
126
|
+
ordinate1 = Math.sqrt(a)*Math.sqrt(1-((abscissa-c_x)**2/b))+c_y
|
127
|
+
ordinate2 = 2*@center[1]-ordinate1
|
128
|
+
ordinates = [ordinate1, ordinate2]
|
129
|
+
rescue
|
130
|
+
puts "this ellipse is not defined for value: #{abscissa}"
|
131
|
+
end
|
132
|
+
|
133
|
+
return ordinates
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
##new##
|
138
|
+
def rotate(rotation_angle)
|
139
|
+
end
|
106
140
|
end
|
107
141
|
end
|
108
|
-
|
109
142
|
|
110
143
|
|
111
144
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burzum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -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 ellipses, this version excludes rotated ellipses.
|
43
|
+
summary: A gem for managing ellipses, this version excludes rotated ellipses.
|
44
44
|
test_files: []
|