mirror of
https://github.com/nasa/trick.git
synced 2025-06-05 17:01:51 +00:00
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
54 lines
2.0 KiB
C
54 lines
2.0 KiB
C
/*
|
|
PURPOSE: (Given an input value 'x', return a value 'y' in the range of zero to one, based on a function with the
|
|
following properties: 1 - zero slope at zero and at one, 2 - continous, 3 - parabolic between at both ends, 4 - and
|
|
not necessarily symmetric.)
|
|
|
|
PROGRAMMERS: (((Robert W. Bailey) (LinCom Corp) (3/22/91) (Trick-CR-00000) (Initial release))) */
|
|
|
|
#include "trick/trick_math.h"
|
|
|
|
double dS_function( /* Return: -- 0.0 <= value <= 1.0 */
|
|
double x, /* In: 'x' parameter */
|
|
double zero_point, /* In: 'x' value where 's' function returns 0.0 */
|
|
double mid_point, /* In: 'x' value where 's' function returns 0.5 */
|
|
double one_point, /* In: 'x' value where 's' function returns 1.0 */
|
|
double sign)
|
|
{ /* In: 'x' axis sign evaluation flag: -1 = evaluate -'X' axis, 1 = evaluate +'X'
|
|
axis */
|
|
|
|
double temp, temp1;
|
|
double value;
|
|
|
|
if (sign > 0) {
|
|
if (x >= one_point)
|
|
value = 1.0;
|
|
else if (x <= zero_point)
|
|
value = 0.0;
|
|
else if (zero_point < x && x < mid_point) {
|
|
temp = x - zero_point;
|
|
temp1 = mid_point - zero_point;
|
|
value = temp * temp / (2.0 * temp1 * temp1);
|
|
} else {
|
|
temp = x - one_point;
|
|
temp1 = one_point - mid_point;
|
|
value = 1.0 - (temp * temp / (2.0 * temp1 * temp1));
|
|
}
|
|
} else {
|
|
if (x <= one_point)
|
|
value = 1.0;
|
|
else if (x >= zero_point)
|
|
value = 0.0;
|
|
else if (mid_point < x && x < zero_point) {
|
|
temp = x - zero_point;
|
|
temp1 = mid_point - zero_point;
|
|
value = temp * temp / (2.0 * temp1 * temp1);
|
|
} else {
|
|
temp = x - one_point;
|
|
temp1 = one_point - mid_point;
|
|
value = 1.0 - (temp * temp / (2.0 * temp1 * temp1));
|
|
}
|
|
}
|
|
|
|
return (value);
|
|
}
|