Commit 31b3e9d 1 parent f335827 commit 31b3e9d Copy full SHA for 31b3e9d
File tree 3 files changed +56
-2
lines changed
3 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,18 @@ def tan
100
100
Math . tan ( radians )
101
101
end
102
102
103
+ def positive?
104
+ radians > 0
105
+ end
106
+
107
+ def negative?
108
+ radians < 0
109
+ end
110
+
111
+ def zero?
112
+ radians . zero?
113
+ end
114
+
103
115
def str ( format )
104
116
case format
105
117
when :dms then to_dms ( degrees ) . format
Original file line number Diff line number Diff line change @@ -12,9 +12,9 @@ class << self
12
12
# Edition: MIT Press
13
13
# Chapter: 4 - Orbits and Coordinate Systems
14
14
def adjustement_for_arctangent ( y , x , angle )
15
- return angle if y . degrees . positive? && x . degrees . positive?
15
+ return angle if y . positive? && x . positive?
16
16
17
- if y . degrees . negative? && x . degrees . positive?
17
+ if y . negative? && x . positive?
18
18
return Angle . as_degrees ( angle . degrees + 360 )
19
19
end
20
20
Original file line number Diff line number Diff line change 193
193
end
194
194
end
195
195
196
+ describe "#positive?" do
197
+ it "returns true when the angle is positive" do
198
+ expect ( described_class . as_degrees ( 90 ) . positive? ) . to be true
199
+ end
200
+
201
+ it "returns false when the angle is negative" do
202
+ expect ( described_class . as_degrees ( -90 ) . positive? ) . to be false
203
+ end
204
+
205
+ it "returns famse when the angle has a zero value" do
206
+ expect ( described_class . as_degrees ( 0 ) . positive? ) . to be false
207
+ end
208
+ end
209
+
210
+ describe "#negative?" do
211
+ it "returns false when the angle is positive" do
212
+ expect ( described_class . as_degrees ( 90 ) . negative? ) . to be false
213
+ end
214
+
215
+ it "returns true when the angle is negative" do
216
+ expect ( described_class . as_degrees ( -90 ) . negative? ) . to be true
217
+ end
218
+
219
+ it "returns false when the angle has a zero value" do
220
+ expect ( described_class . as_degrees ( 0 ) . negative? ) . to be false
221
+ end
222
+ end
223
+
224
+ describe "#zero?" do
225
+ it "returns false when the angle is positive" do
226
+ expect ( described_class . as_degrees ( 90 ) . zero? ) . to be false
227
+ end
228
+
229
+ it "returns false when the angle is negative" do
230
+ expect ( described_class . as_degrees ( -90 ) . zero? ) . to be false
231
+ end
232
+
233
+ it "returns true when the angle has a zero value" do
234
+ expect ( described_class . as_degrees ( 0 ) . zero? ) . to be true
235
+ end
236
+ end
237
+
196
238
describe "#str" do
197
239
it "returns a String" do
198
240
angle = described_class . as_degrees ( 180 )
You can’t perform that action at this time.
0 commit comments