CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
geom
geom/Location.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
carla/geom/RightHandedVector3D.h
"
10
#include "
carla/geom/Vector3D.h
"
11
#include "
carla/geom/Vector3DInt.h
"
12
#include "
carla/geom/Math.h
"
13
14
#ifdef LIBCARLA_INCLUDED_FROM_UE4
15
#include <
util/enable-ue4-macros.h
>
16
#include "Math/Vector.h"
17
#include <
util/disable-ue4-macros.h
>
18
#endif
// LIBCARLA_INCLUDED_FROM_UE4
19
20
namespace
carla
{
21
namespace
geom
{
22
23
struct
Location
:
Vector3D
{
24
25
// =========================================================================
26
// -- Constructors ---------------------------------------------------------
27
// =========================================================================
28
29
Location
() =
default
;
30
31
using
Vector3D::Vector3D
;
32
33
Location
(
Vector3D
rhs) :
Vector3D
(rhs) {}
34
35
constexpr
Location
(
Vector3DInt
rhs) :
36
Vector3D
(static_cast<float>(rhs.
x
),
37
static_cast<float>(rhs.
y
),
38
static_cast<float>(rhs.
z
)) {
39
}
40
41
// =========================================================================
42
// -- Other methods --------------------------------------------------------
43
// =========================================================================
44
45
constexpr
auto
DistanceSquared
(
Location
loc)
const
{
46
return
Math::DistanceSquared
(*
this
, loc);
47
}
48
49
inline
auto
Distance
(
Location
loc)
const
{
50
return
Math::Distance
(*
this
, loc);
51
}
52
53
// =========================================================================
54
// -- Right-handed (ROS / FLU) boundary ------------------------------------
55
// =========================================================================
56
57
/// This location expressed in a right-handed, x-forward / y-**left** /
58
/// z-up frame (ROS REP-103 "FLU"): `(x, -y, z)`.
59
constexpr
RightHandedVector3D
ToRightHanded
()
const
{
60
return
RightHandedVector3D
(*
this
);
61
}
62
63
/// Inverse of `ToRightHanded()`. Mirroring Y is an involution, so this is
64
/// the same `(x, -y, z)` map read the other way.
65
static
constexpr
Location
FromRightHanded
(
const
RightHandedVector3D
&rhs) {
66
return
Location
(rhs.
x
, -rhs.
y
, rhs.
z
);
67
}
68
69
// =========================================================================
70
// -- Arithmetic operators -------------------------------------------------
71
// =========================================================================
72
73
constexpr
Location
&
operator+=
(
Location
rhs) {
74
static_cast<
Vector3D
&
>
(*this) += rhs;
75
return
*
this
;
76
}
77
78
constexpr
friend
Location
operator+
(
Location
lhs,
Location
rhs) {
79
lhs += rhs;
80
return
lhs;
81
}
82
83
constexpr
Location
&
operator-=
(
Location
rhs) {
84
static_cast<
Vector3D
&
>
(*this) -= rhs;
85
return
*
this
;
86
}
87
88
constexpr
friend
Location
operator-
(
Location
lhs,
Location
rhs) {
89
lhs -= rhs;
90
return
lhs;
91
}
92
93
// =========================================================================
94
// -- Conversions to UE4 types ---------------------------------------------
95
// =========================================================================
96
97
#ifdef LIBCARLA_INCLUDED_FROM_UE4
98
99
Location
(
const
FVector &vector)
// from centimeters to meters.
100
:
Location
(1e-2f * vector.X, 1e-2f * vector.Y, 1e-2f * vector.Z) {}
101
102
operator
FVector()
const
{
103
return
FVector{1e2f *
x
, 1e2f *
y
, 1e2f *
z
};
// from meters to centimeters.
104
}
105
106
#endif
// LIBCARLA_INCLUDED_FROM_UE4
107
};
108
109
// =========================================================================
110
// -- Comparison operators -------------------------------------------------
111
// =========================================================================
112
113
constexpr
bool
operator==
(
Location
lhs,
Location
rhs) {
114
return
static_cast<
Vector3D
>
(lhs) ==
static_cast<
Vector3D
>
(rhs);
115
}
116
117
constexpr
bool
operator!=
(
Location
lhs,
Location
rhs) {
118
return
!(lhs == rhs);
119
}
120
121
}
// namespace geom
122
}
// namespace carla
Math.h
RightHandedVector3D.h
Vector3DInt.h
carla::geom::Math::DistanceSquared
static constexpr auto DistanceSquared(const Vector3D &a, const Vector3D &b)
Definition
Math.h:70
carla::geom::Math::Distance
static auto Distance(const Vector3D &a, const Vector3D &b)
Definition
Math.h:78
carla::geom::Vector3DInt
Definition
Vector3DInt.h:17
disable-ue4-macros.h
enable-ue4-macros.h
Vector3D.h
carla::geom
Definition
Misc.h:24
carla::geom::operator!=
constexpr bool operator!=(Location lhs, Location rhs)
Definition
geom/Location.h:117
carla::geom::operator==
constexpr bool operator==(Location lhs, Location rhs)
Definition
geom/Location.h:113
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::geom::Location
Definition
geom/Location.h:23
carla::geom::Location::operator+=
constexpr Location & operator+=(Location rhs)
Definition
geom/Location.h:73
carla::geom::Location::ToRightHanded
constexpr RightHandedVector3D ToRightHanded() const
This location expressed in a right-handed, x-forward / y-**left** / z-up frame (ROS REP-103 "FLU"): (...
Definition
geom/Location.h:59
carla::geom::Location::Location
Location(Vector3D rhs)
Definition
geom/Location.h:33
carla::geom::Location::operator-
constexpr friend Location operator-(Location lhs, Location rhs)
Definition
geom/Location.h:88
carla::geom::Location::operator+
constexpr friend Location operator+(Location lhs, Location rhs)
Definition
geom/Location.h:78
carla::geom::Location::operator-=
constexpr Location & operator-=(Location rhs)
Definition
geom/Location.h:83
carla::geom::Location::DistanceSquared
constexpr auto DistanceSquared(Location loc) const
Definition
geom/Location.h:45
carla::geom::Location::Distance
auto Distance(Location loc) const
Definition
geom/Location.h:49
carla::geom::Location::Location
Location()=default
carla::geom::Location::Location
constexpr Location(Vector3DInt rhs)
Definition
geom/Location.h:35
carla::geom::Location::Location
Location(const FVector &vector)
Definition
geom/Location.h:99
carla::geom::Location::FromRightHanded
static constexpr Location FromRightHanded(const RightHandedVector3D &rhs)
Inverse of ToRightHanded().
Definition
geom/Location.h:65
carla::geom::Location::Vector3D
Vector3D()=default
carla::geom::RightHandedVector3D
Internal adapter that holds a Vector3D in a right-handed coordinate frame.
Definition
RightHandedVector3D.h:19
carla::geom::RightHandedVector3D::y
float y
Definition
RightHandedVector3D.h:22
carla::geom::RightHandedVector3D::x
float x
Definition
RightHandedVector3D.h:21
carla::geom::RightHandedVector3D::RightHandedVector3D
RightHandedVector3D()=default
carla::geom::RightHandedVector3D::z
float z
Definition
RightHandedVector3D.h:23
carla::geom::Vector3D
Definition
geom/Vector3D.h:17
carla::geom::Vector3D::y
float y
Definition
geom/Vector3D.h:27
carla::geom::Vector3D::x
float x
Definition
geom/Vector3D.h:25
carla::geom::Vector3D::z
float z
Definition
geom/Vector3D.h:29
carla::geom::Vector3D::Vector3D
Vector3D()=default
Generated by
1.18.0