Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed structure in od_angular.h #407

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions engine/OD/od_angular.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
/*******************************************************************************
* Definitions
******************************************************************************/
typedef float angular_position_t;
typedef struct{
float private;
} angular_position_t;

/*******************************************************************************
* Variables
Expand All @@ -26,7 +28,7 @@ typedef float angular_position_t;
// deg
static inline float AngularOD_PositionTo_deg(angular_position_t self)
{
return self;
return self.private;
}

static inline angular_position_t AngularOD_PositionFrom_deg(float deg)
Expand All @@ -37,7 +39,7 @@ static inline angular_position_t AngularOD_PositionFrom_deg(float deg)
// rev
static inline float AngularOD_PositionTo_rev(angular_position_t self)
{
return self / 360.0f;
return self.private / 360.0f;
}

static inline angular_position_t AngularOD_PositionFrom_rev(float rev)
Expand All @@ -48,7 +50,7 @@ static inline angular_position_t AngularOD_PositionFrom_rev(float rev)
// rad
static inline float AngularOD_PositionTo_rad(angular_position_t self)
{
return (self * 2.0f * 3.141592653589793f) / 360.0f;
return (self.private * 2.0f * 3.141592653589793f) / 360.0f;
}

static inline angular_position_t AngularOD_PositionFrom_rad(float rad)
Expand All @@ -69,15 +71,17 @@ static inline void AngularOD_PositionFromMsg(angular_position_t *const self, con
memcpy(self, msg->data, msg->header.size);
}

typedef float angular_speed_t;
typedef struct{
float private;
} angular_speed_t;

// angular_speed are stored in degree/s (deg/s)
//******** Conversions ***********

// deg_s
static inline float AngularOD_SpeedTo_deg_s(angular_speed_t self)
{
return self;
return self.private;
}

static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg)
Expand All @@ -88,7 +92,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_deg_s(float deg)
// rev_s
static inline float AngularOD_SpeedTo_rev_s(angular_speed_t self)
{
return self / 360.0f;
return self.private / 360.0f;
}

static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s)
Expand All @@ -99,7 +103,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_s(float rev_s)
// rev_min
static inline float AngularOD_SpeedTo_rev_min(angular_speed_t self)
{
return self * 60.0f / 360.0f;
return self.private * 60.0f / 360.0f;
}

static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min)
Expand All @@ -110,7 +114,7 @@ static inline angular_speed_t AngularOD_SpeedFrom_rev_min(float rev_min)
// rad_s
static inline float AngularOD_SpeedTo_rad_s(angular_speed_t self)
{
return (self * 2.0f * 3.141592653589793f) / 360.0f;
return (self.private * 2.0f * 3.141592653589793f) / 360.0f;
}

static inline angular_speed_t AngularOD_SpeedFrom_rad_s(float rad_s)
Expand Down