I have a file Projectile.rs that is in the src
directory. It is currently used by main.rs. However, I require the file FreeFall.rs sharing the same directory to be used in Projectile.rs. Here is how it looks at the moment:
DIRECTORY
src
|___main.rs
|___Projectile.rs
|___FreeFall.rs
MAIN.RS
mod Projectile;
fn main() {
println!("Goed... momenteel");
Projectile::projectile(10.0, 5.0, 100.0, 7.5);
}
PROJECTILE.RS
use std;
mod FreeFall;
pub fn projectile(init: f64, AngleX: f64, AngleY: f64, AngleZ: f64) {
let mut FFAccel = FreeFall::acceleration();
struct Velocities {
x: f64,
y: f64,
z: f64,
t: f64,
};
let mut Object1 = Velocities {
x: init * AngleX.sin(),
y: init * AngleY.cos(),
z: init * AngleZ.tan(),
t: (2.0 * init.powf(-1.0) * AngleY.sin()) / FFAccel,
};
println!("{}", Object1.t);
}
FREEFALL.RS
use std;
pub fn acceleration() {
// maths here
}
I can't just use the value 9.81 (which is the average gravity on Earth) because it does not take into account air resistance, terminal velocity, etc.
I tried including the FreeFall
module into main.rs instead, but it did not work.