58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0.If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
|
|
|
|
#ifndef DIRECTION_H
|
|
#define DIRECTION_H
|
|
|
|
#include "Angle.h"
|
|
|
|
namespace Passer {
|
|
namespace LinearAlgebra {
|
|
|
|
struct Vector3;
|
|
|
|
template <typename T>
|
|
class DirectionOf {
|
|
public:
|
|
/// @brief horizontal angle, range= (-180..180]
|
|
AngleOf<T> horizontal;
|
|
/// @brief vertical angle, range in degrees = (-90..90]
|
|
AngleOf<T> vertical;
|
|
|
|
DirectionOf<T>();
|
|
DirectionOf<T>(AngleOf<T> horizontal, AngleOf<T> vertical);
|
|
// DirectionOf<T>(Vector3 v);
|
|
|
|
Vector3 ToVector3() const;
|
|
static DirectionOf<T> FromVector3(Vector3 v);
|
|
|
|
static DirectionOf<T> Degrees(float horizontal, float vertical);
|
|
static DirectionOf<T> Radians(float horizontal, float vertical);
|
|
|
|
const static DirectionOf forward;
|
|
const static DirectionOf back;
|
|
const static DirectionOf up;
|
|
const static DirectionOf down;
|
|
const static DirectionOf left;
|
|
const static DirectionOf right;
|
|
|
|
bool operator==(const DirectionOf<T> d) const;
|
|
|
|
DirectionOf<T> operator-() const;
|
|
|
|
Vector3 ToVector3();
|
|
|
|
protected:
|
|
void Normalize();
|
|
};
|
|
|
|
using DirectionSingle = DirectionOf<float>;
|
|
using Direction16 = DirectionOf<signed short>;
|
|
using Direction = DirectionOf<float>;
|
|
|
|
} // namespace LinearAlgebra
|
|
} // namespace Passer
|
|
using namespace Passer::LinearAlgebra;
|
|
|
|
#endif |