LinearAlgebra
Loading...
Searching...
No Matches
Direction.h
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0.If a copy of the MPL was not distributed with this
3// file, You can obtain one at https ://mozilla.org/MPL/2.0/.
4
5#ifndef DIRECTION_H
6#define DIRECTION_H
7
8#include "Angle.h"
9
10namespace Passer {
11namespace LinearAlgebra {
12
13struct Vector3;
14
25template <typename T> class DirectionOf {
26public:
31
38
41 Vector3 ToVector3() const;
48
53 static DirectionOf<T> Degrees(float horizontal, float vertical);
58 static DirectionOf<T> Radians(float horizontal, float vertical);
59
61 const static DirectionOf forward;
64 const static DirectionOf back;
66 const static DirectionOf up;
69 const static DirectionOf down;
72 const static DirectionOf left;
75 const static DirectionOf right;
76
80 bool operator==(const DirectionOf<T> direction) const;
81
85
86protected:
88 void Normalize();
89};
90
93
94} // namespace LinearAlgebra
95} // namespace Passer
96using namespace Passer::LinearAlgebra;
97
98#endif
An angle in various representations.
Definition Angle.h:21
A direction using angles in various representations.
Definition Direction.h:25
static const DirectionOf back
A backward direction with horizontal angle -180 and zero vertical angle.
Definition Direction.h:64
static const DirectionOf left
A left-pointing direction with horizontal angle -90 and zero vertical angle.
Definition Direction.h:72
DirectionOf< T > operator-() const
Negate/reverse the direction.
Definition Direction.cpp:88
static const DirectionOf down
A downward direction with zero horizontal angle and vertical angle -90.
Definition Direction.h:69
AngleOf< T > vertical
vertical angle, range in degrees = (-90..90]
Definition Direction.h:30
static const DirectionOf up
A upward direction with zero horizontal angle and vertical angle 90.
Definition Direction.h:66
Vector3 ToVector3() const
Convert the direction into a carthesian vector.
Definition Direction.cpp:44
bool operator==(const DirectionOf< T > direction) const
Test whether this direction is equal to another direction.
Definition Direction.cpp:81
static DirectionOf< T > Degrees(float horizontal, float vertical)
Create a direction using angle values in degrees.
Definition Direction.cpp:67
void Normalize()
Normalize this vector to the specified ranges.
Definition Direction.cpp:94
static const DirectionOf forward
A forward direction with zero for both angles.
Definition Direction.h:61
static DirectionOf< T > Radians(float horizontal, float vertical)
Create a direction using angle values in radians.
Definition Direction.cpp:74
static const DirectionOf right
A right-pointing direction with horizontal angle 90 and zero vertical angle.
Definition Direction.h:75
AngleOf< T > horizontal
horizontal angle, range= (-180..180]
Definition Direction.h:28
static DirectionOf< T > FromVector3(Vector3 vector)
Convert a carthesian vector into a direction.
Definition Direction.cpp:53
A 3-dimensional vector.
Definition Vector3.h:42