mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
initial commit
This commit is contained in:
36
include/uml/ProjectilePredictor.h
Normal file
36
include/uml/ProjectilePredictor.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by vlad on 11/6/23.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <optional>
|
||||
|
||||
namespace uml
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace uml::prediction
|
||||
{
|
||||
class ProjectilePredictor
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static std::optional<Vector3> CalculateViewAngles(const Vector3& origin,
|
||||
const Vector3& target,
|
||||
const Vector3& targetVelocity,
|
||||
float gravity,
|
||||
float bulletSpeed,
|
||||
float bulletGravity,
|
||||
bool inAir);
|
||||
|
||||
private:
|
||||
[[nodiscard]]
|
||||
static std::optional<float> CalculateAimPitch(const Vector3& origin,
|
||||
const Vector3& target,
|
||||
float bulletSpeed,
|
||||
float bulletGravity);
|
||||
[[nodiscard]] static float ProjectileTravelTime(float distance, float angle, float speed);
|
||||
};
|
||||
|
||||
};
|
||||
55
include/uml/Vector3.h
Normal file
55
include/uml/Vector3.h
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Created by vlad on 10/28/23.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace uml
|
||||
{
|
||||
class Vector3 final
|
||||
{
|
||||
public:
|
||||
float x = 0.f;
|
||||
float y = 0.f;
|
||||
float z = 0.f;
|
||||
Vector3(const float x, const float y, const float z)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
}
|
||||
Vector3() = default;
|
||||
|
||||
bool operator==(const Vector3& src) const;
|
||||
bool operator!=(const Vector3& src) const;
|
||||
|
||||
Vector3& operator+=(const Vector3& v);
|
||||
Vector3& operator-=(const Vector3& v);
|
||||
Vector3& operator*=(float fl);
|
||||
Vector3& operator*=(const Vector3& v);
|
||||
Vector3& operator/=(const Vector3& v);
|
||||
Vector3& operator+=(float fl);
|
||||
Vector3& operator/=(float fl);
|
||||
Vector3& operator-=(float fl);
|
||||
|
||||
[[nodiscard]] float DistTo(const Vector3& vOther) const;
|
||||
Vector3& Abs();
|
||||
[[nodiscard]] float DistToSqr(const Vector3& vOther) const;
|
||||
[[nodiscard]] float Dot(const Vector3& vOther) const;
|
||||
[[nodiscard]] float Length() const;
|
||||
[[nodiscard]] float LengthSqr() const;
|
||||
[[nodiscard]] float Length2D() const;
|
||||
|
||||
Vector3 operator-() const;
|
||||
Vector3 operator+(const Vector3& v) const;
|
||||
Vector3 operator-(const Vector3& v) const;
|
||||
Vector3 operator*(float fl) const;
|
||||
Vector3 operator*(const Vector3& v) const;
|
||||
Vector3 operator/(float fl) const;
|
||||
Vector3 operator/(const Vector3& v) const;
|
||||
[[nodiscard]] Vector3 Transform(const Vector3& angles, float length) const;
|
||||
[[nodiscard]] float Sum() const;
|
||||
[[nodiscard]] float Sum2D() const;
|
||||
[[nodiscard]] Vector3 ViewAngleTo(const Vector3& other) const;
|
||||
};
|
||||
}
|
||||
11
include/uml/angles.h
Normal file
11
include/uml/angles.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by vlad on 11/6/23.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace uml::angles
|
||||
{
|
||||
[[nodiscard]] float RadToDeg(float rads);
|
||||
[[nodiscard]] float DegToRad(float degrees);
|
||||
}
|
||||
73
include/uml/matrix.h
Normal file
73
include/uml/matrix.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace uml
|
||||
{
|
||||
class Vector3;
|
||||
|
||||
class matrix
|
||||
{
|
||||
public:
|
||||
matrix(size_t rows, size_t columns);
|
||||
|
||||
explicit matrix(const std::vector<std::vector<float>> &rows);
|
||||
|
||||
[[nodiscard]] static matrix to_screen_matrix(float screenWidth, float screenHeight);
|
||||
|
||||
matrix(const matrix &other);
|
||||
|
||||
matrix(size_t rows, size_t columns, float *pRaw);
|
||||
|
||||
matrix(matrix &&other) noexcept;
|
||||
|
||||
[[nodiscard]] size_t get_rows_count() const noexcept;
|
||||
|
||||
[[nodiscard]] size_t get_columns_count() const noexcept;
|
||||
|
||||
[[nodiscard]] std::pair<size_t, size_t> get_size() const noexcept;
|
||||
|
||||
float &at(size_t iRow, size_t iCol);
|
||||
|
||||
float get_sum();
|
||||
|
||||
matrix transpose();
|
||||
|
||||
void set(float val);
|
||||
|
||||
[[nodiscard]] const float &at(size_t iRow, size_t iCol) const;
|
||||
|
||||
matrix operator*(const matrix &other) const;
|
||||
|
||||
matrix operator*(float f) const;
|
||||
|
||||
matrix operator*(const Vector3 &vec3) const;
|
||||
|
||||
matrix &operator*=(float f);
|
||||
|
||||
matrix &operator/=(float f);
|
||||
|
||||
void clear();
|
||||
|
||||
[[nodiscard]] matrix strip(size_t row, size_t column) const;
|
||||
|
||||
[[nodiscard]] float minor(size_t i, size_t j) const;
|
||||
|
||||
[[nodiscard]] float alg_complement(size_t i, size_t j) const;
|
||||
|
||||
[[nodiscard]] float det() const;
|
||||
|
||||
matrix &operator=(const matrix &other);
|
||||
|
||||
matrix &operator=(matrix &&other) noexcept;
|
||||
|
||||
matrix operator/(float f) const;
|
||||
|
||||
~matrix();
|
||||
|
||||
private:
|
||||
size_t m_rows = 0;
|
||||
size_t m_columns = 0;
|
||||
std::unique_ptr<float[]> m_pData = nullptr;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user