mirror of
https://github.com/nasa/trick.git
synced 2024-12-24 07:16:41 +00:00
Breakout Regula Falsi Bounds setter functions. Ref #995
This commit is contained in:
parent
e303b2ac9b
commit
9452f928d0
include/trick
trick_sims/SIM_contact/models/contact/src
trick_source/sim_services/Integrator/src
@ -54,6 +54,8 @@ typedef struct {
|
|||||||
|
|
||||||
double regula_falsi(double my_time, REGULA_FALSI * R);
|
double regula_falsi(double my_time, REGULA_FALSI * R);
|
||||||
void reset_regula_falsi(double my_time, REGULA_FALSI * R);
|
void reset_regula_falsi(double my_time, REGULA_FALSI * R);
|
||||||
|
void regula_falsi_set_upper (double my_time, double error, REGULA_FALSI * R);
|
||||||
|
void regula_falsi_set_lower (double my_time, double error, REGULA_FALSI * R);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -127,14 +127,11 @@ double Contact::collision() {
|
|||||||
if ((ii==first) && (jj==second)) {
|
if ((ii==first) && (jj==second)) {
|
||||||
reset_regula_falsi( now, &ballAssociations[association_index] );
|
reset_regula_falsi( now, &ballAssociations[association_index] );
|
||||||
} else {
|
} else {
|
||||||
//Set X_upper and t_upper to event values.
|
// Update the remaining REGULA_FALSI objects to the current event state.
|
||||||
double xdiff = balls[ii]->pos[0] - balls[jj]->pos[0];
|
double xdiff = balls[ii]->pos[0] - balls[jj]->pos[0];
|
||||||
double ydiff = balls[ii]->pos[1] - balls[jj]->pos[1];
|
double ydiff = balls[ii]->pos[1] - balls[jj]->pos[1];
|
||||||
double distance = sqrt( xdiff * xdiff + ydiff * ydiff) - (balls[ii]->radius + balls[jj]->radius);
|
double distance = sqrt( xdiff * xdiff + ydiff * ydiff) - (balls[ii]->radius + balls[jj]->radius);
|
||||||
ballAssociations[association_index].error = distance;
|
regula_falsi_set_upper (now, distance, &ballAssociations[association_index]);
|
||||||
ballAssociations[association_index].x_upper = distance;
|
|
||||||
ballAssociations[association_index].t_upper = now;
|
|
||||||
ballAssociations[association_index].upper_set = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,20 @@
|
|||||||
#define M_ABS(x) ((x) < 0 ? -(x) : (x))
|
#define M_ABS(x) ((x) < 0 ? -(x) : (x))
|
||||||
#include "trick/regula_falsi.h"
|
#include "trick/regula_falsi.h"
|
||||||
|
|
||||||
|
void regula_falsi_set_upper (double time, double error, REGULA_FALSI *R) {
|
||||||
|
R->error = error;
|
||||||
|
R->x_upper = error;
|
||||||
|
R->t_upper = time;
|
||||||
|
R->upper_set = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void regula_falsi_set_lower (double time, double error, REGULA_FALSI *R) {
|
||||||
|
R->error = error;
|
||||||
|
R->x_lower = error;
|
||||||
|
R->t_lower = time;
|
||||||
|
R->lower_set = 1;
|
||||||
|
}
|
||||||
|
|
||||||
double regula_falsi(
|
double regula_falsi(
|
||||||
/* Return: Est. time to go to err
|
/* Return: Est. time to go to err
|
||||||
function zero point */
|
function zero point */
|
||||||
@ -26,15 +40,9 @@ double regula_falsi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (R->error < 0.0) {
|
if (R->error < 0.0) {
|
||||||
/* Set lower bounds */
|
regula_falsi_set_lower(time, R->error, R);
|
||||||
R->x_lower = R->error;
|
|
||||||
R->t_lower = time;
|
|
||||||
R->lower_set = 1;
|
|
||||||
} else if (R->error > 0.0) {
|
} else if (R->error > 0.0) {
|
||||||
/* Set upper bounds */
|
regula_falsi_set_upper(time, R->error, R);
|
||||||
R->x_upper = R->error;
|
|
||||||
R->t_upper = time;
|
|
||||||
R->upper_set = 1;
|
|
||||||
}
|
}
|
||||||
R->iterations++;
|
R->iterations++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user