KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LE_EulerAngles.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: LE_EulerAngles
32  created: 16/07/2010
33  author: Karl Jones
34 
35  purpose: Stores a vector for the LE family. The values have been reduced from 32 bit
36  floats to 8 bit fixed binaries.
37 
38  Note: The DIS Standard does not state where the binary point is located in 8
39  bit fixed binaries, I have assumed bit 3 like the 16 bit equivalent.
40  size: 24 bits / 3 octets
41 *********************************************************************/
42 
43 #pragma once
44 
45 #include "./KFIXED.h"
46 
47 namespace KDIS {
48 namespace DATA_TYPE {
49 
51 {
52 protected:
53 
55 
57 
59 
60 public:
61 
62  static const KUINT16 LE_EULER_ANGLES_SIZE = 3;
63 
65 
66  // In Radians
67  LE_EulerAngles( KFIXED8_3 Psi, KFIXED8_3 Theta, KFIXED8_3 Phi );
68 
69  LE_EulerAngles( KDataStream & stream ) throw( KException );
70 
71  virtual ~LE_EulerAngles();
72 
73  //************************************
74  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::SetPsi
75  // KDIS::DATA_TYPE::LE_EulerAngles::GetPsi
76  //!Description: Radians / Degrees
77  // Parameter: KFIXED8_3, void
78  //************************************
79  void SetPsiInRadians( KFIXED8_3 Psi );
80  KFIXED8_3 GetPsiInRadians() const;
81  void SetPsiInDegrees( KFIXED8_3 Psi );
82  KFIXED8_3 GetPsiInDegrees() const;
83 
84  //************************************
85  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::SetTheta
86  // KDIS::DATA_TYPE::LE_EulerAngles::GetTheta
87  //!Description: Radians / Degrees
88  // Parameter: KFIXED8_3, void
89  //************************************
90  void SetThetaInRadians( KFIXED8_3 Theta );
91  KFIXED8_3 GetThetaInRadians() const;
92  void SetThetaInDegrees( KFIXED8_3 Theta );
93  KFIXED8_3 GetThetaInDegrees() const;
94 
95  //************************************
96  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::SetPhi
97  // KDIS::DATA_TYPE::LE_EulerAngles::GetPhi
98  //!Description: Radians / Degrees
99  // Parameter: KFIXED8_3, void
100  //************************************
101  void SetPhiInRadians( KFIXED8_3 Phi );
102  KFIXED8_3 GetPhiInRadians() const;
103  void SetPhiInDegrees( KFIXED8_3 Phi );
104  KFIXED8_3 GetPhiInDegrees() const;
105 
106  //************************************
107  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::GetAsString
108  //!Description: Returns a string representation.
109  //************************************
110  virtual KString GetAsString() const;
111 
112  //************************************
113  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::Decode
114  //!Description: Convert From Network Data.
115  // Parameter: KDataStream & stream
116  //************************************
117  virtual void Decode( KDataStream & stream ) throw( KException );
118 
119  //************************************
120  // FullName: KDIS::DATA_TYPE::LE_EulerAngles::Encode
121  //!Description: Convert To Network Data.
122  // Parameter: KDataStream & stream
123  //************************************
124  virtual KDataStream Encode() const;
125  virtual void Encode( KDataStream & stream ) const;
126 
127  KBOOL operator == ( const LE_EulerAngles & Value ) const;
128  KBOOL operator != ( const LE_EulerAngles & Value ) const;
129  LE_EulerAngles operator * ( const LE_EulerAngles & Value ) const;
130  LE_EulerAngles operator * ( KFLOAT64 Value ) const ;
131  LE_EulerAngles operator + ( const LE_EulerAngles & Value ) const;
132  LE_EulerAngles & operator += ( const LE_EulerAngles & Value );
133  LE_EulerAngles operator - ( const LE_EulerAngles & Value ) const;
134  LE_EulerAngles & operator -= ( const LE_EulerAngles & Value );
135 
136  // Valid values 0 - Psi, 1 - Theta, 2 - Phi. throws OUT_OF_BOUNDS exception for any other value.
137  KFIXED8_3 & operator[] ( KUINT16 i ) throw( KException );
138  const KFIXED8_3 & operator[] ( KUINT16 i ) const throw( KException );
139 };
140 
141 } // END namespace DATA_TYPES
142 } // END namespace KDIS
143 
unsigned short int KUINT16
Definition: KDefines.h:101
KFIXED8_3 m_Theta
Definition: LE_EulerAngles.h:56
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
KFIXED8_3 m_Phi
Definition: LE_EulerAngles.h:58
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
double KFLOAT64
Definition: KDefines.h:114
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: LE_EulerAngles.h:50
KFIXED8_3 m_Psi
Definition: LE_EulerAngles.h:54