1 /*
2  * Copyright (c) 2019-2020 Kevin Townsend (KTOWN)
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @addtogroup WORK Work
9  *
10  * @brief Work functions.
11  *
12  * @ingroup PHYSICS
13  *  @{ */
14 
15 /**
16  * @file
17  * @brief API header file for work in zscilib.
18  *
19  * This file contains the zscilib work APIs
20  */
21 
22 #ifndef ZEPHYR_INCLUDE_ZSL_WORK_H_
23 #define ZEPHYR_INCLUDE_ZSL_WORK_H_
24 
25 #include <zsl/zsl.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /**
32  * @brief Calculates the module of the work done by a force (f) along a
33  *        distance (d).
34  *
35  * @param f    Applied force in newtons.
36  * @param d    Distance in meters.
37  * @param w    Pointer to the output work in joules. Will be set to NAN
38  *             if either the force or the distance are negative.
39  *
40  * @return 0 if everything executed properly, error code on failure.
41  */
42 int zsl_phy_work_module(zsl_real_t f, zsl_real_t d, zsl_real_t *w);
43 
44 /**
45  * @brief Calculates the horizontal component of the work done by a force (f)
46  *        along a distance (d).
47  *
48  * @param f    Applied force in newtons.
49  * @param d    Distance in meters.
50  * @param theta The angle between the force and distance vectors.
51  * @param w    Pointer to the output work in the x-axis in joules. Will be set
52  *             to NAN if either the force or the distance are negative.
53  *
54  * @return 0 if everything executed properly, error code on failure.
55  */
56 int zsl_phy_work_x(zsl_real_t f, zsl_real_t d, zsl_real_t theta, zsl_real_t *w);
57 
58 /**
59  * @brief Calculates the vertical component of the work done by a force (f)
60  *        along a distance (d).
61  *
62  * @param f    Applied force in newtons.
63  * @param d    Distance in meters.
64  * @param theta The angle between the force and distance vectors.
65  * @param w    Pointer to the output work in the y-axis in joules. Will be set
66  *             to NAN if either the force or the distance are negative.
67  *
68  * @return 0 if everything executed properly, error code on failure.
69  */
70 int zsl_phy_work_y(zsl_real_t f, zsl_real_t d, zsl_real_t theta, zsl_real_t *w);
71 
72 /**
73  * @brief Calculates the work required to change the kinetic energy of an
74  *        object from 'k1' to 'k2'.
75  *
76  * @param k1    Initial kinetic energy of the object in joules.
77  * @param k2    Final kinetic energy of the object in joules.
78  * @param w     Pointer to the output work in joules.
79  *
80  * @return 0 if everything executed properly, error code on failure.
81  */
82 int zsl_phy_work_kin(zsl_real_t k1, zsl_real_t k2, zsl_real_t *w);
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* ZEPHYR_INCLUDE_ZSL_WORK_H_ */
89 
90 /** @} */ /* End of work group */
91