<分区>
我在 src
目录中有一个文件 Projectile.rs。它目前由 main.rs 使用。但是,我需要共享同一目录的文件 FreeFall.rs 用于 Projectile.rs。这是它目前的样子:
目录
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
}
我不能只使用值 9.81(这是地球上的平均重力),因为它没有考虑空气阻力、终端速度等。
我尝试将 FreeFall
模块包含到 main.rs 中,但没有成功。