From 15186785eb6e903a75ac987d25a3315e73c246a0 Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 27 Aug 2024 14:50:54 +0300 Subject: [PATCH] fixed direction vectors --- include/omath/{matrix.h => Matrix.h} | 0 source/Vector3.cpp | 26 +++++--------------------- source/matrix.cpp | 3 ++- source/projection/Camera.cpp | 3 +++ 4 files changed, 10 insertions(+), 22 deletions(-) rename include/omath/{matrix.h => Matrix.h} (100%) diff --git a/include/omath/matrix.h b/include/omath/Matrix.h similarity index 100% rename from include/omath/matrix.h rename to include/omath/Matrix.h diff --git a/source/Vector3.cpp b/source/Vector3.cpp index 39d5757..40664cd 100644 --- a/source/Vector3.cpp +++ b/source/Vector3.cpp @@ -238,31 +238,15 @@ namespace omath const auto cosRoll = std::cos(angles::DegreesToRadians(roll)); const auto sinRoll = std::sin(angles::DegreesToRadians(roll)); - // Right vector calculation - return { - cosYaw * cosRoll - sinYaw * sinPitch * sinRoll, // X component - sinRoll * cosPitch, // Y component - sinYaw * cosRoll + cosYaw * sinPitch * sinRoll // Z component - }; + + return {-sinRoll*sinPitch*cosYaw + -cosRoll*-sinYaw, + -sinRoll*sinPitch*sinYaw + -cosRoll*cosYaw, + sinRoll*cosPitch}; } Vector3 Vector3::UpVector(float pitch, float yaw, float roll) { - const auto cosPitch = std::cos(angles::DegreesToRadians(pitch)); - const auto sinPitch = std::sin(angles::DegreesToRadians(pitch)); - - const auto cosYaw = std::cos(angles::DegreesToRadians(yaw)); - const auto sinYaw = std::sin(angles::DegreesToRadians(yaw)); - - const auto cosRoll = std::cos(angles::DegreesToRadians(roll)); - const auto sinRoll = std::sin(angles::DegreesToRadians(roll)); - - // Up vector calculation - return { - -sinRoll * cosYaw + cosRoll * sinPitch * sinYaw, // X component - cosRoll * cosPitch, // Y component - -sinRoll * sinYaw - cosRoll * sinPitch * cosYaw // Z component - }; + return RightVector(pitch, yaw, roll).Cross(ForwardVector(pitch, yaw)); } Vector3 Vector3::Cross(const Vector3 &v) const diff --git a/source/matrix.cpp b/source/matrix.cpp index 40d9a8f..7ef65e4 100644 --- a/source/matrix.cpp +++ b/source/matrix.cpp @@ -1,10 +1,11 @@ -#include "omath/matrix.h" +#include "omath/Matrix.h" #include #include "omath/Vector3.h" #include #include #include +#include namespace omath diff --git a/source/projection/Camera.cpp b/source/projection/Camera.cpp index dac1ffe..6a32d38 100644 --- a/source/projection/Camera.cpp +++ b/source/projection/Camera.cpp @@ -2,6 +2,9 @@ // Created by Vlad on 27.08.2024. // #include "omath/projection/Camera.h" + +#include + #include "omath/angles.h"