VR-Engage  2.2
Loading...
Searching...
No Matches
vortexUtil.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vortexUtil.h
7//! \brief Utility functions for coordinate conversion and geometry operations with Vortex
8//! \ingroup vreVrfVortex
9
10#pragma once
11
12#include <vreVrfVortex/export.h>
13
14#include <VxMath/VxMath.h>
15#include <geometry/point.h>
16#include <matrix/vlVector.h>
17#include <geometry/extent.h>
18
19class DtLocalObject;
20
21namespace makVre
22{
23//! \brief Converts a vector from Vortex (NWU) coordinates to flat earth coordinates
24//!
25//! \param input The input vector in Vortex coordinates
26//! \param output The output vector in flat earth coordinates
27void VREVRFVORTEX_DLL ConvertVortexToFlatEarth(const DtVector& input, DtVector& output);
28
29//! \brief Converts a vector from Vortex (NWU) coordinates to DIS body coordinates (NED)
30//!
31//! \param input The input vector in Vortex coordinates
32//! \param output The output vector in DIS body coordinates
33void VREVRFVORTEX_DLL ConvertVortexToDISBody(const DtVector& input, DtVector& output);
34
35//! \brief Converts a vector from flat earth coordinates to Vortex (NWU) coordinates
36//!
37//! \param input The input vector in flat earth coordinates
38//! \param output The output vector in Vortex coordinates
39void VREVRFVORTEX_DLL ConvertFlatEarthToVortex(const DtVector& input, DtVector& output);
40
41//! \brief Converts a vector from DIS body coordinates (NED) to Vortex (NWU) coordinates
42//!
43//! \param input The input vector in DIS body coordinates
44//! \param output The output vector in Vortex coordinates
45void VREVRFVORTEX_DLL ConvertDISBodyToVortex(const DtVector& input, DtVector& output);
46
47//! \brief Converts a Vortex Vector3 to a DtVector
48//!
49//! \param input The input Vortex Vector3
50//! \param output The output DtVector
51void VREVRFVORTEX_DLL ConvertVxVector3ToDtVector(const VxMath::Vector3& input, DtVector& output);
52
53//! \brief Converts a DtVector to a Vortex Vector3
54//!
55//! \param input The input DtVector
56//! \param output The output Vortex Vector3
57void VREVRFVORTEX_DLL ConvertDtVectorToVxVector3(const DtVector& input, VxMath::Vector3& output);
58
59//! \brief Checks if one bounding box fully includes another
60//!
61//! Does not check the Z dimension, only X and Y.
62//!
63//! \param bbOne The first bounding box
64//! \param bbTwo The second bounding box to check if it's included
65//! \return True if bbOne fully includes bbTwo in X and Y dimensions
66bool VREVRFVORTEX_DLL doesBoundingBoxInclude(const VxMath::BoundingBox& bbOne, VxMath::BoundingBox& bbTwo);
67
68//! \brief Checks if a bounding box contains a DtVector point
69//!
70//! \param bb The bounding box
71//! \param vec The vector to check
72//! \return True if the point is inside the bounding box
73bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const DtVector& vec);
74
75//! \brief Checks if a bounding box contains a DtPoint
76//!
77//! \param bb The bounding box
78//! \param vec The point to check
79//! \return True if the point is inside the bounding box
80bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const DtPoint& vec);
81
82//! \brief Checks if a bounding box contains a Vortex Vector3 point
83//!
84//! \param bb The bounding box
85//! \param vec The vector to check
86//! \return True if the point is inside the bounding box
87bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox& bb, const VxMath::Vector3& vec);
88
89//! \brief Checks if an extent contains a DtVector point
90//!
91//! \param ext The extent
92//! \param vec The vector to check
93//! \return True if the point is inside the extent
94bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const DtVector& vec);
95
96//! \brief Checks if an extent contains a DtPoint
97//!
98//! \param ext The extent
99//! \param vec The point to check
100//! \return True if the point is inside the extent
101bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const DtPoint& vec);
102
103//! \brief Checks if an extent contains a Vortex Vector3 point
104//!
105//! \param ext The extent
106//! \param vec The vector to check
107//! \return True if the point is inside the extent
108bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent& ext, const VxMath::Vector3& vec);
109
110//! \brief Creates a DtVector from a Vortex Vector3
111//!
112//! \param input The input Vortex Vector3
113//! \return A new DtVector with the same values
114DtVector getDtVector(const VxMath::Vector3& input);
115
116//! \brief Creates a Vortex Vector3 from a DtVector
117//!
118//! \param input The input DtVector
119//! \return A new Vortex Vector3 with the same values
120VxMath::Vector3 getVxVector(const DtVector& input);
121
122//! \brief Returns whether or not a local object is a valid vortex entity.
123//! \param obj The Local object
124//! \return True if the local object is vortex
125bool isValidVortexLocalObject(DtLocalObject* obj);
126}
127
128//! \brief Coercion macros for efficient memory access without copying
129//!
130//! Since both VxVector and DtVector/DtPoint are simply 3 doubles in memory,
131//! we can coerce one to be the other by doing pointer casting and dereferencing
132//! which avoids making any copies.
133
134//! \brief Converts a Vortex vector to a DtVector without copying memory
135#define CoerceToDtVector(x) *((DtVector*)(&x[0]))
136
137//! \brief Converts a DtVector to a Vx::VxReal3 without copying memory
138#define CoerceToVxReal3(x) *((Vx::VxReal3*)(&x[0]))
139
140//! \brief Converts a DtVector to a VxMath::Vector3 without copying memory
141#define CoerceToVxVector(x) *((VxMath::Vector3*)(&x[0]))
142
143//! \brief Formats a vector for printing with fixed precision
144#define printVec(vec) std::fixed << std::setprecision(8) << "{" << vec[0] << ", " << vec[1] << ", " << vec[2] << "}"
145
146//! \brief Formats a transform matrix for printing with fixed precision
147#define printTransform(tm) \
148 std::fixed << std::setprecision(8) << "[" << tm[0][0] << ", " << tm[0][1] << ", " << tm[0][2] << ", " << tm[0][3] \
149 << "]" << std::endl \
150 << "[" << tm[1][0] << ", " << tm[1][1] << ", " << tm[1][2] << ", " << tm[1][3] << "]" << std::endl \
151 << "[" << tm[2][0] << ", " << tm[2][1] << ", " << tm[2][2] << ", " << tm[2][3] << "]" << std::endl \
152 << "[" << tm[3][0] << ", " << tm[3][1] << ", " << tm[3][2] << ", " << tm[3][3] << "]"
153
154//! \brief Formats a matrix for printing with fixed precision
155#define printMatrix(tm) \
156 std::fixed << std::setprecision(8) << "[" << tm(0, 0) << ", " << tm(0, 1) << ", " << tm(0, 2) << ", " << tm(0, 3) \
157 << "]" << std::endl \
158 << "[" << tm(1, 0) << ", " << tm(1, 1) << ", " << tm(1, 2) << ", " << tm(1, 3) << "]" << std::endl \
159 << "[" << tm(2, 0) << ", " << tm(2, 1) << ", " << tm(2, 2) << ", " << tm(2, 3) << "]" << std::endl \
160 << "[" << tm(3, 0) << ", " << tm(3, 1) << ", " << tm(3, 2) << ", " << tm(3, 3) << "]"
161
162//! \brief Profiler macros for performance monitoring with color-coding
163//! @{
164
165//! \brief Defines a profiler zone with a specific color
166#define PROFILER_ZONE_COLOR(color) ZoneNamedC(___tracy_scoped_zone, color, makVrf::DtProfiler::collectTracyStats());
167
168//! \brief Defines a profiler section with text and color
169#define PROFILER_SECTION_COLOR(text, color) \
170 { \
171 ZoneNamedNC(___tracy_scoped_zone, text, color, makVrf::DtProfiler::collectTracyStats());
172
173//! \brief Application profiling color (Dark Green)
174#define APPLICATION_COLOR_PROFILE 0x006400
175
176//! \brief Application profiling zone
177#define PROFILE_VX_APPLICATION_ZONE PROFILER_ZONE_COLOR(APPLICATION_COLOR_PROFILE);
178
179//! \brief Application profiling section with text
180#define PROFILE_VX_APPLICATION_SECTION(text) PROFILER_SECTION_COLOR(text, APPLICATION_COLOR_PROFILE);
181
182//! \brief End of application profiling section
183#define PROFILE_VX_APPLICATION_SECTION_END DtPROFILE_SECTION_END
184
185//! \brief Terrain profiling color (DodgerBlue3)
186#define TERRAIN_COLOR_PROFILE tracy::Color::DodgerBlue3
187
188//! \brief Terrain profiling zone
189#define PROFILE_VX_TERRAIN_ZONE PROFILER_ZONE_COLOR(TERRAIN_COLOR_PROFILE);
190
191//! \brief Terrain profiling section with text
192#define PROFILE_VX_TERRAIN_SECTION(text) PROFILER_SECTION_COLOR(text, TERRAIN_COLOR_PROFILE);
193
194//! \brief End of terrain profiling section
195#define PROFILE_VX_TERRAIN_SECTION_END DtPROFILE_SECTION_END
196
197//! \brief Dynamic terrain profiling color (LightSalmon4)
198#define DYNAMIC_TERRAIN_COLOR_PROFILE tracy::Color::LightSalmon4
199
200//! \brief Dynamic terrain profiling zone
201#define PROFILE_VX_DYNAMIC_TERRAIN_ZONE PROFILER_ZONE_COLOR(DYNAMIC_TERRAIN_COLOR_PROFILE);
202
203//! \brief Dynamic terrain profiling section with text
204#define PROFILE_VX_DYNAMIC_TERRAIN_SECTION(text) PROFILER_SECTION_COLOR(text, DYNAMIC_TERRAIN_COLOR_PROFILE);
205
206//! \brief End of dynamic terrain profiling section
207#define PROFILE_VX_DYNAMIC_TERRAIN_SECTION_END DtPROFILE_SECTION_END
208
209//! \brief Actuator profiling color (DarkOliveGreen3)
210#define ACTUATOR_COLOR_PROFILE tracy::Color::DarkOliveGreen3
211
212//! \brief Actuator profiling zone
213#define PROFILE_VX_ACTUATOR_ZONE PROFILER_ZONE_COLOR(ACTUATOR_COLOR_PROFILE);
214
215//! \brief Actuator profiling section with text
216#define PROFILE_VX_ACTUATOR_SECTION(text) PROFILER_SECTION_COLOR(text, ACTUATOR_COLOR_PROFILE);
217
218//! \brief End of actuator profiling section
219#define PROFILE_VX_ACTUATOR_SECTION_END DtPROFILE_SECTION_END
220//! @}
Export macros for the VR-Forces Vortex extension library.
#define VREVRFVORTEX_DLL
Export macro for non-Windows platforms.
Definition export.h:30
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
void VREVRFVORTEX_DLL ConvertFlatEarthToVortex(const DtVector &input, DtVector &output)
Converts a vector from flat earth coordinates to Vortex (NWU) coordinates.
DtVector getDtVector(const VxMath::Vector3 &input)
Creates a DtVector from a Vortex Vector3.
VxMath::Vector3 getVxVector(const DtVector &input)
Creates a Vortex Vector3 from a DtVector.
void VREVRFVORTEX_DLL ConvertDISBodyToVortex(const DtVector &input, DtVector &output)
Converts a vector from DIS body coordinates (NED) to Vortex (NWU) coordinates.
bool VREVRFVORTEX_DLL doesExtentContainPoint(const DtExtent &ext, const DtVector &vec)
Checks if an extent contains a DtVector point.
void VREVRFVORTEX_DLL ConvertVortexToDISBody(const DtVector &input, DtVector &output)
Converts a vector from Vortex (NWU) coordinates to DIS body coordinates (NED)
void VREVRFVORTEX_DLL ConvertVxVector3ToDtVector(const VxMath::Vector3 &input, DtVector &output)
Converts a Vortex Vector3 to a DtVector.
void VREVRFVORTEX_DLL ConvertDtVectorToVxVector3(const DtVector &input, VxMath::Vector3 &output)
Converts a DtVector to a Vortex Vector3.
bool VREVRFVORTEX_DLL doesBoundingBoxContainPoint(const VxMath::BoundingBox &bb, const DtVector &vec)
Checks if a bounding box contains a DtVector point.
bool isValidVortexLocalObject(DtLocalObject *obj)
Returns whether or not a local object is a valid vortex entity.
void VREVRFVORTEX_DLL ConvertVortexToFlatEarth(const DtVector &input, DtVector &output)
Converts a vector from Vortex (NWU) coordinates to flat earth coordinates.
bool VREVRFVORTEX_DLL doesBoundingBoxInclude(const VxMath::BoundingBox &bbOne, VxMath::BoundingBox &bbTwo)
Checks if one bounding box fully includes another.