physics 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/physics.rb +1 -0
- data/lib/physics/CelestialMechanics.rb +10 -0
- data/lib/physics/classical_mechanics.rb +24 -1
- data/lib/physics/fundamental_constants.rb +12 -0
- data/lib/physics/version.rb +2 -2
- metadata +2 -1
data/lib/physics.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
module Physics
|
2
|
+
class CelestialMechanics
|
3
|
+
|
4
|
+
# System mass is mass of both objects (i.e. The Sun and Earth)
|
5
|
+
def self.orbital_period_of_body_in_elliptic_orbit( semi_major_axis, system_mass )
|
6
|
+
2 * Math.PI * Math.sqrt( ( semi_major_axis ** 3 ) / ( Physics::FundamentalConstants.G * (system_mass) ) )
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
@@ -5,8 +5,31 @@ module Physics
|
|
5
5
|
# Mass should be kg
|
6
6
|
# Velocity should be m/s
|
7
7
|
def self.kinetic_energy_of_mass_at_velocity( mass, velocity )
|
8
|
+
if velocity > 0.10 * Physics::FundamentalConstants.C
|
9
|
+
puts "Warning: Velocity high enough that result is subject to relativistic forces."
|
10
|
+
puts " Consider using a different formula."
|
11
|
+
end
|
12
|
+
|
8
13
|
0.5 * mass * (velocity **2)
|
9
14
|
end
|
10
15
|
|
11
|
-
|
16
|
+
def self.time_to_accelerate_to_velocity_over_distance( velocity, distance )
|
17
|
+
time = distance / ( velocity / 2 )
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.distance_traveled_while_accelerating_at_rate_over_time( starting_velocity, acceleration, time )
|
21
|
+
distance_traveled = ( starting_velocity * time ) + ( ( acceleration * ( time ** 2 ) ) / 2 )
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.distance_traveled_while_accelerating_to_velocity_over_time( starting_velocity, ending_velocity, time )
|
25
|
+
distance_traveled = ( ( ending_velocity + starting_velocity ) / 2 ) * time
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.velocity_after_accelerating_at_rate_over_time( starting_velocity, acceleration, time )
|
29
|
+
velocity = starting_velocity + ( acceleration * time )
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.distance_traveled_given_final_velocity_and_acceleration_over_time( final_velocity, acceleration, time )
|
33
|
+
distance_traveled = ( velocity * time ) - ( ( acceleration * ( time ** 2 ) ) / 2 )
|
34
|
+
end
|
12
35
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Physics
|
2
2
|
class FundamentalConstants
|
3
3
|
|
4
|
+
# Meters per second
|
4
5
|
def self.speed_of_light_in_vacuum
|
5
6
|
299792458
|
6
7
|
end
|
@@ -21,5 +22,16 @@ module Physics
|
|
21
22
|
6.62606957 * ( 10 ** (34 * -1.0) )
|
22
23
|
end
|
23
24
|
|
25
|
+
# Joules
|
26
|
+
def self.kiloton_of_tnt
|
27
|
+
4.184 * (10 ** 12)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Joules
|
31
|
+
def self.megaton_of_tnt
|
32
|
+
4.184 * (10 ** 15)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
24
36
|
end
|
25
37
|
end
|
data/lib/physics/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Physics
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.2"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: physics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,6 +19,7 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- lib/physics/CelestialMechanics.rb
|
22
23
|
- lib/physics/classical_mechanics.rb
|
23
24
|
- lib/physics/fundamental_constants.rb
|
24
25
|
- lib/physics/general_relativity.rb
|