Gazebo Math

API Reference

8.0.0
CoordinateVector3.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef GZ_MATH_COORDINATE_VECTOR3_HH_
18#define GZ_MATH_COORDINATE_VECTOR3_HH_
19
20#include <optional>
21#include <ostream>
22
23#include <gz/math/Angle.hh>
24#include <gz/math/Vector3.hh>
25#include <gz/math/Helpers.hh>
26#include <gz/math/config.hh>
27#include <gz/utils/ImplPtr.hh>
28
29namespace gz::math
30{
31 // Inline bracket to help doxygen filtering.
32 inline namespace GZ_MATH_VERSION_NAMESPACE {
33
38 {
41
43
47
49
55 public: static CoordinateVector3 Metric(double _x, double _y, double _z);
56
60 public: static CoordinateVector3 Metric(const math::Vector3d &_v);
61
68 const math::Angle &_lat, const math::Angle &_lon, double _z);
69
72 public: bool IsMetric() const;
73
76 public: bool IsSpherical() const;
77
82 public: void SetMetric(double _x, double _y, double _z);
83
86 public: void SetMetric(const math::Vector3d &_v);
87
92 public: void SetSpherical(
93 const math::Angle &_lat, const math::Angle &_lon, double _z);
94
97 public: std::optional<math::Vector3d> AsMetricVector() const;
98
103
108
115
122
126
133
140
147 public: bool Equal(const CoordinateVector3 &_v,
148 const double &_tol,
149 const math::Angle &_ang_tol) const;
150
155 public: bool operator==(const CoordinateVector3 &_v) const;
156
161 public: bool operator!=(const CoordinateVector3 &_v) const;
162
165 public: bool IsFinite() const;
166
171 public: bool Equal(const CoordinateVector3 &_v) const;
172
175 public: std::optional<double> X() const;
176
179 public: std::optional<math::Angle> Lat() const;
180
183 public: std::optional<double> Y() const;
184
187 public: std::optional<math::Angle> Lon() const;
188
191 public: std::optional<double> Z() const;
192
196 public: bool X(const double &_v);
197
201 public: bool Lat(const Angle &_v);
202
206 public: bool Y(const double &_v);
207
211 public: bool Lon(const Angle &_v);
212
216 public: bool Z(const double &_v);
217
222 public: friend std::ostream &operator<<(
224 {
225 if (_pt.IsMetric())
226 {
227 appendToStream(_out, *_pt.X());
228 }
229 else
230 {
231 appendToStream(_out, _pt.Lat()->Degree());
232 _out << "°";
233 }
234 _out << " ";
235
236 if (_pt.IsMetric())
237 {
238 appendToStream(_out, *_pt.Y());
239 }
240 else
241 {
242 appendToStream(_out, _pt.Lon()->Degree());
243 _out << "°";
244 }
245 _out << " ";
246
247 appendToStream(_out, *_pt.Z());
248
249 return _out;
250 }
251
253 };
254
255 } // namespace GZ_MATH_VERSION_NAMESPACE
256} // namespace gz::math
257#endif // GZ_MATH_COORDINATE_VECTOR3_HH_