fixed direction vectors

This commit is contained in:
2024-08-27 14:50:54 +03:00
parent 13188615ed
commit 15186785eb
4 changed files with 10 additions and 22 deletions

View File

@@ -238,31 +238,15 @@ namespace omath
const auto cosRoll = std::cos(angles::DegreesToRadians(roll)); const auto cosRoll = std::cos(angles::DegreesToRadians(roll));
const auto sinRoll = std::sin(angles::DegreesToRadians(roll)); const auto sinRoll = std::sin(angles::DegreesToRadians(roll));
// Right vector calculation
return { return {-sinRoll*sinPitch*cosYaw + -cosRoll*-sinYaw,
cosYaw * cosRoll - sinYaw * sinPitch * sinRoll, // X component -sinRoll*sinPitch*sinYaw + -cosRoll*cosYaw,
sinRoll * cosPitch, // Y component sinRoll*cosPitch};
sinYaw * cosRoll + cosYaw * sinPitch * sinRoll // Z component
};
} }
Vector3 Vector3::UpVector(float pitch, float yaw, float roll) Vector3 Vector3::UpVector(float pitch, float yaw, float roll)
{ {
const auto cosPitch = std::cos(angles::DegreesToRadians(pitch)); return RightVector(pitch, yaw, roll).Cross(ForwardVector(pitch, yaw));
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
};
} }
Vector3 Vector3::Cross(const Vector3 &v) const Vector3 Vector3::Cross(const Vector3 &v) const

View File

@@ -1,10 +1,11 @@
#include "omath/matrix.h" #include "omath/Matrix.h"
#include <format> #include <format>
#include "omath/Vector3.h" #include "omath/Vector3.h"
#include <utility> #include <utility>
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include <cmath>
namespace omath namespace omath

View File

@@ -2,6 +2,9 @@
// Created by Vlad on 27.08.2024. // Created by Vlad on 27.08.2024.
// //
#include "omath/projection/Camera.h" #include "omath/projection/Camera.h"
#include <complex>
#include "omath/angles.h" #include "omath/angles.h"