Added bodies
This commit is contained in:
parent
0b12eb7384
commit
be15311c55
@ -1,3 +1,10 @@
|
||||
use solar_engine::Body;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let earth = Body::new("Earth", 5.972e24, [1.496e11, 0.0], [0.0, 0.0]);
|
||||
println!("Created body: {:?}", earth);
|
||||
|
||||
let sun = Body::new("Sun", 1.989e30, [0.0, 0.0], [0.0, 0.0]);
|
||||
println!("Created body: {:?}", sun);
|
||||
}
|
||||
|
||||
18
solar_engine/src/body.rs
Normal file
18
solar_engine/src/body.rs
Normal file
@ -0,0 +1,18 @@
|
||||
#[derive(Debug)]
|
||||
pub struct Body {
|
||||
pub name: String,
|
||||
pub mass: f64,
|
||||
pub position: [f64; 2],
|
||||
pub velocity: [f64; 2],
|
||||
}
|
||||
|
||||
impl Body {
|
||||
pub fn new(name: &str, mass: f64, position: [f64; 2], velocity: [f64; 2]) -> Self {
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
mass,
|
||||
position,
|
||||
velocity,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,3 @@
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
mod body;
|
||||
pub use body::Body;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user