- Timestamp:
- Apr 12, 2017, 1:59:38 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 70 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ReleaseNotes
r148 r167 1 1 * Actual Version: 2 2 3 - Vector2D and Vector3D are now templates. Replace all Vector2D to Vector2Df and Vector3D to Vector3Df to keep compatibility. 3 4 - resolved https://devel.hds.utc.fr/software/flair/ticket/17 4 5 - resolved https://devel.hds.utc.fr/software/flair/ticket/16 -
trunk/demos/CircleFollower/uav/src/CircleFollower.cpp
r147 r167 89 89 //get roll, pitch and w from imu 90 90 Quaternion ahrsQuaternion; 91 Vector3D ahrsAngularSpeed;91 Vector3Df ahrsAngularSpeed; 92 92 GetDefaultOrientation()->GetQuaternionAndAngularRates(ahrsQuaternion, ahrsAngularSpeed); 93 93 … … 101 101 } 102 102 103 void CircleFollower::AltitudeValues(float &z,float &dz) {104 Vector3D uav_pos,uav_vel;103 void CircleFollower::AltitudeValues(float &z,float &dz) const{ 104 Vector3Df uav_pos,uav_vel; 105 105 106 106 uavVrpn->GetPosition(uav_pos); … … 112 112 113 113 AhrsData *CircleFollower::GetReferenceOrientation(void) { 114 Vector2D pos_err, vel_err; // in Uav coordinate system114 Vector2Df pos_err, vel_err; // in Uav coordinate system 115 115 float yaw_ref; 116 116 Euler refAngles; … … 128 128 refAngles.roll=-uY->Output(); 129 129 130 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3D (0,0,0));130 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3Df(0,0,0)); 131 131 132 132 return customReferenceOrientation; 133 133 } 134 134 135 void CircleFollower::PositionValues(Vector2D &pos_error,Vector2D&vel_error,float &yaw_ref) {136 Vector3D uav_pos,uav_vel; // in VRPN coordinate system137 Vector2D uav_2Dpos,uav_2Dvel; // in VRPN coordinate system135 void CircleFollower::PositionValues(Vector2Df &pos_error,Vector2Df &vel_error,float &yaw_ref) { 136 Vector3Df uav_pos,uav_vel; // in VRPN coordinate system 137 Vector2Df uav_2Dpos,uav_2Dvel; // in VRPN coordinate system 138 138 139 139 uavVrpn->GetPosition(uav_pos); … … 148 148 yaw_ref=yawHold; 149 149 } else { //Circle 150 Vector3D target_pos;151 Vector2D circle_pos,circle_vel;152 Vector2D target_2Dpos;150 Vector3Df target_pos; 151 Vector2Df circle_pos,circle_vel; 152 Vector2Df target_2Dpos; 153 153 154 154 targetVrpn->GetPosition(target_pos); … … 238 238 return; 239 239 } 240 Vector3D uav_pos,target_pos;241 Vector2D uav_2Dpos,target_2Dpos;240 Vector3Df uav_pos,target_pos; 241 Vector2Df uav_2Dpos,target_2Dpos; 242 242 243 243 targetVrpn->GetPosition(target_pos); … … 265 265 yawHold=vrpnQuaternion.ToEuler().yaw; 266 266 267 Vector3D vrpnPosition;267 Vector3Df vrpnPosition; 268 268 uavVrpn->GetPosition(vrpnPosition); 269 269 vrpnPosition.To2Dxy(posHold); -
trunk/demos/CircleFollower/uav/src/CircleFollower.h
r122 r167 54 54 void ExtraCheckJoystick(void); 55 55 const flair::core::AhrsData *GetOrientation(void) const; 56 void AltitudeValues(float &z,float &dz) ;57 void PositionValues(flair::core::Vector2D &pos_error,flair::core::Vector2D&vel_error,float &yaw_ref);56 void AltitudeValues(float &z,float &dz) const; 57 void PositionValues(flair::core::Vector2Df &pos_error,flair::core::Vector2Df &vel_error,float &yaw_ref); 58 58 flair::core::AhrsData *GetReferenceOrientation(void); 59 59 void SignalEvent(Event_t event); … … 61 61 flair::filter::Pid *uX, *uY; 62 62 63 flair::core::Vector2D posHold;63 flair::core::Vector2Df posHold; 64 64 float yawHold; 65 65 -
trunk/demos/Gps/uav/src/DemoGps.cpp
r159 r167 79 79 80 80 AhrsData* DemoGps::GetReferenceOrientation(void) { 81 Vector2D pos_err, vel_err; // in Uav coordinate system81 Vector2Df pos_err, vel_err; // in Uav coordinate system 82 82 float yaw_ref; 83 83 Euler refAngles; … … 95 95 refAngles.roll = -uY->Output(); 96 96 97 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(), Vector3D (0, 0, 0));97 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(), Vector3Df(0, 0, 0)); 98 98 99 99 return customReferenceOrientation; 100 100 } 101 101 102 void DemoGps::PositionValues(Vector2D & pos_error, Vector2D& vel_error, float& yaw_ref) {103 Vector3D uav_pos, uav_vel;104 Vector2D uav_2Dpos, uav_2Dvel;102 void DemoGps::PositionValues(Vector2Df& pos_error, Vector2Df& vel_error, float& yaw_ref) { 103 Vector3Df uav_pos, uav_vel; 104 Vector2Df uav_2Dpos, uav_2Dvel; 105 105 106 106 // TODO GPS position and circle center … … 116 116 yaw_ref = yawHold; 117 117 } else { // Circle 118 Vector2D circle_pos, circle_vel;119 Vector2D target_2Dpos;118 Vector2Df circle_pos, circle_vel; 119 Vector2Df target_2Dpos; 120 120 121 121 circle->SetCenter(target_2Dpos); … … 190 190 return; 191 191 } 192 Vector3D uav_pos;193 Vector2D uav_2Dpos, target_2Dpos;192 Vector3Df uav_pos; 193 Vector2Df uav_2Dpos, target_2Dpos; 194 194 195 195 circle->SetCenter(target_2Dpos); -
trunk/demos/Gps/uav/src/DemoGps.h
r122 r167 51 51 void ExtraCheckPushButton(void); 52 52 void ExtraCheckJoystick(void); 53 void PositionValues(flair::core::Vector2D &pos_error,flair::core::Vector2D&vel_error,float &yaw_ref);53 void PositionValues(flair::core::Vector2Df &pos_error,flair::core::Vector2Df &vel_error,float &yaw_ref); 54 54 flair::core::AhrsData *GetReferenceOrientation(void); 55 55 void SignalEvent(Event_t event); … … 57 57 flair::filter::Pid *uX, *uY; 58 58 59 flair::core::Vector2D posHold;59 flair::core::Vector2Df posHold; 60 60 float yawHold; 61 61 -
trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp
r165 r167 178 178 179 179 // /!\ in this demo, the target value is a speed (in m/s). As a consequence the error is the difference between the current speed and the target speed 180 Vector2D error, errorVariation; // in Uav coordinate system180 Vector2Df error, errorVariation; // in Uav coordinate system 181 181 182 182 error.x=opticalFlowRealSpeed->Value(0,0)-opticalFlowReference->Value(0,0); … … 194 194 refAngles.roll=-u_y->Output(); 195 195 196 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3D (0,0,0));196 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3Df(0,0,0)); 197 197 198 198 return customReferenceOrientation; -
trunk/demos/SimpleFleet/uav/src/SimpleFleet.cpp
r136 r167 111 111 //get roll, pitch and w from imu 112 112 Quaternion ahrsQuaternion; 113 Vector3D ahrsAngularSpeed;113 Vector3Df ahrsAngularSpeed; 114 114 GetDefaultOrientation()->GetQuaternionAndAngularRates(ahrsQuaternion, ahrsAngularSpeed); 115 115 … … 124 124 125 125 void SimpleFleet::AltitudeValues(float &z,float &dz) const { 126 Vector3D uav_pos,uav_vel;126 Vector3Df uav_pos,uav_vel; 127 127 128 128 uavVrpn->GetPosition(uav_pos); … … 134 134 135 135 const AhrsData *SimpleFleet::GetReferenceOrientation(void) { 136 Vector2D pos_err, vel_err; // in uav coordinate system136 Vector2Df pos_err, vel_err; // in uav coordinate system 137 137 float yaw_ref; 138 138 Euler refAngles; … … 150 150 refAngles.roll=-u_y->Output(); 151 151 152 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3D (0,0,0));152 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3Df(0,0,0)); 153 153 154 154 return customReferenceOrientation; 155 155 } 156 156 157 void SimpleFleet::PositionValues(Vector2D &pos_error,Vector2D&vel_error,float &yaw_ref) {158 Vector3D uav_pos,uav_vel; // in VRPN coordinate system159 Vector2D uav_2Dpos,uav_2Dvel; // in VRPN coordinate system157 void SimpleFleet::PositionValues(Vector2Df &pos_error,Vector2Df &vel_error,float &yaw_ref) { 158 Vector3Df uav_pos,uav_vel; // in VRPN coordinate system 159 Vector2Df uav_2Dpos,uav_2Dvel; // in VRPN coordinate system 160 160 161 161 uavVrpn->GetPosition(uav_pos); … … 171 171 yaw_ref=yawHold; 172 172 } else { //Circle 173 Vector2D circle_pos,circle_vel;174 Vector2D target_2Dpos;173 Vector2Df circle_pos,circle_vel; 174 Vector2Df target_2Dpos; 175 175 176 176 //circle center … … 318 318 return; 319 319 } 320 Vector3D uav_pos;321 Vector2D uav_2Dpos,target_2Dpos;320 Vector3Df uav_pos; 321 Vector2Df uav_2Dpos,target_2Dpos; 322 322 323 323 //circle center … … 352 352 yawHold=vrpnQuaternion.ToEuler().yaw; 353 353 354 Vector3D vrpnPosition;354 Vector3Df vrpnPosition; 355 355 uavVrpn->GetPosition(vrpnPosition); 356 356 vrpnPosition.To2Dxy(posHold); -
trunk/demos/SimpleFleet/uav/src/SimpleFleet.h
r135 r167 63 63 const flair::core::AhrsData *GetOrientation(void) const; 64 64 void AltitudeValues(float &z,float &dz) const; 65 void PositionValues(flair::core::Vector2D &pos_error,flair::core::Vector2D&vel_error,float &yaw_ref);65 void PositionValues(flair::core::Vector2Df &pos_error,flair::core::Vector2Df &vel_error,float &yaw_ref); 66 66 const flair::core::AhrsData *GetReferenceOrientation(void); 67 67 void SignalEvent(Event_t event); … … 70 70 flair::filter::Pid *u_x, *u_y; 71 71 72 flair::core::Vector2D posHold;72 flair::core::Vector2Df posHold; 73 73 float yawHold; 74 74 flair::core::Socket *message; -
trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.cpp
r122 r167 51 51 //refAngles.yaw=; 52 52 53 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3D (0,0,0));53 customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3Df(0,0,0)); 54 54 55 55 return customReferenceOrientation; -
trunk/lib/FlairCore/src/AhrsData.cpp
r15 r167 43 43 void CopyData(char *destination) const { 44 44 float data; 45 Vector3D angularRates;45 Vector3Df angularRates; 46 46 Euler eulerAngles; 47 47 Quaternion quaternion; … … 138 138 } 139 139 140 Vector3D AhrsData::GetAngularRates(void) const {141 Vector3D out;140 Vector3Df AhrsData::GetAngularRates(void) const { 141 Vector3Df out; 142 142 GetMutex(); 143 143 out = angularRates; … … 147 147 148 148 void AhrsData::GetQuaternionAndAngularRates(Quaternion &outQuaternion, 149 Vector3D &outAngularRates) const {149 Vector3Df &outAngularRates) const { 150 150 GetMutex(); 151 151 outQuaternion = quaternion; … … 155 155 156 156 void AhrsData::SetQuaternionAndAngularRates(const Quaternion &inQuaternion, 157 const Vector3D &inAngularRates) {157 const Vector3Df &inAngularRates) { 158 158 GetMutex(); 159 159 quaternion = inQuaternion; … … 168 168 } 169 169 170 void AhrsData::SetAngularRates(const Vector3D &inAngularRates) {170 void AhrsData::SetAngularRates(const Vector3Df &inAngularRates) { 171 171 GetMutex(); 172 172 angularRates = inAngularRates; -
trunk/lib/FlairCore/src/AhrsData.h
r15 r167 121 121 * 122 122 */ 123 void SetAngularRates(const Vector3D &angularRates);123 void SetAngularRates(const Vector3Df &angularRates); 124 124 125 125 /*! … … 131 131 * 132 132 */ 133 Vector3D GetAngularRates(void) const;133 Vector3Df GetAngularRates(void) const; 134 134 135 135 /*! … … 143 143 */ 144 144 void GetQuaternionAndAngularRates(Quaternion &quaternion, 145 Vector3D &angularRates) const;145 Vector3Df &angularRates) const; 146 146 147 147 /*! … … 155 155 */ 156 156 void SetQuaternionAndAngularRates(const Quaternion &quaternion, 157 const Vector3D &angularRates);157 const Vector3Df &angularRates); 158 158 159 159 const Type &GetDataType() const { return dataType; } … … 182 182 * 183 183 */ 184 Vector3D angularRates;184 Vector3Df angularRates; 185 185 186 186 Type dataType; -
trunk/lib/FlairCore/src/GpsData.h
r51 r167 19 19 20 20 class IODataElement; 21 class Vector3D;22 21 23 22 /*! \class GpsData -
trunk/lib/FlairCore/src/ImuData.cpp
r15 r167 44 44 void CopyData(char *dst) const { 45 45 float data; 46 Vector3D rawAcc = imudata->GetRawAcc();47 Vector3D rawMag = imudata->GetRawMag();48 Vector3D rawGyr = imudata->GetRawGyr();46 Vector3Df rawAcc = imudata->GetRawAcc(); 47 Vector3Df rawMag = imudata->GetRawMag(); 48 Vector3Df rawGyr = imudata->GetRawGyr(); 49 49 switch (plotableData) { 50 50 case ImuData::RawAx: … … 121 121 ImuData::~ImuData() {} 122 122 123 Vector3D ImuData::GetRawAcc(void) const {124 Vector3D out;123 Vector3Df ImuData::GetRawAcc(void) const { 124 Vector3Df out; 125 125 GetMutex(); 126 126 out = rawAcc; … … 129 129 } 130 130 131 Vector3D ImuData::GetRawMag(void) const {132 Vector3D out;131 Vector3Df ImuData::GetRawMag(void) const { 132 Vector3Df out; 133 133 GetMutex(); 134 134 out = rawMag; … … 137 137 } 138 138 139 Vector3D ImuData::GetRawGyr(void) const {140 Vector3D out;139 Vector3Df ImuData::GetRawGyr(void) const { 140 Vector3Df out; 141 141 GetMutex(); 142 142 out = rawGyr; … … 145 145 } 146 146 147 void ImuData::GetRawAccMagAndGyr(Vector3D &inRawAcc, Vector3D&inRawMag,148 Vector3D &inRawGyr) const {147 void ImuData::GetRawAccMagAndGyr(Vector3Df &inRawAcc, Vector3Df &inRawMag, 148 Vector3Df &inRawGyr) const { 149 149 GetMutex(); 150 150 inRawAcc = rawAcc; … … 154 154 } 155 155 156 void ImuData::SetRawAcc(const Vector3D &inRawAcc) {156 void ImuData::SetRawAcc(const Vector3Df &inRawAcc) { 157 157 GetMutex(); 158 158 rawAcc = inRawAcc; … … 160 160 } 161 161 162 void ImuData::SetRawMag(const Vector3D &inRawMag) {162 void ImuData::SetRawMag(const Vector3Df &inRawMag) { 163 163 GetMutex(); 164 164 rawMag = inRawMag; … … 166 166 } 167 167 168 void ImuData::SetRawGyr(const Vector3D &inRawGyr) {168 void ImuData::SetRawGyr(const Vector3Df &inRawGyr) { 169 169 GetMutex(); 170 170 rawGyr = inRawGyr; … … 172 172 } 173 173 174 void ImuData::SetRawAccMagAndGyr(const Vector3D &inRawAcc,175 const Vector3D &inRawMag,176 const Vector3D &inRawGyr) {174 void ImuData::SetRawAccMagAndGyr(const Vector3Df &inRawAcc, 175 const Vector3Df &inRawMag, 176 const Vector3Df &inRawGyr) { 177 177 GetMutex(); 178 178 rawAcc = inRawAcc; -
trunk/lib/FlairCore/src/ImuData.h
r15 r167 104 104 * 105 105 */ 106 Vector3D GetRawAcc(void) const;106 Vector3Df GetRawAcc(void) const; 107 107 108 108 /*! … … 114 114 * 115 115 */ 116 Vector3D GetRawMag(void) const;116 Vector3Df GetRawMag(void) const; 117 117 118 118 /*! … … 124 124 * 125 125 */ 126 Vector3D GetRawGyr(void) const;126 Vector3Df GetRawGyr(void) const; 127 127 128 128 /*! … … 136 136 * 137 137 */ 138 void GetRawAccMagAndGyr(Vector3D &rawAcc, Vector3D&rawMag,139 Vector3D &rawGyr) const;138 void GetRawAccMagAndGyr(Vector3Df &rawAcc, Vector3Df &rawMag, 139 Vector3Df &rawGyr) const; 140 140 141 141 /*! … … 147 147 * 148 148 */ 149 void SetRawAcc(const Vector3D &rawAcc);149 void SetRawAcc(const Vector3Df &rawAcc); 150 150 151 151 /*! … … 157 157 * 158 158 */ 159 void SetRawMag(const Vector3D &rawMag);159 void SetRawMag(const Vector3Df &rawMag); 160 160 161 161 /*! … … 167 167 * 168 168 */ 169 void SetRawGyr(const Vector3D &rawGyr);169 void SetRawGyr(const Vector3Df &rawGyr); 170 170 171 171 /*! … … 179 179 * 180 180 */ 181 void SetRawAccMagAndGyr(const Vector3D &rawAcc, const Vector3D&rawMag,182 const Vector3D &rawGyr);181 void SetRawAccMagAndGyr(const Vector3Df &rawAcc, const Vector3Df &rawMag, 182 const Vector3Df &rawGyr); 183 183 184 184 Type const &GetDataType() const { return dataType; } … … 199 199 * 200 200 */ 201 Vector3D rawAcc;201 Vector3Df rawAcc; 202 202 203 203 /*! … … 205 205 * 206 206 */ 207 Vector3D rawGyr;207 Vector3Df rawGyr; 208 208 209 209 /*! … … 211 211 * 212 212 */ 213 Vector3D rawMag;213 Vector3Df rawMag; 214 214 215 215 void Queue(char **dst, const void *src, size_t size) const; -
trunk/lib/FlairCore/src/OneAxisRotation.cpp
r147 r167 24 24 #include "OneAxisRotation.h" 25 25 #include "OneAxisRotation_impl.h" 26 #include <Vector3D.h>27 26 #include <Euler.h> 28 27 … … 32 31 namespace core { 33 32 33 template void OneAxisRotation::ComputeRotation(core::Vector3D<float> &) const; 34 template void OneAxisRotation::ComputeRotation(core::Vector3D<double> &) const; 35 34 36 OneAxisRotation::OneAxisRotation(const gui::LayoutPosition *position, 35 37 string name) … … 40 42 OneAxisRotation::~OneAxisRotation() { delete pimpl_; } 41 43 42 void OneAxisRotation::ComputeRotation(Vector3D&vector) const {44 template <typename T> void OneAxisRotation::ComputeRotation(Vector3D<T> &vector) const { 43 45 pimpl_->ComputeRotation(vector); 44 46 } -
trunk/lib/FlairCore/src/OneAxisRotation.h
r147 r167 15 15 16 16 #include <GroupBox.h> 17 #include <Vector3D.h> 17 18 18 19 class OneAxisRotation_impl; … … 24 25 25 26 namespace core { 26 class Vector3D;27 27 class Euler; 28 28 class Quaternion; … … 57 57 * \brief Compute rotation 58 58 * 59 * \param vector Vector3D to rotate59 * \param vector Vector3Df to rotate 60 60 */ 61 void ComputeRotation(core::Vector3D&vector) const;61 template <typename T> void ComputeRotation(core::Vector3D<T> &vector) const; 62 62 63 63 /*! -
trunk/lib/FlairCore/src/OneAxisRotation_impl.cpp
r144 r167 20 20 #include "ComboBox.h" 21 21 #include "DoubleSpinBox.h" 22 #include <Vector3D.h>23 22 #include <Euler.h> 24 23 #include <Quaternion.h> … … 27 26 using namespace flair::core; 28 27 using namespace flair::gui; 28 29 template void OneAxisRotation_impl::ComputeRotation(Vector3D<float>&) const; 30 template void OneAxisRotation_impl::ComputeRotation(Vector3D<double>&) const; 29 31 30 32 OneAxisRotation_impl::OneAxisRotation_impl(GroupBox *box) { … … 41 43 // compute rotation of each axis through ComputeRotation(Vector3D& vector) 42 44 void OneAxisRotation_impl::ComputeRotation(Quaternion &quat) const { 43 Vector3D rot = Vector3D(quat.q1, quat.q2, quat.q3);45 Vector3Df rot = Vector3Df(quat.q1, quat.q2, quat.q3); 44 46 ComputeRotation(rot); 45 47 quat.q1 = rot.x; … … 54 56 // on utilise la rotation d'un vector pour faire une rotation de repere 55 57 // d'ou le signe negatif 56 void OneAxisRotation_impl::ComputeRotation(Vector3D&vector) const {58 template <typename T> void OneAxisRotation_impl::ComputeRotation(Vector3D<T> &vector) const { 57 59 switch (rot_axe->CurrentIndex()) { 58 60 case 0: -
trunk/lib/FlairCore/src/Quaternion.cpp
r161 r167 17 17 18 18 #include "Quaternion.h" 19 #include "Vector3D.h"20 19 #include "Euler.h" 21 20 #include "RotationMatrix.h" … … 63 62 } 64 63 65 void Quaternion::GetLogarithm(Vector3D &logarithm) {64 void Quaternion::GetLogarithm(Vector3Df &logarithm) { 66 65 Normalize(); 67 66 float v_norm = sqrtf(q1 * q1 + q2 * q2 + q3 * q3); … … 79 78 } 80 79 81 Vector3D Quaternion::GetLogarithm(void) {82 Vector3D vector;80 Vector3Df Quaternion::GetLogarithm(void) { 81 Vector3Df vector; 83 82 GetLogarithm(vector); 84 83 return vector; 85 84 } 86 85 87 Quaternion Quaternion::GetDerivative(const Vector3D &angularSpeed) const {86 Quaternion Quaternion::GetDerivative(const Vector3Df &angularSpeed) const { 88 87 const Quaternion Qw(0, angularSpeed.x, angularSpeed.y, angularSpeed.z); 89 88 return 0.5 * (*this) * Qw; 90 89 } 91 90 92 void Quaternion::Derivate(const Vector3D &angularSpeed) {91 void Quaternion::Derivate(const Vector3Df &angularSpeed) { 93 92 Quaternion Q = GetDerivative(angularSpeed); 94 93 (*this) = Q; -
trunk/lib/FlairCore/src/Quaternion.h
r15 r167 13 13 #define QUATERNION_H 14 14 15 #include <Vector3D.h> 16 15 17 namespace flair { 16 18 namespace core { 17 19 class Euler; 18 class Vector3D;19 20 class RotationMatrix; 20 21 … … 62 63 * \param logarithm output logarithm 63 64 */ 64 void GetLogarithm(Vector3D &logarithm);65 void GetLogarithm(Vector3Df &logarithm); 65 66 66 67 /*! … … 71 72 * \return output logarithm 72 73 */ 73 Vector3D GetLogarithm(void);74 Vector3Df GetLogarithm(void); 74 75 75 76 /*! … … 92 93 * \return derivative 93 94 */ 94 Quaternion GetDerivative(const Vector3D &angularSpeed) const;95 Quaternion GetDerivative(const Vector3Df &angularSpeed) const; 95 96 96 97 /*! … … 99 100 * \param w rotationonal speed 100 101 */ 101 void Derivate(const Vector3D &angularSpeed);102 void Derivate(const Vector3Df &angularSpeed); 102 103 103 104 /*! -
trunk/lib/FlairCore/src/Vector2D.cpp
r161 r167 22 22 namespace flair { 23 23 namespace core { 24 25 template class Vector2D<double>; 26 template Vector2D<double> operator+(const Vector2D<double>&, const Vector2D<double>&); 27 template Vector2D<double> operator-(const Vector2D<double>&, const Vector2D<double>&); 28 template Vector2D<double> operator-(const Vector2D<double>&); 29 template Vector2D<double> operator/(const Vector2D<double>&, float); 30 template Vector2D<double> operator*(const Vector2D<double>&, float); 31 template Vector2D<double> operator*(float, const Vector2D<double>&); 24 32 25 Vector2D::Vector2D(float inX, float inY) : x(inX), y(inY) {} 33 template class Vector2D<float>; 34 template Vector2D<float> operator+(const Vector2D<float>&, const Vector2D<float>&); 35 template Vector2D<float> operator-(const Vector2D<float>&, const Vector2D<float>&); 36 template Vector2D<float> operator-(const Vector2D<float>&); 37 template Vector2D<float> operator/(const Vector2D<float>&, float); 38 template Vector2D<float> operator*(const Vector2D<float>&, float); 39 template Vector2D<float> operator*(float, const Vector2D<float>&); 26 40 27 Vector2D::~Vector2D() {}41 template <typename T> Vector2D<T>::Vector2D(T inX, T inY) : x(inX), y(inY) {} 28 42 29 Vector2D &Vector2D::operator=(const Vector2D &vector) { 30 x = vector.x; 31 y = vector.y; 32 return (*this); 33 } 43 template <typename T> Vector2D<T>::~Vector2D() {} 34 44 35 Vector2D &Vector2D::operator+=(const Vector2D&vector) {45 template <typename T> Vector2D<T> &Vector2D<T>::operator+=(const Vector2D<T> &vector) { 36 46 x += vector.x; 37 47 y += vector.y; … … 39 49 } 40 50 41 Vector2D &Vector2D::operator-=(const Vector2D&vector) {51 template <typename T> Vector2D<T> &Vector2D<T>::operator-=(const Vector2D<T> &vector) { 42 52 x -= vector.x; 43 53 y -= vector.y; … … 45 55 } 46 56 47 Vector2D operator+(const Vector2D &vectorA, const Vector2D&vectorB) {48 return Vector2D (vectorA.x + vectorB.x, vectorA.y + vectorB.y);57 template <typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB) { 58 return Vector2D<T>(vectorA.x + vectorB.x, vectorA.y + vectorB.y); 49 59 } 50 60 51 Vector2D operator-(const Vector2D &vectorA, const Vector2D&vectorB) {52 return Vector2D (vectorA.x - vectorB.x, vectorA.y - vectorB.y);61 template <typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB) { 62 return Vector2D<T>(vectorA.x - vectorB.x, vectorA.y - vectorB.y); 53 63 } 54 64 55 Vector2D operator-(const Vector2D&vectorA) {56 return Vector2D (-vectorA.x, -vectorA.y);65 template <typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA) { 66 return Vector2D<T>(-vectorA.x, -vectorA.y); 57 67 } 58 68 59 Vector2D operator/(const Vector2D&vector, float coeff) {69 template <typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff) { 60 70 if (coeff != 0) { 61 return Vector2D (vector.x / coeff, vector.y / coeff);71 return Vector2D<T>(vector.x / coeff, vector.y / coeff); 62 72 } else { 63 return Vector2D (0, 0);73 return Vector2D<T>(0, 0); 64 74 } 65 75 } 66 76 67 Vector2D operator*(const Vector2D&vector, float coeff) {68 return Vector2D (vector.x * coeff, vector.y * coeff);77 template <typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff) { 78 return Vector2D<T>(vector.x * coeff, vector.y * coeff); 69 79 } 70 80 71 Vector2D operator*(float coeff, const Vector2D&vector) {72 return Vector2D (vector.x * coeff, vector.y * coeff);81 template <typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector) { 82 return Vector2D<T>(vector.x * coeff, vector.y * coeff); 73 83 } 74 84 75 void Vector2D::Rotate(float value) {85 template <typename T> void Vector2D<T>::Rotate(float value) { 76 86 float xTmp; 77 87 xTmp = x * cosf(value) - y * sinf(value); … … 80 90 } 81 91 82 void Vector2D::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); }92 template <typename T> void Vector2D<T>::RotateDeg(float value) { Rotate(Euler::ToRadian(value)); } 83 93 84 float Vector2D::GetNorm(void) const { return sqrt(x * x + y * y); }94 template <typename T> float Vector2D<T>::GetNorm(void) const { return sqrt(x * x + y * y); } 85 95 86 void Vector2D::Normalize(void) {96 template <typename T> void Vector2D<T>::Normalize(void) { 87 97 float n = GetNorm(); 88 98 if (n != 0) { … … 92 102 } 93 103 94 void Vector2D::Saturate(Vector2D min, Vector2D max) {104 template <typename T> void Vector2D<T>::Saturate(Vector2D min, Vector2D max) { 95 105 if (x < min.x) 96 106 x = min.x; … … 104 114 } 105 115 106 void Vector2D::Saturate(float min, float max) {116 template <typename T> void Vector2D<T>::Saturate(float min, float max) { 107 117 Saturate(Vector2D(min, min), Vector2D(max, max)); 108 118 } 109 119 110 void Vector2D::Saturate(const Vector2D &value) {120 template <typename T> void Vector2D<T>::Saturate(const Vector2D &value) { 111 121 float x = fabs(value.x); 112 122 float y = fabs(value.y); … … 114 124 } 115 125 116 void Vector2D::Saturate(float value) {126 template <typename T> void Vector2D<T>::Saturate(float value) { 117 127 float sat = fabs(value); 118 128 Saturate(Vector2D(-sat, -sat), Vector2D(sat, sat)); -
trunk/lib/FlairCore/src/Vector2D.h
r161 r167 21 21 * \brief Class defining a 2D vector 22 22 */ 23 template <typename T> 23 24 class Vector2D { 24 25 public: … … 31 32 * \param y 32 33 */ 33 Vector2D( float x = 0, floaty = 0);34 Vector2D(T x = 0, T y = 0); 34 35 35 36 /*! … … 73 74 * \param max maximum Vector2D value 74 75 */ 75 void Saturate(Vector2D min, Vector2Dmax);76 void Saturate(Vector2D<T> min, Vector2D<T> max); 76 77 77 78 /*! … … 92 93 * \param value saturation Vector2D value 93 94 */ 94 void Saturate(const Vector2D &value);95 void Saturate(const Vector2D<T> &value); 95 96 96 97 /*! … … 106 107 * \brief x 107 108 */ 108 floatx;109 T x; 109 110 110 111 /*! 111 112 * \brief y 112 113 */ 113 floaty;114 T y; 114 115 115 Vector2D &operator=(const Vector2D &vector); 116 Vector2D &operator+=(const Vector2D &vector); 117 Vector2D &operator-=(const Vector2D &vector); 116 template<typename S> Vector2D<T> &operator=(const Vector2D<S> &vector) { 117 x = vector.x; 118 y = vector.y; 119 return (*this); 120 } 121 Vector2D<T> &operator+=(const Vector2D<T> &vector); 122 Vector2D<T> &operator-=(const Vector2D<T> &vector); 118 123 }; 124 125 typedef Vector2D<float> Vector2Df; 119 126 120 127 /*! Add … … 125 132 * \param vectorB vector 126 133 */ 127 Vector2D operator+(const Vector2D &vectorA, const Vector2D&vectorB);134 template<typename T> Vector2D<T> operator+(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 128 135 129 136 /*! Substract … … 134 141 * \param vectorB vector 135 142 */ 136 Vector2D operator-(const Vector2D &vectorA, const Vector2D&vectorB);143 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA, const Vector2D<T> &vectorB); 137 144 138 145 /*! Opposite … … 144 151 * \return -vectorA 145 152 */ 146 Vector2D operator-(const Vector2D&vectorA);153 template<typename T> Vector2D<T> operator-(const Vector2D<T> &vectorA); 147 154 148 155 /*! Divid … … 154 161 * \return vector/coefficient 155 162 */ 156 Vector2D operator/(const Vector2D&vector, float coeff);163 template<typename T> Vector2D<T> operator/(const Vector2D<T> &vector, float coeff); 157 164 158 165 /*! Multiply … … 164 171 * \return coefficient*vector 165 172 */ 166 Vector2D operator*(const Vector2D&vector, float coeff);173 template<typename T> Vector2D<T> operator*(const Vector2D<T> &vector, float coeff); 167 174 168 175 /*! Multiply … … 174 181 * \return coefficient*vector 175 182 */ 176 Vector2D operator*(float coeff, const Vector2D&vector);183 template<typename T> Vector2D<T> operator*(float coeff, const Vector2D<T> &vector); 177 184 178 185 } // end namespace core -
trunk/lib/FlairCore/src/Vector3D.cpp
r15 r167 23 23 #include "Object.h" 24 24 #include <math.h> 25 //#include "Vector3DSpinBox.h"26 25 27 26 namespace flair { 28 27 namespace core { 29 30 Vector3D::Vector3D(float inX, float inY, float inZ) : x(inX), y(inY), z(inZ) {} 31 32 Vector3D::~Vector3D() {} 28 29 template class Vector3D<double>; 30 template Vector3D<double> operator+(const Vector3D<double>&, const Vector3D<double>&); 31 template Vector3D<double> operator-(const Vector3D<double>&, const Vector3D<double>&); 32 template Vector3D<double> operator-(const Vector3D<double>&); 33 template Vector3D<double> operator/(const Vector3D<double>&, float); 34 template Vector3D<double> operator*(const Vector3D<double>&, const Vector3D<double>&); 35 template Vector3D<double> operator*(const Vector3D<double>&, float); 36 template Vector3D<double> operator*(float, const Vector3D<double>&); 37 template Vector3D<double> CrossProduct(const Vector3D<double>&, const Vector3D<double>&); 38 template float DotProduct(const Vector3D<double>&, const Vector3D<double>&); 39 40 template class Vector3D<float>; 41 template Vector3D<float> operator+(const Vector3D<float>&, const Vector3D<float>&); 42 template Vector3D<float> operator-(const Vector3D<float>&, const Vector3D<float>&); 43 template Vector3D<float> operator-(const Vector3D<float>&); 44 template Vector3D<float> operator/(const Vector3D<float>&, float); 45 template Vector3D<float> operator*(const Vector3D<float>&, const Vector3D<float>&); 46 template Vector3D<float> operator*(const Vector3D<float>&, float); 47 template Vector3D<float> operator*(float, const Vector3D<float>&); 48 template Vector3D<float> CrossProduct(const Vector3D<float>&, const Vector3D<float>&); 49 template float DotProduct(const Vector3D<float>&, const Vector3D<float>&); 50 51 template <typename T> Vector3D<T>::Vector3D(T inX, T inY, T inZ) { 52 x=inX; 53 y=inY; 54 z=inZ; 55 } 56 57 template <typename T> Vector3D<T>::~Vector3D() {} 58 33 59 /* 34 60 void Vector3D::operator=(const gui::Vector3DSpinBox *vector) { … … 38 64 z=vect.z; 39 65 }*/ 40 41 Vector3D &Vector3D::operator=(const Vector3D &vector) { 66 /* 67 template<typename T,typename S> Vector3D<T> &Vector3D<T>::operator=(const Vector3D<S> &vector) { 68 //template <typename T> Vector3D<T> &Vector3D<T>::operator=(const Vector3D<T> &vector) { 42 69 x = vector.x; 43 70 y = vector.y; … … 45 72 return (*this); 46 73 } 47 48 Vector3D &Vector3D::operator+=(const Vector3D&vector) {74 */ 75 template <typename T> Vector3D<T> &Vector3D<T>::operator+=(const Vector3D<T> &vector) { 49 76 x += vector.x; 50 77 y += vector.y; … … 53 80 } 54 81 55 Vector3D &Vector3D::operator-=(const Vector3D&vector) {82 template <typename T> Vector3D<T> &Vector3D<T>::operator-=(const Vector3D<T> &vector) { 56 83 x -= vector.x; 57 84 y -= vector.y; … … 60 87 } 61 88 62 float &Vector3D::operator[](size_t idx) {89 template <typename T> T &Vector3D<T>::operator[](size_t idx) { 63 90 if (idx == 0) { 64 91 return x; … … 73 100 } 74 101 75 const float &Vector3D::operator[](size_t idx) const {102 template <typename T> const T &Vector3D<T>::operator[](size_t idx) const { 76 103 if (idx == 0) { 77 104 return x; … … 86 113 } 87 114 88 Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D&vectorB) {89 return Vector3D (vectorA.y * vectorB.z - vectorA.z * vectorB.y,115 template <typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) { 116 return Vector3D<T>(vectorA.y * vectorB.z - vectorA.z * vectorB.y, 90 117 vectorA.z * vectorB.x - vectorA.x * vectorB.z, 91 118 vectorA.x * vectorB.y - vectorA.y * vectorB.x); 92 119 } 93 120 94 float DotProduct(const Vector3D &vectorA, const Vector3D&vectorB) {121 template <typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) { 95 122 return vectorA.x * vectorB.x + vectorA.y * vectorB.y + vectorA.z * vectorB.z; 96 123 } 97 124 98 Vector3D operator+(const Vector3D &vectorA, const Vector3D&vectorB) {99 return Vector3D (vectorA.x + vectorB.x, vectorA.y + vectorB.y,125 template <typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) { 126 return Vector3D<T>(vectorA.x + vectorB.x, vectorA.y + vectorB.y, 100 127 vectorA.z + vectorB.z); 101 128 } 102 129 103 Vector3D operator-(const Vector3D &vectorA, const Vector3D&vectorB) {104 return Vector3D (vectorA.x - vectorB.x, vectorA.y - vectorB.y,130 template <typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) { 131 return Vector3D<T>(vectorA.x - vectorB.x, vectorA.y - vectorB.y, 105 132 vectorA.z - vectorB.z); 106 133 } 107 134 108 Vector3D operator-(const Vector3D&vector) {109 return Vector3D (-vector.x, -vector.y, -vector.z);110 } 111 112 Vector3D operator*(const Vector3D &vectorA, const Vector3D&vectorB) {113 return Vector3D (vectorA.x * vectorB.x, vectorA.y * vectorB.y,135 template <typename T> Vector3D<T> operator-(const Vector3D<T> &vector) { 136 return Vector3D<T>(-vector.x, -vector.y, -vector.z); 137 } 138 139 template <typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB) { 140 return Vector3D<T>(vectorA.x * vectorB.x, vectorA.y * vectorB.y, 114 141 vectorA.z * vectorB.z); 115 142 } 116 143 117 Vector3D operator*(const Vector3D&vector, float coeff) {118 return Vector3D (vector.x * coeff, vector.y * coeff, vector.z * coeff);119 } 120 121 Vector3D operator*(float coeff, const Vector3D&vector) {122 return Vector3D (vector.x * coeff, vector.y * coeff, vector.z * coeff);123 } 124 125 Vector3D operator/(const Vector3D&vector, float coeff) {144 template <typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff) { 145 return Vector3D<T>(vector.x * coeff, vector.y * coeff, vector.z * coeff); 146 } 147 148 template <typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector) { 149 return Vector3D<T>(vector.x * coeff, vector.y * coeff, vector.z * coeff); 150 } 151 152 template <typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff) { 126 153 if (coeff != 0) { 127 return Vector3D (vector.x / coeff, vector.y / coeff, vector.z / coeff);154 return Vector3D<T>(vector.x / coeff, vector.y / coeff, vector.z / coeff); 128 155 } else { 129 156 printf("Vector3D: err divinding by 0\n"); 130 return Vector3D (0, 0, 0);131 } 132 } 133 134 void Vector3D::RotateX(float value) {157 return Vector3D<T>(0, 0, 0); 158 } 159 } 160 161 template <typename T> void Vector3D<T>::RotateX(float value) { 135 162 float y_tmp; 136 163 y_tmp = y * cosf(value) - z * sinf(value); … … 139 166 } 140 167 141 void Vector3D::RotateXDeg(float value) { RotateX(Euler::ToRadian(value)); }142 143 void Vector3D::RotateY(float value) {168 template <typename T> void Vector3D<T>::RotateXDeg(float value) { RotateX(Euler::ToRadian(value)); } 169 170 template <typename T> void Vector3D<T>::RotateY(float value) { 144 171 float x_tmp; 145 172 x_tmp = x * cosf(value) + z * sinf(value); … … 148 175 } 149 176 150 void Vector3D::RotateYDeg(float value) { RotateY(Euler::ToRadian(value)); }151 152 void Vector3D::RotateZ(float value) {177 template <typename T> void Vector3D<T>::RotateYDeg(float value) { RotateY(Euler::ToRadian(value)); } 178 179 template <typename T> void Vector3D<T>::RotateZ(float value) { 153 180 float x_tmp; 154 181 x_tmp = x * cosf(value) - y * sinf(value); … … 157 184 } 158 185 159 void Vector3D::RotateZDeg(float value) { RotateZ(Euler::ToRadian(value)); }160 161 void Vector3D::Rotate(const RotationMatrix &matrix) {162 floata[3] = {0, 0, 0};163 floatb[3] = {x, y, z};186 template <typename T> void Vector3D<T>::RotateZDeg(float value) { RotateZ(Euler::ToRadian(value)); } 187 188 template <typename T> void Vector3D<T>::Rotate(const RotationMatrix &matrix) { 189 T a[3] = {0, 0, 0}; 190 T b[3] = {x, y, z}; 164 191 165 192 for (int i = 0; i < 3; i++) { … … 174 201 } 175 202 176 void Vector3D::Rotate(const Quaternion &quaternion) {203 template <typename T> void Vector3D<T>::Rotate(const Quaternion &quaternion) { 177 204 RotationMatrix matrix; 178 205 quaternion.ToRotationMatrix(matrix); … … 180 207 } 181 208 182 void Vector3D::To2Dxy(Vector2D&vector) const {209 template <typename T> void Vector3D<T>::To2Dxy(Vector2D<T> &vector) const { 183 210 vector.x = x; 184 211 vector.y = y; 185 212 } 186 213 187 Vector2D Vector3D::To2Dxy(void) const {188 Vector2D vect;214 template <typename T> Vector2D<T> Vector3D<T>::To2Dxy(void) const { 215 Vector2D<T> vect; 189 216 To2Dxy(vect); 190 217 return vect; 191 218 } 192 219 193 float Vector3D::GetNorm(void) const { return sqrt(x * x + y * y + z * z); }194 195 void Vector3D::Normalize(void) {220 template <typename T> float Vector3D<T>::GetNorm(void) const { return sqrt(x * x + y * y + z * z); } 221 222 template <typename T> void Vector3D<T>::Normalize(void) { 196 223 float n = GetNorm(); 197 224 if (n != 0) { … … 202 229 } 203 230 204 void Vector3D::Saturate(const Vector3D &min, const Vector3D&max) {231 template <typename T> void Vector3D<T>::Saturate(const Vector3D<T> &min, const Vector3D<T> &max) { 205 232 if (x < min.x) 206 233 x = min.x; … … 219 246 } 220 247 221 void Vector3D::Saturate(float min, float max) {222 Saturate(Vector3D (min, min, min), Vector3D(max, max, max));223 } 224 225 void Vector3D::Saturate(const Vector3D&value) {248 template <typename T> void Vector3D<T>::Saturate(float min, float max) { 249 Saturate(Vector3D<T>(min, min, min), Vector3D<T>(max, max, max)); 250 } 251 252 template <typename T> void Vector3D<T>::Saturate(const Vector3D<T> &value) { 226 253 float x = fabs(value.x); 227 254 float y = fabs(value.y); 228 255 float z = fabs(value.z); 229 Saturate(Vector3D (-x, -y, -z), Vector3D(x, y, z));230 } 231 232 void Vector3D::Saturate(float value) {256 Saturate(Vector3D<T>(-x, -y, -z), Vector3D<T>(x, y, z)); 257 } 258 259 template <typename T> void Vector3D<T>::Saturate(float value) { 233 260 float sat = fabs(value); 234 Saturate(Vector3D (-sat, -sat, -sat), Vector3D(sat, sat, sat));261 Saturate(Vector3D<T>(-sat, -sat, -sat), Vector3D<T>(sat, sat, sat)); 235 262 } 236 263 -
trunk/lib/FlairCore/src/Vector3D.h
r15 r167 15 15 16 16 #include <stddef.h> 17 #include <Vector2D.h> 17 18 18 19 namespace flair { 19 20 namespace core { 20 class Vector2D;21 21 class RotationMatrix; 22 22 class Quaternion; … … 26 26 * \brief Class defining a 3D vector 27 27 */ 28 template <typename T> 28 29 class Vector3D { 29 30 public: … … 37 38 * \param z 38 39 */ 39 Vector3D( float x = 0, float y = 0, floatz = 0);40 Vector3D(T x = 0, T y = 0, T z = 0); 40 41 41 42 /*! … … 48 49 * \brief x 49 50 */ 50 floatx;51 T x; 51 52 52 53 /*! 53 54 * \brief y 54 55 */ 55 floaty;56 T y; 56 57 57 58 /*! 58 59 * \brief z 59 60 */ 60 floatz;61 T z; 61 62 62 63 /*! … … 126 127 * \param vector destination 127 128 */ 128 void To2Dxy(Vector2D &vector) const;129 void To2Dxy(Vector2D<T> &vector) const; 129 130 130 131 /*! … … 135 136 * \return destination 136 137 */ 137 Vector2D To2Dxy(void) const;138 Vector2D<T> To2Dxy(void) const; 138 139 139 140 /*! … … 157 158 * \param max maximum value 158 159 */ 159 void Saturate(const Vector3D &min, const Vector3D&max);160 void Saturate(const Vector3D<T> &min, const Vector3D<T> &max); 160 161 161 162 /*! … … 176 177 * \param value saturation Vector3D value 177 178 */ 178 void Saturate(const Vector3D &value);179 void Saturate(const Vector3D<T> &value); 179 180 180 181 /*! … … 188 189 void Saturate(float value); 189 190 190 float &operator[](size_t idx); 191 const float &operator[](size_t idx) const; 192 Vector3D &operator=(const Vector3D &vector); 193 Vector3D &operator+=(const Vector3D &vector); 194 Vector3D &operator-=(const Vector3D &vector); 191 T &operator[](size_t idx); 192 const T &operator[](size_t idx) const; 193 //Vector3D<T> &operator=(const Vector3D<T> &vector); 194 template<typename S> Vector3D<T> &operator=(const Vector3D<S> &vector) { 195 x = vector.x; 196 y = vector.y; 197 z = vector.z; 198 return (*this); 199 } 200 Vector3D<T> &operator+=(const Vector3D<T> &vector); 201 Vector3D<T> &operator-=(const Vector3D<T> &vector); 195 202 196 203 private: 197 204 }; 198 205 206 typedef Vector3D<float> Vector3Df; 207 199 208 /*! Add 200 209 * … … 206 215 * \return vectorA+vectorB 207 216 */ 208 Vector3D operator+(const Vector3D &vectorA, const Vector3D&vectorB);217 template<typename T> Vector3D<T> operator+(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 209 218 210 219 /*! Substract … … 217 226 * \return vectorA-vectorB 218 227 */ 219 Vector3D operator-(const Vector3D &vectorA, const Vector3D&vectorB);228 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 220 229 221 230 /*! Minus … … 227 236 * \return -vector 228 237 */ 229 Vector3D operator-(const Vector3D&vector);238 template<typename T> Vector3D<T> operator-(const Vector3D<T> &vector); 230 239 231 240 /*! Divid … … 238 247 * \return vector/coefficient 239 248 */ 240 Vector3D operator/(const Vector3D&vector, float coeff);249 template<typename T> Vector3D<T> operator/(const Vector3D<T> &vector, float coeff); 241 250 242 251 /*! Hadamard product … … 249 258 * \return Hadamard product 250 259 */ 251 Vector3D operator*(const Vector3D &vectorA, const Vector3D&vectorB);260 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 252 261 253 262 /*! Multiply … … 260 269 * \return coefficient*vector 261 270 */ 262 Vector3D operator*(const Vector3D&vector, float coeff);271 template<typename T> Vector3D<T> operator*(const Vector3D<T> &vector, float coeff); 263 272 264 273 /*! Multiply … … 271 280 * \return coefficient*vector 272 281 */ 273 Vector3D operator*(float coeff, const Vector3D&vector);282 template<typename T> Vector3D<T> operator*(float coeff, const Vector3D<T> &vector); 274 283 275 284 /*! Cross product … … 282 291 * \return cross product 283 292 */ 284 Vector3D CrossProduct(const Vector3D &vectorA, const Vector3D&vectorB);293 template<typename T> Vector3D<T> CrossProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 285 294 286 295 /*! Dot product … … 293 302 * \return dot product 294 303 */ 295 float DotProduct(const Vector3D &vectorA, const Vector3D&vectorB);304 template<typename T> float DotProduct(const Vector3D<T> &vectorA, const Vector3D<T> &vectorB); 296 305 297 306 } // end namespace core -
trunk/lib/FlairCore/src/Vector3DSpinBox.cpp
r15 r167 26 26 Vector3DSpinBox::Vector3DSpinBox(const LayoutPosition *position, string name, 27 27 double min, double max, double step, 28 int decimals, core::Vector3D default_value)28 int decimals, core::Vector3Df default_value) 29 29 : Box(position, name, "Vector3DSpinBox") { 30 30 // update value from xml file … … 52 52 } 53 53 */ 54 core::Vector3D Vector3DSpinBox::Value(void) const {55 core::Vector3D tmp;54 core::Vector3Df Vector3DSpinBox::Value(void) const { 55 core::Vector3Df tmp; 56 56 57 57 GetMutex(); -
trunk/lib/FlairCore/src/Vector3DSpinBox.h
r15 r167 44 44 Vector3DSpinBox(const LayoutPosition *position, std::string name, double min, 45 45 double max, double step, int decimals = 2, 46 core::Vector3D default_value = core::Vector3D(0, 0, 0));46 core::Vector3Df default_value = core::Vector3Df(0, 0, 0)); 47 47 48 48 /*! … … 57 57 * \return value 58 58 */ 59 core::Vector3D Value(void) const;59 core::Vector3Df Value(void) const; 60 60 // operator core::Vector3D() const; 61 61 private: … … 68 68 void XmlEvent(void); 69 69 70 core::Vector3D box_value;70 core::Vector3Df box_value; 71 71 }; 72 72 -
trunk/lib/FlairCore/src/Vector3Ddata.h
r15 r167 26 26 * User must manually use the io_data's Mutex to access to Vector3D values. 27 27 */ 28 class Vector3Ddata : public io_data, public Vector3D {28 class Vector3Ddata : public io_data, public Vector3Df { 29 29 public: 30 30 /*! -
trunk/lib/FlairCore/src/unexported/OneAxisRotation_impl.h
r144 r167 14 14 #define ONEAXISROTATION_IMPL_H 15 15 16 #include <Vector3D.h> 17 16 18 namespace flair { 17 19 namespace core { 18 class Vector3D;19 20 class Euler; 20 21 class Quaternion; … … 36 37 OneAxisRotation_impl(flair::gui::GroupBox *box); 37 38 ~OneAxisRotation_impl(); 38 void ComputeRotation(flair::core::Vector3D&point) const;39 template <typename T> void ComputeRotation(flair::core::Vector3D<T> &point) const; 39 40 void ComputeRotation(flair::core::Quaternion &quat) const; 40 41 void ComputeRotation(flair::core::RotationMatrix &matrix) const; -
trunk/lib/FlairFilter/src/Ahrs.h
r51 r167 19 19 namespace flair { 20 20 namespace core { 21 class Euler;22 class Vector3D;23 class ImuData;24 class Quaternion;25 21 class AhrsData; 26 22 } -
trunk/lib/FlairFilter/src/AhrsComplementaryFilter.cpp
r157 r167 64 64 AhrsData* ahrsData; 65 65 GetDatas(&ahrsData); 66 Vector3D rawAcc,rawMag,rawGyr;66 Vector3Df rawAcc,rawMag,rawGyr; 67 67 input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr); 68 68 … … 70 70 previous_time=data->DataTime(); 71 71 72 Vector3D aBar,aHat,aTilde;73 Vector3D mBar,mHat,mTilde;74 Vector3D alpha,dBHat,omegaHat;72 Vector3Df aBar,aHat,aTilde; 73 Vector3Df mBar,mHat,mTilde; 74 Vector3Df alpha,dBHat,omegaHat; 75 75 Quaternion dQHat; 76 76 -
trunk/lib/FlairFilter/src/AhrsComplementaryFilter.h
r24 r167 66 66 bool isInit; 67 67 core::Quaternion QHat; 68 core::Vector3D BHat;68 core::Vector3Df BHat; 69 69 gui::DoubleSpinBox *ka[3]; 70 70 gui::DoubleSpinBox *kb[3]; -
trunk/lib/FlairFilter/src/AhrsKalman_impl.cpp
r18 r167 86 86 ImuData *input=(ImuData*)data; 87 87 float delta_t; 88 Vector3D rawAcc,rawMag,rawGyr;88 Vector3Df rawAcc,rawMag,rawGyr; 89 89 90 90 input->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr); … … 115 115 116 116 ahrsData->SetQuaternionAndAngularRates(euler.ToQuaternion(), 117 rawGyr-Vector3D (ars_roll.x_bias,ars_pitch.x_bias,0));117 rawGyr-Vector3Df(ars_roll.x_bias,ars_pitch.x_bias,0)); 118 118 } else { 119 119 is_init=true; -
trunk/lib/FlairFilter/src/Gx3_25_ahrs.cpp
r157 r167 44 44 45 45 Quaternion quaternion; 46 Vector3D filteredAngRates;46 Vector3Df filteredAngRates; 47 47 input->GetQuaternionAndAngularRates(quaternion, filteredAngRates); 48 48 GetImu()->GetOneAxisRotation()->ComputeRotation(quaternion); -
trunk/lib/FlairFilter/src/JoyReference_impl.cpp
r148 r167 168 168 input->GetMutex(); 169 169 170 Vector3D theta_xy(170 Vector3Df theta_xy( 171 171 -Euler::ToRadian(input->ValueNoMutex(0, 0) * deb_roll->Value()), 172 172 -Euler::ToRadian(input->ValueNoMutex(1, 0) * deb_pitch->Value()), 0); 173 Vector3D e_bar = theta_xy;173 Vector3Df e_bar = theta_xy; 174 174 e_bar.Normalize(); 175 175 Quaternion q_xy(cos(theta_xy.GetNorm() / 2.0f), … … 192 192 input->ReleaseMutex(); 193 193 194 ahrsData->SetQuaternionAndAngularRates(q_ref, Vector3D (0, 0, wz_ref));194 ahrsData->SetQuaternionAndAngularRates(q_ref, Vector3Df(0, 0, wz_ref)); 195 195 196 196 // ouput quaternion for control law -
trunk/lib/FlairFilter/src/SimuAhrs.cpp
r158 r167 42 42 43 43 Quaternion quaternion; 44 Vector3D filteredAngRates;44 Vector3Df filteredAngRates; 45 45 input->GetQuaternionAndAngularRates(quaternion, filteredAngRates); 46 46 output->SetQuaternionAndAngularRates(quaternion, filteredAngRates); -
trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle.cpp
r157 r167 48 48 } 49 49 50 void TrajectoryGenerator2DCircle::StartTraj(const Vector2D &start_pos,50 void TrajectoryGenerator2DCircle::StartTraj(const Vector2Df &start_pos, 51 51 float nb_lap) { 52 52 pimpl_->StartTraj(start_pos, nb_lap); … … 57 57 void TrajectoryGenerator2DCircle::StopTraj(void) { pimpl_->is_running = false; } 58 58 59 void TrajectoryGenerator2DCircle::GetPosition(Vector2D &point) const {59 void TrajectoryGenerator2DCircle::GetPosition(Vector2Df &point) const { 60 60 point.x = pimpl_->output->Value(0, 0); 61 61 point.y = pimpl_->output->Value(0, 1); 62 62 } 63 63 64 void TrajectoryGenerator2DCircle::SetCenter(const Vector2D &value) {64 void TrajectoryGenerator2DCircle::SetCenter(const Vector2Df &value) { 65 65 pimpl_->pos_off = value; 66 66 } 67 67 68 void TrajectoryGenerator2DCircle::GetSpeed(Vector2D &point) const {68 void TrajectoryGenerator2DCircle::GetSpeed(Vector2Df &point) const { 69 69 point.x = pimpl_->output->Value(1, 0); 70 70 point.y = pimpl_->output->Value(1, 1); 71 71 } 72 72 73 void TrajectoryGenerator2DCircle::SetCenterSpeed(const Vector2D &value) {73 void TrajectoryGenerator2DCircle::SetCenterSpeed(const Vector2Df &value) { 74 74 pimpl_->vel_off = value; 75 75 } -
trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle.h
r15 r167 15 15 16 16 #include <IODevice.h> 17 #include <Vector2D.h> 17 18 18 19 namespace flair { 19 20 namespace core { 20 21 class cvmatrix; 21 class Vector2D;22 22 } 23 23 namespace gui { … … 72 72 * \param nb_lap number of laps, -1 for infinite 73 73 */ 74 void StartTraj(const core::Vector2D &start_pos, float nb_lap = -1);74 void StartTraj(const core::Vector2Df &start_pos, float nb_lap = -1); 75 75 76 76 /*! … … 93 93 * \param value center position 94 94 */ 95 void SetCenter(const core::Vector2D &value);95 void SetCenter(const core::Vector2Df &value); 96 96 97 97 /*! … … 100 100 * \param value center speed 101 101 */ 102 void SetCenterSpeed(const core::Vector2D &value);102 void SetCenterSpeed(const core::Vector2Df &value); 103 103 104 104 /*! … … 117 117 * \param point returned position 118 118 */ 119 void GetPosition(core::Vector2D &point) const;119 void GetPosition(core::Vector2Df &point) const; 120 120 121 121 /*! … … 124 124 * \param point returned speed 125 125 */ 126 void GetSpeed(core::Vector2D &point) const;126 void GetSpeed(core::Vector2Df &point) const; 127 127 128 128 /*! -
trunk/lib/FlairFilter/src/TrajectoryGenerator2DCircle_impl.cpp
r148 r167 64 64 } 65 65 66 void TrajectoryGenerator2DCircle_impl::StartTraj(const Vector2D &start_pos,66 void TrajectoryGenerator2DCircle_impl::StartTraj(const Vector2Df &start_pos, 67 67 float nb_lap) { 68 68 is_running = true; … … 89 89 float A = acceleration->Value(); 90 90 float R = rayon->Value(); 91 Vector2D v;91 Vector2Df v; 92 92 93 93 if (V < 0) -
trunk/lib/FlairFilter/src/unexported/TrajectoryGenerator2DCircle_impl.h
r15 r167 43 43 ~TrajectoryGenerator2DCircle_impl(); 44 44 void Update(flair::core::Time time); 45 void StartTraj(const flair::core::Vector2D &start_pos, float nb_lap);45 void StartTraj(const flair::core::Vector2Df &start_pos, float nb_lap); 46 46 void FinishTraj(void); 47 47 bool is_running; 48 48 flair::core::cvmatrix *output; 49 flair::core::Vector2D pos_off, vel_off;49 flair::core::Vector2Df pos_off, vel_off; 50 50 51 51 private: … … 53 53 float CurrentTime, FinishTime; 54 54 bool first_update, is_finishing; 55 flair::core::Vector2D pos;55 flair::core::Vector2Df pos; 56 56 float angle_off; 57 57 flair::gui::DoubleSpinBox *T, *veloctity, *acceleration, *rayon; -
trunk/lib/FlairMeta/src/MetaVrpnObject.cpp
r148 r167 28 28 #include <TabWidget.h> 29 29 #include <cvmatrix.h> 30 #include <Vector3D.h>31 30 32 31 using std::string; … … 55 54 desc->SetElementName(i, 0, Output()->Name(i, 0)); 56 55 } 57 cvmatrix *prev_value = new cvmatrix(this, desc, elementDataType, name);56 cvmatrix *prev_value = new cvmatrix(this, desc, floatType, name); 58 57 delete desc; 59 58 … … 66 65 desc->SetElementName(i, 0, "d" + Output()->Name(i, 0)); 67 66 } 68 prev_value = new cvmatrix(this, desc, elementDataType, name);67 prev_value = new cvmatrix(this, desc, floatType, name); 69 68 delete desc; 70 69 … … 95 94 DataPlot2D *MetaVrpnObject::XyPlot(void) const { return xy_plot; } 96 95 97 void MetaVrpnObject::GetSpeed(Vector3D &speed) const {96 void MetaVrpnObject::GetSpeed(Vector3Df &speed) const { 98 97 speed.x = euler->Output(4, 0); 99 98 speed.y = euler->Output(5, 0); -
trunk/lib/FlairMeta/src/MetaVrpnObject.h
r122 r167 15 15 16 16 #include <VrpnObject.h> 17 #include "io_data.h" 17 #include <io_data.h> 18 #include <Vector3D.h> 18 19 19 20 namespace flair { 20 namespace core {21 class Vector3D;22 class FloatType;23 }24 21 namespace gui { 25 22 class DataPlot1D; … … 51 48 gui::DataPlot1D *VzPlot(void) const; // 1,2 52 49 gui::DataPlot2D *XyPlot(void) const; 53 void GetSpeed(core::Vector3D &speed) const;50 void GetSpeed(core::Vector3Df &speed) const; 54 51 55 52 private: … … 60 57 gui::DataPlot1D *vx_opti_plot, *vy_opti_plot, *vz_opti_plot; 61 58 gui::Tab *plot_tab; 62 core::FloatType elementDataType;63 59 }; 64 60 } // end namespace meta -
trunk/lib/FlairMeta/src/UavStateMachine.cpp
r164 r167 132 132 } 133 133 134 const Vector3D &UavStateMachine::GetCurrentAngularSpeed(void) const {134 const Vector3Df &UavStateMachine::GetCurrentAngularSpeed(void) const { 135 135 return currentAngularSpeed; 136 136 } … … 423 423 const AhrsData *refOrientation = ComputeReferenceOrientation(); 424 424 Quaternion refQuaternion; 425 Vector3D refAngularRates;425 Vector3Df refAngularRates; 426 426 refOrientation->GetQuaternionAndAngularRates(refQuaternion, 427 427 refAngularRates); -
trunk/lib/FlairMeta/src/UavStateMachine.h
r165 r167 107 107 const core::Quaternion &GetCurrentQuaternion(void) const; 108 108 109 const core::Vector3D &GetCurrentAngularSpeed(void) const;109 const core::Vector3Df &GetCurrentAngularSpeed(void) const; 110 110 111 111 void Land(void); … … 267 267 268 268 core::Quaternion currentQuaternion; 269 core::Vector3D currentAngularSpeed;269 core::Vector3Df currentAngularSpeed; 270 270 271 271 const core::AhrsData *ComputeReferenceOrientation(void); -
trunk/lib/FlairSensorActuator/src/Gx3_25_imu_impl.cpp
r157 r167 130 130 eulerAngles.yaw = Dequeue(&buf); 131 131 132 Vector3D filteredAngRates;132 Vector3Df filteredAngRates; 133 133 filteredAngRates.x = Dequeue(&buf); 134 134 filteredAngRates.y = Dequeue(&buf); … … 143 143 GetData(response, sizeof(response), &imuTime); 144 144 145 Vector3D rawAcc;145 Vector3Df rawAcc; 146 146 rawAcc.x = 9.80665 * Dequeue(&buf); 147 147 rawAcc.y = 9.80665 * Dequeue(&buf); 148 148 rawAcc.z = 9.80665 * Dequeue(&buf); 149 149 150 Vector3D filteredAngRates;150 Vector3Df filteredAngRates; 151 151 filteredAngRates.x = Dequeue(&buf); 152 152 filteredAngRates.y = Dequeue(&buf); … … 178 178 quaternion.q3 = Dequeue(&buf); 179 179 180 Vector3D filteredAngRates;180 Vector3Df filteredAngRates; 181 181 filteredAngRates.x = 0; 182 182 filteredAngRates.y = 0; -
trunk/lib/FlairSensorActuator/src/Imu.cpp
r137 r167 69 69 return; 70 70 } 71 Vector3D rawAcc, rawMag, rawGyr;71 Vector3Df rawAcc, rawMag, rawGyr; 72 72 imuData->GetRawAccMagAndGyr(rawAcc, rawMag, rawGyr); 73 73 rotation->ComputeRotation(rawAcc); -
trunk/lib/FlairSensorActuator/src/NmeaGps.cpp
r137 r167 173 173 void NmeaGps::SetRef(void) { takeRef = true; } 174 174 175 void NmeaGps::GetEnu(Vector3D *point) {175 void NmeaGps::GetEnu(Vector3Df *point) { 176 176 gpsData->GetMutex(); 177 177 gpsData->GetEnu(point->x,point->y,point->z); -
trunk/lib/FlairSensorActuator/src/NmeaGps.h
r137 r167 15 15 16 16 #include <IODevice.h> 17 #include <Vector3D.h> 17 18 #include <nmea/nmea.h> 18 19 … … 21 22 class FrameworkManager; 22 23 class GeoCoordinate; 23 class Vector3D;24 24 class GpsData; 25 25 } … … 168 168 * \param point to store position 169 169 */ 170 void GetEnu(core::Vector3D *point);170 void GetEnu(core::Vector3Df *point); 171 171 172 172 protected: -
trunk/lib/FlairSensorActuator/src/SimuImu.cpp
r158 r167 107 107 ahrsData->SetQuaternionAndAngularRates( 108 108 Quaternion(state.q0, state.q1, state.q2, state.q3), 109 Vector3D (state.wx, state.wy, state.wz));109 Vector3Df(state.wx, state.wy, state.wz)); 110 110 111 111 imuData->SetDataTime(GetTime()); -
trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
r140 r167 104 104 } 105 105 106 void VrpnClient_impl::ComputeRotations(Vector3D &point) {106 void VrpnClient_impl::ComputeRotations(Vector3Df &point) { 107 107 rotation_1->ComputeRotation(point); 108 108 rotation_2->ComputeRotation(point); -
trunk/lib/FlairSensorActuator/src/VrpnObject.cpp
r157 r167 77 77 } 78 78 79 void VrpnObject::GetPosition(Vector3D &point) const {79 void VrpnObject::GetPosition(Vector3Df &point) const { 80 80 pimpl_->GetPosition(point); 81 81 } -
trunk/lib/FlairSensorActuator/src/VrpnObject.h
r140 r167 16 16 17 17 #include <IODevice.h> 18 #include <Vector3D.h> 18 19 #include <stdint.h> 19 20 … … 21 22 namespace core { 22 23 class cvmatrix; 23 class Vector3D;24 24 class Quaternion; 25 25 } … … 110 110 * \param point output datas 111 111 */ 112 void GetPosition(core::Vector3D &point) const;112 void GetPosition(core::Vector3Df &point) const; 113 113 114 114 /*! -
trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp
r148 r167 129 129 } 130 130 131 void VrpnObject_impl::GetPosition(Vector3D &point) {131 void VrpnObject_impl::GetPosition(Vector3Df &point) { 132 132 output->GetMutex(); 133 133 point.x = output->ValueNoMutex(4, 0); … … 163 163 // flair::core::Quaternion 164 164 Quaternion quaternion(t.quat[3],t.quat[0],t.quat[1],t.quat[2]); 165 Vector3D pos((float)t.pos[0], (float)t.pos[1], (float)t.pos[2]);165 Vector3Df pos((float)t.pos[0], (float)t.pos[1], (float)t.pos[2]); 166 166 167 167 // on effectue les rotation -
trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h
r140 r167 21 21 #include <string> 22 22 #include <vector> 23 #include "Vector3D.h" 23 24 24 25 namespace flair { 25 26 namespace core { 26 27 class OneAxisRotation; 27 class Vector3D;28 28 class Quaternion; 29 29 class Mutex; … … 54 54 void AddTrackable(VrpnObject_impl *obj, uint8_t id); // xbee 55 55 void RemoveTrackable(VrpnObject_impl *obj); // normal+xbee 56 void ComputeRotations(flair::core::Vector3D &point);56 void ComputeRotations(flair::core::Vector3Df &point); 57 57 void ComputeRotations(flair::core::Quaternion &quat); 58 58 bool UseXbee(void); -
trunk/lib/FlairSensorActuator/src/unexported/VrpnObject_impl.h
r140 r167 24 24 #include <vrpn_Tracker.h> 25 25 #include "Quaternion.h" 26 #include "Vector3D.h" 26 27 27 28 namespace flair { 28 29 namespace core { 29 30 class cvmatrix; 30 class Vector3D;31 31 } 32 32 namespace gui { … … 51 51 52 52 void GetQuaternion(flair::core::Quaternion &quaternion); 53 void GetPosition(flair::core::Vector3D &point);53 void GetPosition(flair::core::Vector3Df &point); 54 54 bool IsTracked(unsigned int timeout_ms); 55 55 -
trunk/lib/FlairSimulator/src/FixedCamera.cpp
r120 r167 35 35 namespace simulator { 36 36 37 FixedCamera::FixedCamera(std::string name,core::Vector3D position,core::Vector3Dlookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name) {37 FixedCamera::FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat,float inRotateSpeed,float inZoomSpeed):VisualizationCamera(name) { 38 38 Rotating = false; 39 39 rotateSpeed=inRotateSpeed; … … 62 62 63 63 //normal between target and up vector 64 cameraAxeY=target.crossProduct( irr::core::vector3df(0,0,1));64 cameraAxeY=target.crossProduct(vector3df(0,0,1)); 65 65 cameraAxeY.normalize(); 66 66 … … 81 81 82 82 //check angle 83 irr::core::vector3df newTarget(q3.X,q3.Y,q3.Z);84 float angle=acos(newTarget.dotProduct( irr::core::vector3df(0,0,1))/newTarget.getLength());85 irr::core::vector3df cross = newTarget.crossProduct(irr::core::vector3df(0,0,1));83 vector3df newTarget(q3.X,q3.Y,q3.Z); 84 float angle=acos(newTarget.dotProduct(vector3df(0,0,1))/newTarget.getLength()); 85 vector3df cross = newTarget.crossProduct(vector3df(0,0,1)); 86 86 if (cross.dotProduct(cameraAxeY) > 0) { 87 87 newTarget += camera->getAbsolutePosition(); -
trunk/lib/FlairSimulator/src/FixedCamera.h
r120 r167 26 26 class FixedCamera : public VisualizationCamera { 27 27 public: 28 FixedCamera(std::string name,core::Vector3D position,core::Vector3D lookat=core::Vector3D(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f);28 FixedCamera(std::string name,core::Vector3Df position,core::Vector3Df lookat=core::Vector3Df(0,0,0),float rotateSpeed = -3.0f, float zoomSpeed = .05f); 29 29 ~FixedCamera(); 30 30 -
trunk/lib/FlairSimulator/src/Gui.cpp
r158 r167 109 109 } 110 110 111 vector3df ToIrrlichtCoordinates(Vector3Dvect) {111 template<typename T> vector3df ToIrrlichtCoordinates(Vector3D<T> vect) { 112 112 return ToIrrlichtScale(1) * vector3df(vect.x, vect.y, -vect.z); 113 113 } 114 114 115 Vector3D ToSimulatorCoordinates(vector3df vect) {116 return ToSimulatorScale(1) * Vector3D (vect.X, vect.Y, -vect.Z);115 Vector3Df ToSimulatorCoordinates(vector3df vect) { 116 return ToSimulatorScale(1) * Vector3Df(vect.X, vect.Y, -vect.Z); 117 117 } 118 118 … … 132 132 return Quaternion(quat.q0, -quat.q1, -quat.q2, quat.q3); 133 133 } 134 135 136 template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<double>); 137 template irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<float>); 134 138 135 139 Gui::Gui(std::string name, int app_width, -
trunk/lib/FlairSimulator/src/Gui.h
r158 r167 19 19 20 20 #include <Object.h> 21 #include <Vector3D.h> 21 22 #include <EDriverTypes.h> 22 23 #include <vector3d.h> … … 36 37 namespace core { 37 38 class Object; 38 class Vector3D;39 39 class Euler; 40 40 class Quaternion; … … 125 125 * \return vector in irrlicht coordinates 126 126 */ 127 irr::core::vector3df ToIrrlichtCoordinates(core::Vector3Dvect);127 template<typename T> irr::core::vector3df ToIrrlichtCoordinates(core::Vector3D<T> vect); 128 128 129 129 /*! … … 136 136 * \return vector in simulator coordinates 137 137 */ 138 core::Vector3D ToSimulatorCoordinates(irr::core::vector3df vect);138 core::Vector3Df ToSimulatorCoordinates(irr::core::vector3df vect); 139 139 140 140 /*! -
trunk/lib/FlairSimulator/src/Man.cpp
r158 r167 73 73 state[0].Quat.Normalize(); 74 74 75 Vector3D dir = state[0].Vel;75 Vector3D<double> dir = state[0].Vel; 76 76 dir.Rotate(state[0].Quat); 77 77 state[0].Pos = state[-1].Pos + dT() * dir; -
trunk/lib/FlairSimulator/src/Model.cpp
r158 r167 69 69 TabWidget *Model::GetTabWidget(void) const { return pimpl_->tabwidget; } 70 70 71 floatModel::dT(void) const { return pimpl_->dT->Value(); }71 double Model::dT(void) const { return pimpl_->dT->Value(); } 72 72 73 73 int Model::GetId(void) const { -
trunk/lib/FlairSimulator/src/Model.h
r158 r167 69 69 typedef struct simu_state { 70 70 core::Quaternion Quat; 71 core::Vector3D W;72 core::Vector3D Pos;73 core::Vector3D Vel;71 core::Vector3Df W; 72 core::Vector3D<double> Pos; 73 core::Vector3D<double> Vel; 74 74 } simu_state_t; 75 75 … … 96 96 protected: 97 97 DiscreteTimeVariable<simu_state_t, 3> state; 98 floatdT(void) const;98 double dT(void) const; 99 99 virtual void CalcModel(void) = 0; 100 100 #ifdef GL -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r163 r167 160 160 states_mutex->GetMutex(); 161 161 Quaternion quat = getSimulator()->ToVRPNReference(self->state[0].Quat); 162 Vector3D position = getSimulator()->ToVRPNReference(self->state[0].Pos);162 Vector3D<double> position = getSimulator()->ToVRPNReference(self->state[0].Pos); 163 163 states_mutex->ReleaseMutex(); 164 164 -
trunk/lib/FlairSimulator/src/Parser.cpp
r158 r167 210 210 } 211 211 212 Vector3D Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) {212 Vector3Df Parser::getMeshVector3D(xmlNode *mesh_node, xmlChar *param) { 213 213 xmlNode *cur_node = NULL; 214 214 for (cur_node = mesh_node; cur_node; cur_node = cur_node->next) { 215 215 if (xmlStrEqual(cur_node->name, param)) { 216 return Vector3D (atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")),216 return Vector3Df(atof((char *)xmlGetProp(cur_node, (xmlChar *)"x")), 217 217 atof((char *)xmlGetProp(cur_node, (xmlChar *)"y")), 218 218 atof((char *)xmlGetProp(cur_node, (xmlChar *)"z"))); 219 219 } 220 220 } 221 return Vector3D (0, 0, 0);221 return Vector3Df(0, 0, 0); 222 222 } 223 223 -
trunk/lib/FlairSimulator/src/Parser.h
r158 r167 19 19 20 20 #include <Gui.h> 21 #include <Vector3D.h> 21 22 #include <libxml/parser.h> 22 23 #include <libxml/tree.h> 23 24 #include <SColor.h> 24 25 namespace flair {26 namespace core {27 class Vector3D;28 }29 }30 25 31 26 namespace flair { … … 53 48 irr::core::vector3df getSceneVect(xmlNode *mesh_node, xmlChar *param, 54 49 bool isScale = false); 55 core::Vector3D getMeshVector3D(xmlNode *mesh_node, xmlChar *param);50 core::Vector3Df getMeshVector3D(xmlNode *mesh_node, xmlChar *param); 56 51 }; 57 52 } -
trunk/lib/FlairSimulator/src/SimuUsGL.cpp
r158 r167 43 43 position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01); 44 44 direction = new Vector3DSpinBox(setup_tab->NewRow(), "direction", -2, 2, .01); 45 range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 6, 1);45 range = new DoubleSpinBox(setup_tab->NewRow(), "range:", 0, 1000, 1,0,6.); 46 46 } 47 47 -
trunk/lib/FlairSimulator/src/Simulator.cpp
r15 r167 56 56 } 57 57 58 Vector3D Simulator::ToVRPNReference(Vector3Dpoint_in) {58 Vector3D<double> Simulator::ToVRPNReference(Vector3D<double> point_in) { 59 59 Quaternion yaw_rot_quat; 60 60 Euler yaw_rot_euler( -
trunk/lib/FlairSimulator/src/Simulator.h
r158 r167 19 19 20 20 #include <FrameworkManager.h> 21 #include <Vector3D.h> 21 22 #include <stdint.h> 22 23 … … 27 28 namespace core { 28 29 class Quaternion; 29 class Vector3D;30 30 } 31 31 } … … 53 53 // coordinate, around z axis 54 54 core::Quaternion ToVRPNReference(core::Quaternion quat_in); 55 core::Vector3D ToVRPNReference(core::Vector3Dpoint_in);55 core::Vector3D<double> ToVRPNReference(core::Vector3D<double> point_in); 56 56 57 57 private: -
trunk/lib/FlairSimulator/src/X4.cpp
r158 r167 282 282 u_thrust = k_mot->Value() * (fl_speed * fl_speed + fr_speed * fr_speed + 283 283 rl_speed * rl_speed + rr_speed * rr_speed); 284 Vector3D vect(0, 0, -u_thrust);284 Vector3D<double> vect(0, 0, -u_thrust); 285 285 vect.Rotate(state[0].Quat); 286 286 … … 291 291 ** =================================================================== 292 292 */ 293 293 294 state[0].Pos.x = 294 295 (dT() * dT() / m->Value()) * 295 (vect.x - 296 f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) + 296 (vect.x - f_air_lat->Value() * (state[-1].Pos.x - state[-2].Pos.x) / dT()) + 297 297 2 * state[-1].Pos.x - state[-2].Pos.x; 298 298 state[0].Vel.x = (state[0].Pos.x - state[-1].Pos.x) / dT(); 299 299 300 300 /* 301 301 ** =================================================================== -
trunk/lib/FlairSimulator/src/X8.cpp
r158 r167 339 339 sigma->Value() * trr_speed * trr_speed + bfl_speed * bfl_speed + 340 340 bfr_speed * bfr_speed + brl_speed * brl_speed + brr_speed * brr_speed); 341 Vector3D vect(0, 0, -u_thrust);341 Vector3D<double> vect(0, 0, -u_thrust); 342 342 vect.Rotate(state[0].Quat); 343 343 -
trunk/lib/FlairSimulator/src/unexported/Model_impl.h
r158 r167 120 120 flair::core::Mutex *collision_mutex; 121 121 bool collision_occured; 122 flair::core::Vector3D collision_point;122 flair::core::Vector3D<double> collision_point; 123 123 #endif 124 124 }; -
trunk/lib/FlairVisionFilter/src/OpticalFlow.cpp
r157 r167 128 128 //apply rotation 129 129 for(i=0;i<count;i++) { 130 Vector3D tmp;130 Vector3Df tmp; 131 131 tmp.x=pointsA[i].x; 132 132 tmp.y=pointsA[i].y;
Note:
See TracChangeset
for help on using the changeset viewer.