Marine systems simulation
compact_data_representations.h
1#pragma once
2
3#include "eigen_matrix_defs.h"
4#include <stdint.h>
5
6namespace CompactData{
7
14 Temperature(){m_value = 0;}
15 Temperature(double Celcius) {m_value = (unsigned short)(Celcius * (65535.0/30.0));}
16 operator double() {return (m_value)*(30.0/65535.0);}
17 unsigned short raw_data(){return m_value;}
18 private:
19 unsigned short m_value;
20 };
21
27 struct Depth{
28 Depth(){m_value = 0;}
29 Depth(double Meter){m_value = (unsigned short)(Meter * (65535.0/50.0));}//8.0
30 operator double(){return m_value*(50.0/65535.0);}//0.125
31 private:
32 unsigned short m_value;
33 };
34
40 struct Speed{
41 Speed(){m_value = 0;}
42 Speed(double Meter_per_second){m_value = (unsigned short)(Meter_per_second * (65535.0/4.0));}//64.0
43 operator double(){return m_value*(4.0/65535.0);}//0.015625
44 unsigned short raw_data(){return m_value;} //unsigned char raw_data(){return m_value;}
45 private:
46 unsigned short m_value; //unsigned char m_value;
47 };
48
55 /*struct Velocity{
56 Velocity(){m_x = 0; m_y = 0; m_z = 0;}
57 Velocity(const double* X)
58 {
59 m_x = (char)(X[0] * 32);
60 m_y = (char)(X[1] * 32);
61 m_z = (char)(X[2] * 32);
62 m_abs = (char)sqrt((float)int(m_x)*int(m_x) + int(m_y)*int(m_y) + int(m_z)*int(m_z));
63 }
64 operator Eigen::Vector3d(){return Eigen::Vector3d(m_x,m_y,m_z)*0.03125;}
65 operator Eigen::Vector3f(){return Eigen::Vector3f(m_x,m_y,m_z)*0.03125f;}
66 float norm(){ return m_abs*0.03125f;}// sqrt((int(m_x)*int(m_x) + int(m_y)*int(m_y) + int(m_z)*int(m_z))*0.03125f*0.03125f);}
67 private:
68 char m_x;
69 char m_y;
70 char m_z;
71 char m_abs;
72 };*/
73
79 /*struct Position{
80 Position(short x,short y,short z){m_x=x;m_y=y;m_z=z;}
81 Position(){m_x = 0; m_y = 0; m_z = 0;}
82 Position(const double* X)
83 {
84 m_x = (short)(X[0] * 512);
85 m_y = (short)(X[1] * 512);
86 m_z = (short)(X[2] * 512);
87 }
88 operator Eigen::Vector3d(){return Eigen::Vector3d(m_x,m_y,m_z)*0.001953125;}
89 operator Eigen::Vector3f(){return Eigen::Vector3f(m_x,m_y,m_z)*0.001953125f;}
90 Position operator-(Position a){return Position(m_x-a.m_x,m_y-a.m_y,m_z-a.m_z);}
91 Position operator+(Position a){return Position(m_x+a.m_x,m_y+a.m_y,m_z+a.m_z);}
92 float squaredNorm(){ return (int(m_x)*int(m_x) + int(m_y)*int(m_y) + int(m_z)*int(m_z))*0.001953125f*0.001953125f;}
93 float norm(){ return sqrt((int(m_x)*int(m_x) + int(m_y)*int(m_y) + int(m_z)*int(m_z))*0.001953125f*0.001953125f);}
94 inline short X_raw(){return m_x;}
95 inline short Y_raw(){return m_y;}
96 inline short Z_raw(){return m_z;}
97 inline float x(){return m_x*0.001953125f;}
98 inline float y(){return m_y*0.001953125f;}
99 inline float z(){return m_z*0.001953125f;}
100 private:
101 short m_x;
102 short m_y;
103 short m_z;
104 };*/
105
106
112 struct Length{
113 Length(){m_value = 0;}
114 Length(double Meter){m_value = (unsigned short)(Meter * (65535.0/5.0));}//128.0
115 //operator double(){return m_value*0.0078125;}
116 operator float(){return m_value*((float)(5.0/65535.0));}//0.0078125f
117 private:
118 unsigned short m_value;
119 };
120
126 struct Duration{
127 Duration(){m_value = 0;}
128 Duration(double seconds){m_value = (unsigned short)(seconds * (65535.0/60.0));}//256.0/60.0
129 operator double(){return m_value*(60.0/65535.0);}//60.0/256.0
130 unsigned short raw_data(){return m_value;}
131 private:
132 unsigned short m_value;
133 };
134
138 /*struct debV{
139 debV(){m_value = 0;}
140 debV(double Volume){m_value = (unsigned char)(Volume * (256.0/11800.0));}
141 operator double(){return m_value*(11800.0/256.0);}
142 private:
143 unsigned char m_value;
144 };*/
145
149 /*struct debE{
150 debE(){m_value = 0;}
151 debE(double Volume){m_value = (unsigned char)(Volume * (256.0/548720.0));}
152 operator double(){return m_value*(548720.0/256.0);}
153 private:
154 unsigned char m_value;
155 };*/
156
160 /*struct debG{
161 debG(){m_value = 0;}
162 debG(double Volume){m_value = (unsigned char)(Volume * (256.0/100.0));}
163 operator double(){return m_value*(100.0/256.0);}
164 private:
165 unsigned char m_value;
166 };*/
167 /*struct accumPelletsEaten{
168 accumPelletsEaten(){m_value = 0;}
169 accumPelletsEaten(double nPellets){m_value = (unsigned char)(nPellets* (65536/65536));}
170 operator double(){return m_value*(65536.0/65536.0);}
171 private:
172 unsigned char m_value;
173 };*/
174}
Definition: compact_data_representations.h:27
Definition: compact_data_representations.h:126
Definition: compact_data_representations.h:112
Definition: compact_data_representations.h:40
Definition: compact_data_representations.h:13