CARLA
Loading...
Searching...
No Matches
Velocity.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
10
11namespace carla {
12namespace geom {
13
14 /// Linear velocity in metres per second. Inherits the storage and arithmetic
15 /// of `Vector3D` while carrying unit semantics so consumers do not
16 /// accidentally mix `cm/s` and `m/s` payloads at API boundaries.
17 struct Velocity : Vector3D {
18
19 Velocity() = default;
20
21 constexpr Velocity(float ix, float iy, float iz)
22 : Vector3D(ix, iy, iz) {
23 }
24
25 explicit constexpr Velocity(const Vector3D &v)
26 : Vector3D(v) {
27 }
28
29#ifdef LIBCARLA_INCLUDED_FROM_UE4
30
31 /// Build a `Velocity` (m/s) from an Unreal `FVector` expressed in
32 /// centimetres per second.
33 explicit Velocity(const FVector &v_cm_per_s)
34 : Vector3D(
35 static_cast<float>(v_cm_per_s.X) * 1e-2f,
36 static_cast<float>(v_cm_per_s.Y) * 1e-2f,
37 static_cast<float>(v_cm_per_s.Z) * 1e-2f) {
38 }
39
40 /// Return this `Velocity` as an Unreal `FVector` in centimetres per
41 /// second.
42 FVector ToFVectorCmPerSecond() const {
43 return FVector{x * 1e2f, y * 1e2f, z * 1e2f};
44 }
45
46#endif // LIBCARLA_INCLUDED_FROM_UE4
47 };
48
49} // namespace geom
50} // namespace carla
This file contains definitions of common data structures used in traffic manager.
Linear velocity in metres per second.
Definition Velocity.h:17
constexpr Velocity(const Vector3D &v)
Definition Velocity.h:25
Velocity(const FVector &v_cm_per_s)
Build a Velocity (m/s) from an Unreal FVector expressed in centimetres per second.
Definition Velocity.h:33
constexpr Velocity(float ix, float iy, float iz)
Definition Velocity.h:21
FVector ToFVectorCmPerSecond() const
Return this Velocity as an Unreal FVector in centimetres per second.
Definition Velocity.h:42