summaryrefslogtreecommitdiff
path: root/include/d
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-12-27 21:39:17 +0100
committerGitHub <noreply@github.com>2025-12-27 21:39:17 +0100
commitdf5bd1a7b50bf21f2ea9bd250a4f64053c0ac431 (patch)
tree1253d62065caf98b9270b91bd227f6e6dcc02823 /include/d
parent3754ad2e08d4f962f3d5f2933097db9154f1a0bc (diff)
parentb524551c43301f5022a1f8e3a0a6b5e7f40cc346 (diff)
Merge pull request #291 from robojumper/vec-functions
Consolidate certain coordinate conversions
Diffstat (limited to 'include/d')
-rw-r--r--include/d/d_vec.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/d/d_vec.h b/include/d/d_vec.h
new file mode 100644
index 00000000..18fdd628
--- /dev/null
+++ b/include/d/d_vec.h
@@ -0,0 +1,29 @@
+#ifndef D_VEC_H
+#define D_VEC_H
+
+#include "m/m_angle.h"
+#include "m/m_vec.h"
+
+/**
+ * @brief Gets a point on a XZ circle.
+ *
+ * @param center the circle center. Will also hold the result.
+ * @param angle the Y angle.
+ * @param radius the circle radius.
+ */
+inline static void getXZCirclePoint(mVec3_c &center, const mAng &angle, f32 radius) {
+ center.x += radius * angle.sin();
+ center.z += radius * angle.cos();
+}
+
+/**
+ * @brief Converts a 2D vector to a 3D vector holding the original's vector coordinates in its XY components.
+ *
+ * @param v The 2D vector
+ * @return mVec3_c The 3D vector
+ */
+inline mVec3_c vec2ToVec3XY(const mVec2_c &v) {
+ return mVec3_c(v.x, v.y, 0.0f);
+}
+
+#endif