Skip to content

Commit

Permalink
Changed floating point precision to doubles
Browse files Browse the repository at this point in the history
  • Loading branch information
atong01 committed May 11, 2014
1 parent 244964c commit 77df237
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Binary file removed .waypoint_expansion.c.swp
Binary file not shown.
Binary file modified gen_data
Binary file not shown.
Binary file modified trst
Binary file not shown.
11 changes: 5 additions & 6 deletions waypoint_expansion.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "state_rep.h"
#include "waypoint_expansion.h"

static inline float radians_to_degrees(float rad)
static inline double radians_to_degrees(double rad)
{
return 180 * rad / M_PI;
}
Expand Down Expand Up @@ -55,7 +55,6 @@ Angle mod360(Angle a1) {
}
return a1;
}


/* Args: two Vectors
* Purpose: Calculate the angle between to vectors
Expand All @@ -81,7 +80,7 @@ Waypoints read_waypts(FILE *fp) {

/* read in each waypt */
for (i = 0; i < wp->size; i++) {
assert(fscanf(fp, "%c%f,%f;", &(wp->rounding_dirs[i]),
assert(fscanf(fp, "%c%lf,%lf;", &(wp->rounding_dirs[i]),
&(wp->waypts[i].lat),
&(wp->waypts[i].lon)) == 3);
assert(wp->rounding_dirs[i] == 'p' ||
Expand Down Expand Up @@ -117,7 +116,7 @@ void print_wpt_pos(FILE *fp, Position p) {
* WARNING: unlike expand_waypts(FILE *, Waypoints) this function prints first
* waypoint
*/
int print_waypts(FILE *fp, Waypoints wp, float r) {
int print_waypts(FILE *fp, Waypoints wp, double r) {
assert(fp != NULL);
(void) r;
unsigned i = 0;
Expand All @@ -129,7 +128,7 @@ int print_waypts(FILE *fp, Waypoints wp, float r) {

/* given position, angle, radius, calculates a new position
* radius must be given in lat long terms */
Position calc_wpt_from_pos_and_ang(Position p, Angle a, float r) {
Position calc_wpt_from_pos_and_ang(Position p, Angle a, double r) {
Position to_return;
to_return.lat = p.lat + r * sinf(a);
to_return.lon = p.lon + r * cosf(a);
Expand All @@ -139,7 +138,7 @@ Position calc_wpt_from_pos_and_ang(Position p, Angle a, float r) {
const int WAYPOINT_ERROR_FACTOR = 5; /* allowable error on produced waypoint
angle */

int expand_waypts(FILE *fp, Waypoints wp, float r) {
int expand_waypts(FILE *fp, Waypoints wp, double r) {
unsigned i = 0;
Angle init_ang, fin_ang, ang_past, ang_toward;
int dir, wp_sep;
Expand Down
4 changes: 2 additions & 2 deletions waypoint_expansion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
typedef struct Waypoints *Waypoints;

Waypoints read_waypts(FILE *fp);
int expand_waypts(FILE *fp, Waypoints wp, float r);
int print_waypts(FILE *fp, Waypoints wp, float r);
int expand_waypts(FILE *fp, Waypoints wp, double r);
int print_waypts(FILE *fp, Waypoints wp, double r);

0 comments on commit 77df237

Please sign in to comment.