Skip to content

Commit

Permalink
physics: Add newtons_second_law_of_motion
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Aug 1, 2023
1 parent 72b660a commit c544601
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions physics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod kinetic_energy;
pub mod lorentz_transformation_four_vector;
pub mod malus_law;
pub mod newtons_law_of_gravitation;
pub mod newtons_second_law_of_motion;
pub mod potential_energy;
pub mod rms_speed_of_molecule;
pub mod shear_stress;
Expand Down
25 changes: 25 additions & 0 deletions physics/src/newtons_second_law_of_motion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2023 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
// Use of this source is governed by General Public License that can be found
// in the LICENSE file.

//! Newton's second law of motion pertains to the behavior of objects for which
//! all existing forces are not balanced.
//!
//! [Newtons Second Law](https://www.physicsclassroom.com/class/newtlaws/Lesson-3/Newton-s-Second-Law)

#[must_use]
pub fn newtons_second_law_of_motion(mass: f64, acceleration: f64) -> f64 {
mass * acceleration
}

#[cfg(test)]
mod tests {

use super::newtons_second_law_of_motion;

#[test]
fn test_newtons_second_law_of_motion() {
assert_eq!(newtons_second_law_of_motion(10.0, 10.0), 100.0);
assert_eq!(newtons_second_law_of_motion(2.0, 1.0), 2.0);
}
}

0 comments on commit c544601

Please sign in to comment.