RoboidControl
Loading...
Searching...
No Matches
Spherical.h
Go to the documentation of this file.
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 SPHERICAL_H
6#define SPHERICAL_H
7
8#include "Angle.h"
9#include "Polar.h"
10
11namespace Passer {
12namespace LinearAlgebra {
13
14struct Vector3;
15
21struct Spherical {
22public:
25 float distance;
32
34 Spherical();
48
50 const static Spherical zero;
52 const static Spherical forward;
54 const static Spherical back;
56 const static Spherical right;
58 const static Spherical left;
60 const static Spherical up;
62 const static Spherical down;
63
69 bool operator==(const Spherical &v) const;
70
74 inline static float Magnitude(const Spherical &v) { return v.distance; }
77 inline float magnitude() const { return this->distance; }
78
82 static Spherical Normalize(const Spherical &v);
85 Spherical normalized() const;
86
91 Spherical operator-() const;
92
98 friend Spherical operator*(const Spherical &v, float f);
99 friend Spherical operator*(float f, const Spherical &v);
100 Spherical operator*=(float f);
106 friend Spherical operator/(const Spherical &v, float f);
107 friend Spherical operator/(float f, const Spherical &v);
108 Spherical operator/=(float f);
109
116 // static float Distance(const Spherical &s1, const Spherical &s2);
117
120 static Spherical RotateHorizontal(const Spherical &v, Angle angle);
121 static Spherical RotateVertical(const Spherical &v, Angle angle);
122};
123
124} // namespace LinearAlgebra
125} // namespace Passer
126using namespace Passer::LinearAlgebra;
127
128#include "Vector3.h"
129
130#endif
Definition Angle.h:9
Definition AbsoluteEncoder.h:5
A polar vector.
Definition Polar.h:19
A spherical vector.
Definition Spherical.h:21
static const Spherical left
A normalized left-oriented vector.
Definition Spherical.h:58
static const Spherical up
A normalized up-oriented vector.
Definition Spherical.h:60
static float Magnitude(const Spherical &v)
The vector length.
Definition Spherical.h:74
static Spherical Normalize(const Spherical &v)
Convert the vector to a length of 1.
Definition Spherical.cpp:59
static const Spherical down
A normalized down-oriented vector.
Definition Spherical.h:62
friend Spherical operator*(const Spherical &v, float f)
Scale the vector uniformly up.
Angle horizontalAngle
The angle in the horizontal plane in degrees, clockwise rotation.
Definition Spherical.h:28
static Spherical Rotate(const Spherical &v, Angle horizontalAngle, Angle verticalAngle)
The distance between two vectors.
Definition Spherical.cpp:106
static const Spherical forward
A normalized forward-oriented vector.
Definition Spherical.h:52
static Spherical RotateVertical(const Spherical &v, Angle angle)
Definition Spherical.cpp:116
static const Spherical right
A normalized right-oriented vector.
Definition Spherical.h:56
friend Spherical operator/(float f, const Spherical &v)
float magnitude() const
The vector length.
Definition Spherical.h:77
static const Spherical zero
A spherical vector with zero degree angles and distance.
Definition Spherical.h:50
static Spherical RotateHorizontal(const Spherical &v, Angle angle)
Definition Spherical.cpp:112
Spherical normalized() const
Convert the vector to a length of a.
Definition Spherical.cpp:63
Spherical operator-() const
Negate the vector.
Definition Spherical.cpp:68
static const Spherical back
A normalized back-oriented vector.
Definition Spherical.h:54
friend Spherical operator*(float f, const Spherical &v)
Spherical operator/=(float f)
Definition Spherical.cpp:90
float distance
The distance in meters.
Definition Spherical.h:25
Angle verticalAngle
The angle in the vertical plane in degrees. Positive is upward.
Definition Spherical.h:31
friend Spherical operator/(const Spherical &v, float f)
Scale the vector uniformly down.
Spherical operator*=(float f)
Definition Spherical.cpp:80
Spherical()
Create a new spherical vector with zero degrees and distance.
Definition Spherical.cpp:8
bool operator==(const Spherical &v) const
Equality test to another vector.
Definition Spherical.cpp:53
A 3-dimensional vector.
Definition Vector3.h:42