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 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

View File

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

View File

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