HoverRace  2.0
WorldCoordinates.h
Go to the documentation of this file.
1 // WorldCoordinates.h
2 //
3 //
4 // Copyright (c) 1995-1998 - Richard Langlois and Grokksoft Inc.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 //
22 
23 #ifndef WORLD_COORDINATES_H
24 #define WORLD_COORDINATES_H
25 
26 #include "MR_Types.h"
27 
28 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
29 # ifdef MR_ENGINE
30 # define MR_DllDeclare __declspec( dllexport )
31 # else
32 # define MR_DllDeclare __declspec( dllimport )
33 # endif
34 #else
35 # define MR_DllDeclare
36 #endif
37 
38 namespace HoverRace {
39  namespace Parcel {
40  class ObjStream;
41  }
42 }
43 
44 // All geometrical coordinates are in millimeters.
45 
47 {
48 public:
49  constexpr MR_2DCoordinate() noexcept : mX(0), mY(0) { }
50  constexpr MR_2DCoordinate(MR_Int32 pX, MR_Int32 pY) noexcept : mX(pX), mY(pY) { }
51 
52  void Serialize(HoverRace::Parcel::ObjStream &pArchive);
53 
54  // Comparison operators
55  constexpr bool operator==(const MR_2DCoordinate &pCoordinate) const noexcept
56  {
57  return (mX == pCoordinate.mX) && (mY == pCoordinate.mY);
58  }
59 
60  constexpr bool operator!=(const MR_2DCoordinate &pCoordinate) const noexcept
61  {
62  return (mX != pCoordinate.mX) || (mY != pCoordinate.mY);
63  }
64 
67 };
68 
69 inline std::ostream &operator<<(std::ostream &os, const MR_2DCoordinate &c)
70 {
71  os << '<' << c.mX << ", " << c.mY << '>';
72  return os;
73 }
74 
76 {
78 
79 public:
80  constexpr MR_3DCoordinate() noexcept : SUPER(0, 0), mZ(0) { }
81  constexpr MR_3DCoordinate(MR_Int32 pX, MR_Int32 pY, MR_Int32 pZ) noexcept :
82  SUPER(pX, pY), mZ(pZ) { }
83 
84  void Serialize(HoverRace::Parcel::ObjStream &pArchive);
85 
87 };
88 
89 inline std::ostream &operator<<(std::ostream &os, const MR_3DCoordinate &c)
90 {
91  os << '<' << c.mX << ", " << c.mY << ", " << c.mZ << '>';
92  return os;
93 }
94 
95 // Angles
97 
98 #define MR_PI 2048
99 #define MR_2PI 4096
100 
101 #define MR_NORMALIZE_ANGLE( pAngle ) ( (MR_Angle) (( 2*MR_2PI+(pAngle) )%MR_2PI) )
102 
103 #define RAD_2_MR_ANGLE( pAngle ) ((MR_Angle)( (static_cast<unsigned int>(pAngle*static_cast<double>(MR_2PI)*0.5/3.1415926536)+MR_2PI)%static_cast<unsigned int>(MR_2PI) ))
104 
105 // Temporal units
106 using MR_SimulationTime = MR_Int32; // In 1/1000th of seconds
107 // Do not stay in a maze for more than 49 days
108 // or the time will wrap-up
109 
110 // Sin and Cos tables
113 
114 #define MR_TRIGO_FRACT 16384 // unity of the trigo tables
115 #define MR_TRIGO_SHIFT 14
116 
117 // Function prototypes
119 
120 #undef MR_DllDeclare
121 #endif
Definition: WorldCoordinates.h:46
constexpr bool operator!=(const MR_2DCoordinate &pCoordinate) const noexcept
Definition: WorldCoordinates.h:60
Definition: WorldCoordinates.h:75
MR_DllDeclare MR_Int16 MR_Cos[MR_2PI]
Definition: WorldCoordinates.cpp:33
MR_Int16 MR_Angle
Definition: WorldCoordinates.h:96
#define MR_2PI
Definition: WorldCoordinates.h:99
constexpr MR_3DCoordinate(MR_Int32 pX, MR_Int32 pY, MR_Int32 pZ) noexcept
Definition: WorldCoordinates.h:81
MR_Int32 mZ
Definition: WorldCoordinates.h:86
MR_Int32 MR_SimulationTime
Definition: WorldCoordinates.h:106
constexpr MR_2DCoordinate(MR_Int32 pX, MR_Int32 pY) noexcept
Definition: WorldCoordinates.h:50
MR_Int32 mX
Definition: WorldCoordinates.h:65
Base class for parcel serializers.
Definition: ObjStream.h:58
int16_t MR_Int16
Definition: MR_Types.h:41
MR_Int32 mY
Definition: WorldCoordinates.h:66
MR_DllDeclare MR_Int16 MR_Sin[MR_2PI]
Definition: WorldCoordinates.cpp:32
int32_t MR_Int32
Definition: MR_Types.h:43
constexpr MR_3DCoordinate() noexcept
Definition: WorldCoordinates.h:80
constexpr MR_2DCoordinate() noexcept
Definition: WorldCoordinates.h:49
MR_DllDeclare void MR_InitTrigoTables()
Definition: WorldCoordinates.cpp:35
std::ostream & operator<<(std::ostream &os, const Vec2 &v)
Definition: Vec.h:48
Definition: Announcement.h:24
#define MR_DllDeclare
Definition: WorldCoordinates.h:35
constexpr bool operator==(const MR_2DCoordinate &pCoordinate) const noexcept
Definition: WorldCoordinates.h:55