KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
WorldCoordinates.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: WorldCoordinates
32  created: 18/08/2008
33  author: Karl Jones
34 
35  purpose: World coordinate system.
36  Using a right-handed, geocentric Cartesian coordinate system.
37  The origin of the coordinate system is the centroid of the World
38  Geodetic System 1984 (WGS 84) reference frame.
39  Scale is 1 unit equals 1m.
40 
41  size: 192 bits / 24 octets
42 *********************************************************************/
43 
44 #pragma once
45 
46 #include "./DataTypeBase.h"
47 #include "./Vector.h"
48 
49 namespace KDIS {
50 namespace DATA_TYPE {
51 
53 {
54 protected:
55 
57 
59 
61 
62 public:
63 
64  static const KUINT16 WORLD_COORDINATES_SIZE = 24;
65 
67 
68  WorldCoordinates( KDataStream & stream ) throw( KException );
69 
71 
72  virtual ~WorldCoordinates();
73 
74  //************************************
75  // FullName: KDIS::DATA_TYPE::WorldCoordinates::SetX
76  // KDIS::DATA_TYPE::WorldCoordinates::GetX
77  //!Description: X
78  // Parameter: KFLOAT64 X
79  //************************************
80  void SetX( KFLOAT64 X );
81  KFLOAT64 GetX() const;
82 
83  //************************************
84  // FullName: KDIS::DATA_TYPE::WorldCoordinates::SetY
85  // KDIS::DATA_TYPE::WorldCoordinates::GetY
86  //!Description: Y
87  // Parameter: KFLOAT64 Y
88  //************************************
89  void SetY( KFLOAT64 Y );
90  KFLOAT64 GetY() const;
91 
92  //************************************
93  // FullName: KDIS::DATA_TYPE::WorldCoordinates::SetZ
94  // KDIS::DATA_TYPE::WorldCoordinates::GetZ
95  //!Description: Z
96  // Parameter: KFLOAT64 Z
97  //************************************
98  void SetZ( KFLOAT64 Z );
99  KFLOAT64 GetZ() const;
100 
101  //************************************
102  // FullName: KDIS::DATA_TYPE::WorldCoordinates::Set
103  //!Description: Sets x,y and z.
104  // Parameter: KFLOAT64 X
105  // Parameter: KFLOAT64 Y
106  // Parameter: KFLOAT64 Z
107  //************************************
108  void Set( KFLOAT64 X, KFLOAT64 Y, KFLOAT64 Z );
109 
110  //************************************
111  // FullName: KDIS::DATA_TYPE::WorldCoordinates::GetDistance
112  //!Description: Calculates the distance from this WorldCoordinates to an other.
113  //************************************
114  KFLOAT64 GetDistance( const WorldCoordinates & Other );
115 
116  //************************************
117  // FullName: KDIS::DATA_TYPE::WorldCoordinates::Lerp
118  //!Description: Linearly interpolate between From and To by T.
119  //! T should be between 0 and 1(its not checked).
120  //! T 0 = From
121  //! 1 = to
122  //! 0.5 = halfway between From and To.
123  // Parameter: const WorldCoordinates & From
124  // Parameter: const WorldCoordinates & To
125  // Parameter: KFLOAT32 T
126  //************************************
127  static WorldCoordinates Lerp( const WorldCoordinates & From, const WorldCoordinates & To, KFLOAT32 T );
128  void Lerp( const WorldCoordinates & To, KFLOAT32 T );
129 
130  //************************************
131  // FullName: KDIS::DATA_TYPE::WorldCoordinates::GetAsString
132  //!Description: Returns a string representation
133  //************************************
134  virtual KString GetAsString() const;
135 
136  //************************************
137  // FullName: KDIS::DATA_TYPE::WorldCoordinates::Decode
138  //!Description: Convert From Network Data.
139  // Parameter: KDataStream & stream
140  //************************************
141  virtual void Decode( KDataStream & stream ) throw( KException );
142 
143  //************************************
144  // FullName: KDIS::DATA_TYPE::WorldCoordinates::Encode
145  //!Description: Convert To Network Data.
146  // Parameter: KDataStream & stream
147  //************************************
148  virtual KDataStream Encode() const;
149  virtual void Encode( KDataStream & stream ) const;
150 
151  KBOOL operator == ( const WorldCoordinates & Value ) const;
152  KBOOL operator != ( const WorldCoordinates & Value ) const;
153  WorldCoordinates operator * ( const WorldCoordinates & Value ) const;
154  WorldCoordinates operator * ( KFLOAT64 Value ) const;
155  WorldCoordinates operator * ( KFLOAT32 Value ) const;
156  WorldCoordinates operator + ( const WorldCoordinates & Value ) const;
157  WorldCoordinates operator + ( const Vector & Value ) const;
158  WorldCoordinates & operator += ( const Vector & Value );
159  const WorldCoordinates & operator = ( const Vector & Value );
160  WorldCoordinates operator - ( const WorldCoordinates & Value ) const;
161  WorldCoordinates & operator -= ( const WorldCoordinates & Value );
162 
163  // Valid values 0 - X, 1 - Y, 2 - Z. throws OUT_OF_BOUNDS exception for any other value.
164  KFLOAT64 & operator[] ( KUINT16 i ) throw( KException );
165  const KFLOAT64 & operator[] ( KUINT16 i ) const throw( KException );
166 };
167 
168 } // END namespace DATA_TYPES
169 } // END namespace KDIS
170 
unsigned short int KUINT16
Definition: KDefines.h:101
float KFLOAT32
Definition: KDefines.h:113
Definition: Vector.h:71
Definition: KDefines.h:182
Definition: KDataStream.h:48
KFLOAT64 m_f64Z
Definition: WorldCoordinates.h:60
Definition: DataTypeBase.h:49
Definition: WorldCoordinates.h:52
bool KBOOL
Definition: KDefines.h:119
KFLOAT64 m_f64Y
Definition: WorldCoordinates.h:58
std::string KString
Definition: KDefines.h:116
KFLOAT64 m_f64X
Definition: WorldCoordinates.h:56
double KFLOAT64
Definition: KDefines.h:114
#define KDIS_EXPORT
Definition: KDefines.h:82