joules 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20266cc292103a7a4ec29036bf2eb5eca74653ea
4
- data.tar.gz: df55eff3e23043443756fec9ea24ed7351313115
3
+ metadata.gz: ebea8b8abdde03c40493dc8bccd291448aae450a
4
+ data.tar.gz: 372309d709a479b124a2f45ca48fe2082cc93898
5
5
  SHA512:
6
- metadata.gz: f744ec8a76f8a7fac6c7a74295eb01e8d3f29230729b5e447ec6f72d9c0dc6f25aa39dce9eb9c476a706a195196d1ba21932e27d52f9247aea646776836628db
7
- data.tar.gz: 7f49d574908f32acb1c75332ee4f1e2d5f81413f4ad215049fc6122a820cd66386fc4039400b44857f08134bda28c136cf2fe6c254504cf0e9eb51d5fe2b175e
6
+ metadata.gz: d9b14eca944849f3a96e0d739bd2afa12d3a59d6a587a035b6696fe792c26cc3634c522c878207060afba456f1a8b5c9217a9796085a0cb70b6e434299cf3d70
7
+ data.tar.gz: 7958efaaca9e74f5d623d305cb62eaf3d37755647455fc4c3e2df6088673c89c15d354e233084c2b04313ac47e60fb20054fa20582bdc9fee3c3d7aa4e91cfd4
data/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ #### Version 0.0.1
2
+ * Added Physics formulas in kinematics, mass, weight, density, forces, momentum, impulse, energy, work, power, and pressure
3
+ * Added the following Physics constants: speed of light in free space and acceleration of free fall
4
+
5
+ #### Version 0.0.2
6
+ * Fixed publishing date in gem specification
7
+
8
+ #### Version 0.0.3
9
+ * Added the following Physics constants: permeability of free space, permittivity of free space, elementary charge, Planck constant, unified atomic mass unit, rest mass of electron, rest mass of proton, molar gas constant, avogadro constant, Boltzmann constant, and gravitational constant
10
+
11
+ #### Version 0.1.0
12
+ * Added Physics formulas in waves and thermodynamics
13
+ * Added the following Physics constants: rest mass of neutron, Stefan constant, and Wien constant
14
+ * Updated existing documentation style to YARD documentation style
15
+
16
+ #### Version 0.2.0
17
+ * Added Physics formulas in electricity
18
+ * Added geometric and conversion formulas commonly used in Physics
19
+
20
+ #### Version 0.3.0
21
+ * Added Physics formulas in quantum
22
+ * Added more geometric and conversion formulas commonly used in Physics
23
+
24
+ #### Version 0.3.1
25
+ * Added Physics formulas in gravitational fields and electric fields
26
+
27
+ #### Version 0.3.2
28
+ * Added Physics formulas in magnetic fields, stress, and strain
29
+
30
+ #### Version 0.4.0
31
+ * Added Physics formulas in circular motion
32
+
33
+ #### Version 0.4.1
34
+ * Added Physics formulas in oscillations
35
+
36
+ #### Version 0.4.2
37
+ * Added more Physics formulas in electricity and force
38
+ * Added more geometric formulas commonly used in Physics
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  ![Joules Logo](https://cloud.githubusercontent.com/assets/7763904/7764836/ef617b0a-0024-11e5-8044-3cf354a4a306.png)
2
2
 
3
- [![forthebadge](http://forthebadge.com/images/badges/built-with-ruby.svg)](http://forthebadge.com)
3
+ [![Ruby Badge](http://forthebadge.com/images/badges/built-with-ruby.svg)](http://forthebadge.com)
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/joules.svg)](http://badge.fury.io/rb/joules)
6
+ [![Inline Docs](http://inch-ci.org/github/elailai94/joules.svg?style=shields)](https://inch-ci.org/github/elailai94/Joules)
6
7
 
7
8
  ### About
8
9
  Joules is a library (gem) for providing simple Physics formulas in kinematics, forces, waves, electricity, and so much more. A selection of fundamental constants are also provided. It is written entirely in Ruby.
@@ -15,7 +16,7 @@ gem build joules.gemspec
15
16
 
16
17
  ### Library Installation
17
18
  ```Bash
18
- gem install joules-0.4.1.gem
19
+ gem install joules-0.4.2.gem
19
20
  ```
20
21
 
21
22
  ### Library Import
@@ -36,42 +37,6 @@ Joules.power(Joules.work_done(40, 2.34), 4)
36
37
  This would return 23.4.
37
38
  > Note: For documentation on usage of methods and constants, please visit [http://www.rubydoc.info/gems/joules/](http://www.rubydoc.info/gems/joules/).
38
39
 
39
- ### Change Log
40
- #### Version 0.0.1
41
- * Added Physics formulas in kinematics, mass, weight, density, forces, momentum, impulse, energy, work, power, and pressure
42
- * Added the following Physics constants: speed of light in free space and acceleration of free fall
43
-
44
- #### Version 0.0.2
45
- * Fixed publishing date in gem specification
46
-
47
- #### Version 0.0.3
48
- * Added the following Physics constants: permeability of free space, permittivity of free space, elementary charge, Planck constant, unified atomic mass unit, rest mass of electron, rest mass of proton, molar gas constant, avogadro constant, Boltzmann constant, and gravitational constant
49
-
50
- #### Version 0.1.0
51
- * Added Physics formulas in waves and thermodynamics
52
- * Added the following Physics constants: rest mass of neutron, Stefan constant, and Wien constant
53
- * Updated existing documentation style to YARD documentation style
54
-
55
- #### Version 0.2.0
56
- * Added Physics formulas in electricity
57
- * Added geometric and conversion formulas commonly used in Physics
58
-
59
- #### Version 0.3.0
60
- * Added Physics formulas in quantum
61
- * Added more geometric and conversion formulas commonly used in Physics
62
-
63
- #### Version 0.3.1
64
- * Added Physics formulas in gravitational fields and electric fields
65
-
66
- #### Version 0.3.2
67
- * Added Physics formulas in magnetic fields, stress, and strain
68
-
69
- #### Version 0.4.0
70
- * Added Physics formulas in circular motion
71
-
72
- #### Version 0.4.1
73
- * Added Physics formulas in oscillations
74
-
75
40
  ### Contribution
76
41
  Please feel free to submit any ideas, questions, or problems by reporting an issue.
77
42
 
@@ -3,13 +3,15 @@
3
3
  #
4
4
  # @description: Module for providing circular motion formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Circular motion module (circular_motion.rb)
10
10
 
11
11
  module Joules
12
12
  module_function
13
+
14
+ # @!group Circular Motion Methods
13
15
 
14
16
  # Calculates the angular velocity given linear velocity and radius.
15
17
  # @param linear_velocity [Int, Float]
@@ -157,4 +159,6 @@ module Joules
157
159
  return 0.5 * moment_of_inertia * (angular_velocity ** 2)
158
160
  end
159
161
 
162
+ # @!endgroup
163
+
160
164
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing constants
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Constants module (constants.rb)
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing conversion formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Conversion module (conversion.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Angle Conversion Methods
15
+
14
16
  # Calculates the equivalent angle in degrees given radians.
15
17
  # @param angle [Int, Float]
16
18
  # angle is in radians
@@ -33,6 +35,10 @@ module Joules
33
35
  return (angle * Math::PI) / 180
34
36
  end
35
37
 
38
+ # @!endgroup
39
+
40
+ # @!group Temperature Conversion Methods
41
+
36
42
  # Calculates the equivalent temperature in kelvins given celcius.
37
43
  # @param temperature [Int, Float]
38
44
  # temperature is in celcius
@@ -55,6 +61,10 @@ module Joules
55
61
  return temperature - 273.15
56
62
  end
57
63
 
64
+ # @!endgroup
65
+
66
+ # @!group Velocity Conversion Methods
67
+
58
68
  # Calculates the equivalent velocity in metres per second given kilometres per hour.
59
69
  # @param velocity [Int, Float]
60
70
  # velocity is in kilometres per hour
@@ -77,4 +87,6 @@ module Joules
77
87
  return (velocity * 3600) / 1000.0
78
88
  end
79
89
 
90
+ # @!endgroup
91
+
80
92
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing density formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Density module (density.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Density Methods
15
+
14
16
  # Calculates the density given mass and volume.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -29,4 +31,6 @@ module Joules
29
31
  end
30
32
  end
31
33
 
34
+ # @!endgroup
35
+
32
36
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing electric fields formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Electric fields module (electric_fields.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Electric Fields Methods
15
+
14
16
  # Calculates the electric field strength given voltage and distance between two plates.
15
17
  # @param voltage [Int, Float]
16
18
  # voltage is in volts
@@ -100,4 +102,6 @@ module Joules
100
102
  return voltage * (charge / ELEMENTARY_CHARGE)
101
103
  end
102
104
 
105
+ # @!endgroup
106
+
103
107
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing electricity formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Electricity module (electricity.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Electricity Methods
15
+
14
16
  # Calculates the current given charge and time.
15
17
  # @param charge [Int, Float]
16
18
  # charge is in coulombs
@@ -20,8 +22,9 @@ module Joules
20
22
  # return value is in amperes
21
23
  # @raise [ZeroDivisionError] if time = 0
22
24
  # @example
23
- # Joules.current(325, 5) #=> 65.0
24
- def current(charge, time)
25
+ # Joules.current_v1(325, 5) #=> 65.0
26
+ # @note There is one other method for calculating current.
27
+ def current_v1(charge, time)
25
28
  if time.zero?
26
29
  raise ZeroDivisionError.new('divided by 0')
27
30
  else
@@ -29,6 +32,24 @@ module Joules
29
32
  end
30
33
  end
31
34
 
35
+ # Calculates the current given cross sectional area, charge density, drift velocity, and charge.
36
+ # @param cross_sectional_area [Int, Float]
37
+ # cross_sectional_area >= 0; cross_sectional_area is in metres squared
38
+ # @param charge_density [Int, Float]
39
+ # charge_density is in per metres cubed
40
+ # @param drift_velocity [Int, Float]
41
+ # drift_velocity is in metres per second
42
+ # @param charge [Int, Float]
43
+ # charge is in coulombs
44
+ # @return [Float]
45
+ # return value is in amperes
46
+ # @example
47
+ # Joules.current_v2(0.9, 5e28, 8e-4, 1.6e-19) #=> 5759999.999999999
48
+ # @note There is one other method for calculating current.
49
+ def current_v2(cross_sectional_area, charge_density, drift_velocity, charge)
50
+ return cross_sectional_area * charge_density * drift_velocity * charge
51
+ end
52
+
32
53
  # Calculates the resistance given voltage and current.
33
54
  # @param voltage [Int, Float]
34
55
  # voltage is in volts
@@ -298,4 +319,6 @@ module Joules
298
319
  return power_v2(voltage, current) * time
299
320
  end
300
321
 
322
+ # @!endgroup
323
+
301
324
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing energy, work, and power formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Energy, work, and power module (energy_work_power.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Energy, Work, and Power Methods
15
+
14
16
  # Calculates the gravitational potential energy given mass and height.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -137,4 +139,6 @@ module Joules
137
139
  end
138
140
  end
139
141
 
142
+ # @!endgroup
143
+
140
144
  end
data/lib/joules/forces.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing forces formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Forces module (forces.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Forces Methods
15
+
14
16
  # Calculates the force given mass and acceleration.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -75,6 +77,19 @@ module Joules
75
77
  return coefficient_of_friction * normal_force.to_f
76
78
  end
77
79
 
80
+ # Calculates the buoyant force given density and volume of liquid displaced.
81
+ # @param density [Int, Float]
82
+ # density >= 0; density is in kilograms per metre cubed
83
+ # @param volume_of_liquid_displaced [Int, Float]
84
+ # volume_of_liquid_displaced >= 0; volume_of_liquid_displaced is in metres cubed
85
+ # @return [Float]
86
+ # return value >= 0; return value is in newtons
87
+ # @example
88
+ # Joules.buoyant_force(1000, 0.00150) #=> 14.715
89
+ def buoyant_force(density, volume_of_liquid_displaced)
90
+ return density * FREE_FALL_ACCELERATION * volume_of_liquid_displaced
91
+ end
92
+
78
93
  # Calculates the moment given force, distance, and angle.
79
94
  # @param force [Int, Float]
80
95
  # force is in newtons
@@ -90,4 +105,6 @@ module Joules
90
105
  return force * distance * Math.sin(to_radians(angle))
91
106
  end
92
107
 
108
+ # @!endgroup
109
+
93
110
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing geometry formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Geometry module (geometry.rb)
@@ -11,18 +11,7 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
- # Calculates the area of a rectangle given length and width.
15
- # @param length [Int, Float]
16
- # length >= 0; length is in a unit of length
17
- # @param width [Int, Float]
18
- # width >= 0; width has the same units as length
19
- # @return [Float]
20
- # return value >= 0; return value has the same units squared as length
21
- # @example
22
- # Joules.rectangle_area(2, 3.4) #=> 6.8
23
- def rectangle_area(length, width)
24
- return length * width.to_f
25
- end
14
+ # @!group Arc Length Method
26
15
 
27
16
  # Calculates the arc length of a circle given radius and central angle.
28
17
  # @param radius [Int, Float]
@@ -37,6 +26,10 @@ module Joules
37
26
  return radius * central_angle.to_f
38
27
  end
39
28
 
29
+ # @!endgroup
30
+
31
+ # @!group Circumference Method
32
+
40
33
  # Calculates the circumference of a circle given radius.
41
34
  # @param radius [Int, Float]
42
35
  # radius >= 0; radius is in a unit of length
@@ -48,6 +41,51 @@ module Joules
48
41
  return 2 * Math::PI * radius
49
42
  end
50
43
 
44
+ # @!endgroup
45
+
46
+ # @!group Area Methods
47
+
48
+ # Calculates the area of a triangle given base and height.
49
+ # @param base [Int, Float]
50
+ # base >= 0; base is in a unit of length
51
+ # @param height [Int, Float]
52
+ # height >= 0; height has the same units as base
53
+ # @return [Float]
54
+ # return value >= 0; return value has the same units squared as base
55
+ # @example
56
+ # Joules.triangle_area(2, 3.4) #=> 3.4
57
+ def triangle_area(base, height)
58
+ return 0.5 * base * height
59
+ end
60
+
61
+ # Calculates the area of a trapezium given top base, bottom base, and height.
62
+ # @param top_base [Int, Float]
63
+ # top_base >= 0; top_base is in a unit of length
64
+ # @param bottom_base [Int, Float]
65
+ # bottom_base >= 0; bottom_base has the same units as top_base
66
+ # @param height [Int, Float]
67
+ # height >= 0; height has the same units as top_base
68
+ # @return [Float]
69
+ # return value >= 0; return value has the same units squared as top_base
70
+ # @example
71
+ # Joules.trapezium_area(10, 15, 3) #=> 37.5
72
+ def trapezium_area(top_base, bottom_base, height)
73
+ return 0.5 * (top_base + bottom_base) * height
74
+ end
75
+
76
+ # Calculates the area of a rectangle given length and width.
77
+ # @param length [Int, Float]
78
+ # length >= 0; length is in a unit of length
79
+ # @param width [Int, Float]
80
+ # width >= 0; width has the same units as length
81
+ # @return [Float]
82
+ # return value >= 0; return value has the same units squared as length
83
+ # @example
84
+ # Joules.rectangle_area(2, 3.4) #=> 6.8
85
+ def rectangle_area(length, width)
86
+ return length * width.to_f
87
+ end
88
+
51
89
  # Calculates the area of a circle given radius.
52
90
  # @param radius [Int, Float]
53
91
  # radius >= 0; radius is in a unit of length
@@ -59,16 +97,9 @@ module Joules
59
97
  return Math::PI * (radius ** 2)
60
98
  end
61
99
 
62
- # Calculates the surface area of a sphere given radius.
63
- # @param radius [Int, Float]
64
- # radius >= 0; radius is in a unit of length
65
- # @return [Float]
66
- # return value >= 0; return value has the same units squared as radius
67
- # @example
68
- # Joules.sphere_surface_area(12) #=> 1809.5573684677208
69
- def sphere_surface_area(radius)
70
- return 4 * circle_area(radius)
71
- end
100
+ # @!endgroup
101
+
102
+ # @!group Volume Methods
72
103
 
73
104
  # Calculates the volume of a sphere given radius.
74
105
  # @param radius [Int, Float]
@@ -81,19 +112,6 @@ module Joules
81
112
  return (4 * circle_area(radius) * radius) / 3
82
113
  end
83
114
 
84
- # Calculates the surface area of a cone given radius and slant height.
85
- # @param radius [Int, Float]
86
- # radius >= 0; radius is in a unit of length
87
- # @param slant_height [Int, Float]
88
- # slant_height >= 0; slant_height has the same units as radius
89
- # @return [Float]
90
- # return value >= 0; return value has the same units squared as radius
91
- # @example
92
- # Joules.cone_surface_area(3, 5.83) #=> 83.22078939359362
93
- def cone_surface_area(radius, slant_height)
94
- return circle_area(radius) + (Math::PI * radius * slant_height)
95
- end
96
-
97
115
  # Calculates the volume of a cone given radius and height.
98
116
  # @param radius [Int, Float]
99
117
  # radius >= 0; radius is in a unit of length
@@ -107,30 +125,60 @@ module Joules
107
125
  return (circle_area(radius) * height) / 3
108
126
  end
109
127
 
110
- # Calulates the surface area of a cylinder given radius and height.
128
+ # Calculates the volume of a cylinder given radius and height.
111
129
  # @param radius [Int, Float]
112
130
  # radius >= 0; radius is in a unit of length
113
131
  # @param height [Int, Float]
114
132
  # height >= 0; height has the same units as radius
115
133
  # @return [Float]
134
+ # return value >= 0; return value has the same units cubed as radius
135
+ # @example
136
+ # Joules.cylinder_volume(6.5, 3) #=> 398.196868842506
137
+ def cylinder_volume(radius, height)
138
+ return circle_area(radius) * height
139
+ end
140
+
141
+ # @!endgroup
142
+
143
+ # @!group Surface Area Methods
144
+
145
+ # Calculates the surface area of a sphere given radius.
146
+ # @param radius [Int, Float]
147
+ # radius >= 0; radius is in a unit of length
148
+ # @return [Float]
116
149
  # return value >= 0; return value has the same units squared as radius
117
150
  # @example
118
- # Joules.cylinder_surface_area(6.5, 3) #=> 122.522113490002
119
- def cylinder_surface_area(radius, height)
120
- return circumference(radius) * height
151
+ # Joules.sphere_surface_area(12) #=> 1809.5573684677208
152
+ def sphere_surface_area(radius)
153
+ return 4 * circle_area(radius)
121
154
  end
122
155
 
123
- # Calculates the volume of a cylinder given radius and height.
156
+ # Calculates the surface area of a cone given radius and slant height.
157
+ # @param radius [Int, Float]
158
+ # radius >= 0; radius is in a unit of length
159
+ # @param slant_height [Int, Float]
160
+ # slant_height >= 0; slant_height has the same units as radius
161
+ # @return [Float]
162
+ # return value >= 0; return value has the same units squared as radius
163
+ # @example
164
+ # Joules.cone_surface_area(3, 5.83) #=> 83.22078939359362
165
+ def cone_surface_area(radius, slant_height)
166
+ return circle_area(radius) + (Math::PI * radius * slant_height)
167
+ end
168
+
169
+ # Calulates the surface area of a cylinder given radius and height.
124
170
  # @param radius [Int, Float]
125
171
  # radius >= 0; radius is in a unit of length
126
172
  # @param height [Int, Float]
127
173
  # height >= 0; height has the same units as radius
128
174
  # @return [Float]
129
- # return value >= 0; return value has the same units cubed as radius
175
+ # return value >= 0; return value has the same units squared as radius
130
176
  # @example
131
- # Joules.cylinder_volume(6.5, 3) #=> 398.196868842506
132
- def cylinder_volume(radius, height)
133
- return circle_area(radius) * height
177
+ # Joules.cylinder_surface_area(6.5, 3) #=> 122.522113490002
178
+ def cylinder_surface_area(radius, height)
179
+ return circumference(radius) * height
134
180
  end
135
181
 
182
+ # @!group
183
+
136
184
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing gravitational fields formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Gravitational fields module (gravitational_fields.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Gravitational Fields Methods
15
+
14
16
  # Calculates the gravitational force given object mass 1, object mass 2, and distance between the centres of the two objects.
15
17
  # @param object_mass1 [Int, Float]
16
18
  # object_mass1 >= 0; object_mass1 is in kilograms
@@ -88,4 +90,6 @@ module Joules
88
90
  end
89
91
  end
90
92
 
93
+ # @!endgroup
94
+
91
95
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing kinematics formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Kinematics module (kinematics.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Kinematics Methods
15
+
14
16
  # Calculates the average speed given distance and time.
15
17
  # @param distance [Int, Float]
16
18
  # distance >= 0; distance is in metres
@@ -147,4 +149,6 @@ module Joules
147
149
  return (final_velocity * time) - (0.5 * acceleration * (time ** 2))
148
150
  end
149
151
 
152
+ # @!endgroup
153
+
150
154
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing magnetic fields formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Magnetic fields module (magnetic_fields.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Magnetic Fields Methods
15
+
14
16
  # Calculates the magnetic force on a current given flux density, current, conductor length, and angle.
15
17
  # @param flux_density [Int, Float]
16
18
  # flux_density is in teslas
@@ -75,4 +77,6 @@ module Joules
75
77
  return magnetic_flux * number_of_coils.to_f
76
78
  end
77
79
 
80
+ # @!endgroup
81
+
78
82
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing mass and weight formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Mass and weight module (mass_weight.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Mass and Weight Methods
15
+
14
16
  # Calculates the weight given mass.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -33,4 +35,6 @@ module Joules
33
35
  return weight / FREE_FALL_ACCELERATION
34
36
  end
35
37
 
38
+ # @!endgroup
39
+
36
40
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing momentum and impulse formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Momentum and impulse module (momentum_impulse.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Momentum and Impulse Methods
15
+
14
16
  # Calculates the momentum given mass and velocity.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -54,4 +56,6 @@ module Joules
54
56
  return (final_velocity - initial_velocity) * mass.to_f
55
57
  end
56
58
 
59
+ # @!endgroup
60
+
57
61
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing oscillations formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Oscillations module (oscillations.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Oscillations Methods
15
+
14
16
  # Calculates the acceleration of a particle in oscillation given angular velocity and particle displacement.
15
17
  # @param angular_velocity [Int, Float]
16
18
  # angular_velocity is in radians per second
@@ -121,4 +123,6 @@ module Joules
121
123
  return 2 * Math::PI * ((pendulum_length / FREE_FALL_ACCELERATION) ** 0.5)
122
124
  end
123
125
 
126
+ # @!endgroup
127
+
124
128
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing pressure formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Pressure module (pressure.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Pressure Methods
15
+
14
16
  # Calculates the pressure given force and area.
15
17
  # @param force [Int, Float]
16
18
  # force >= 0; force is in newtons
@@ -42,4 +44,6 @@ module Joules
42
44
  return density * FREE_FALL_ACCELERATION * height
43
45
  end
44
46
 
47
+ # @!endgroup
48
+
45
49
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing quantum formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Quantum module (quantum.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Quantum Methods
15
+
14
16
  # Calculates the photon energy given frequency.
15
17
  # @param frequency [Int, Float]
16
18
  # frequency > 0; frequency is in hertz
@@ -66,4 +68,6 @@ module Joules
66
68
  end
67
69
  end
68
70
 
71
+ # @!endgroup
72
+
69
73
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing stress and strain formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Stress and strain module (stress_strain.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Stress and Strain Methods
15
+
14
16
  # Calculates the tensile stress given force and area.
15
17
  # @param force [Int, Float]
16
18
  # force >= 0; force is in newtons
@@ -65,4 +67,6 @@ module Joules
65
67
  end
66
68
  end
67
69
 
70
+ # @!endgroup
71
+
68
72
  end
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing thermodynamics formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Thermodynamics module (thermodynamics.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Thermodynamics Methods
15
+
14
16
  # Calculates the energy given mass, specific heat capacity, and temperature change.
15
17
  # @param mass [Int, Float]
16
18
  # mass >= 0; mass is in kilograms
@@ -41,4 +43,6 @@ module Joules
41
43
  return mass * specific_latent_heat.to_f
42
44
  end
43
45
 
46
+ # @!endgroup
47
+
44
48
  end
data/lib/joules/waves.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing waves formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Waves module (waves.rb)
@@ -11,6 +11,8 @@
11
11
  module Joules
12
12
  module_function
13
13
 
14
+ # @!group Waves Methods
15
+
14
16
  # Calculates the wave speed given frequency and wavelength.
15
17
  # @param frequency [Int, Float]
16
18
  # frequency > 0; frequency is in hertz
@@ -182,4 +184,6 @@ module Joules
182
184
  end
183
185
  end
184
186
 
187
+ # @!endgroup
188
+
185
189
  end
data/lib/joules.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # @description: Module for providing Physics formulas
5
5
  # @author: Elisha Lai
6
- # @version: 0.4.1 07/06/2015
6
+ # @version: 0.4.2 10/06/2015
7
7
  #==============================================================================
8
8
 
9
9
  # Joules module (joules.rb)
@@ -0,0 +1,30 @@
1
+ #==============================================================================
2
+ # Joules
3
+ #
4
+ # @description: Module for testing the Joules module
5
+ # @author: Elisha Lai
6
+ # @version: 0.4.2 10/06/2015
7
+ #==============================================================================
8
+
9
+ # Testing module for joules.rb (test_joules.rb)
10
+
11
+ require 'test/unit'
12
+ require 'joules'
13
+ include Joules
14
+
15
+ EPSILON = 0.00001
16
+
17
+ # Unit tests for kinematics module
18
+ class KinematicsTests < Test::Unit::TestCase
19
+ def test_avg_speed_extreme_1
20
+ assert_in_epsilon(0, avg_speed(0,0.001), EPSILON)
21
+ end
22
+
23
+ def test_avg_speed_extreme_2
24
+ assert_in_epsilon(1.03010, avg_speed(928476103, 901348726), EPSILON)
25
+ end
26
+
27
+ def test_avg_speed_big_divisor
28
+ assert_in_epsilon(6.32386e-09, avg_speed(5.7, 901348726), EPSILON)
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elisha Lai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-07 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " Joules is a library (gem) for providing simple Physics formulas\n
14
14
  \ in kinematics, forces, waves, electricity, and so much more. A\n selection
@@ -18,6 +18,7 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - CHANGELOG.md
21
22
  - LICENSE.md
22
23
  - README.md
23
24
  - lib/joules.rb
@@ -41,6 +42,7 @@ files:
41
42
  - lib/joules/stress_strain.rb
42
43
  - lib/joules/thermodynamics.rb
43
44
  - lib/joules/waves.rb
45
+ - test/test_joules.rb
44
46
  homepage: http://elailai94.github.io/Joules
45
47
  licenses:
46
48
  - MIT