16 lines
685 B
Crystal
16 lines
685 B
Crystal
require "../../../src/engine/gravity/body"
|
|
|
|
describe Gravity::Body do
|
|
it "accelerate arbitrary points" do
|
|
earth = Gravity::Body(2).new(mass: 5972200000000000000000000.0, position: Vector[0.0, 0.0])
|
|
earth = Gravity::Body.new(mass: 5972200000000000000000000.0, position: Vector[0.0, 0.0])
|
|
earth_surface = Vector[6371000.0, 0.0]
|
|
earth.acceleration(earth_surface).magnitude.round(2).should eq(9.82)
|
|
end
|
|
|
|
it "has acceleration and speed but null" do
|
|
Gravity::Body.new(mass: 123, position: Vector[1.0, 2.0]).speed.should eq(Vector(Float64, 2).zero)
|
|
Gravity::Body.new(mass: 123, position: Vector[1.0, 2.0, 3.0]).speed.should eq(Vector(Float64, 3).zero)
|
|
end
|
|
end
|