mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fixed direction vectors
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user