CARLA
Loading...
Searching...
No Matches
carla::geom::Math Class Reference

#include <Math.h>

Static Public Member Functions

template<typename T>
static constexpr T Clamp (T a, T min=T(0), T max=T(1))
static constexpr auto Cross (const Vector3D &a, const Vector3D &b)
static auto Distance (const Vector3D &a, const Vector3D &b)
static auto Distance2D (const Vector3D &a, const Vector3D &b)
static std::pair< float, float > DistanceArcToPoint (Vector3D p, Vector3D start_pos, float length, float heading, float curvature)
 Returns a pair containing:
static std::pair< float, float > DistanceSegmentToPoint (const Vector3D &p, const Vector3D &v, const Vector3D &w)
 Returns a pair containing:
static constexpr auto DistanceSquared (const Vector3D &a, const Vector3D &b)
static constexpr auto DistanceSquared2D (const Vector3D &a, const Vector3D &b)
static constexpr auto Dot (const Vector3D &a, const Vector3D &b)
static constexpr auto Dot2D (const Vector3D &a, const Vector3D &b)
static std::vector< int > GenerateRange (int a, int b)
static Vector3D GetForwardVector (const Rotation &rotation)
 Compute the unit vector pointing towards the X-axis of rotation.
static Vector3D GetRightVector (const Rotation &rotation)
 Compute the unit vector pointing towards the Y-axis of rotation.
static Vector3D GetUpVector (const Rotation &rotation)
 Compute the unit vector pointing towards the Y-axis of rotation.
static double GetVectorAngle (const Vector3D &a, const Vector3D &b)
 Returns the angle between 2 vectors in radians.
static constexpr float LinearLerp (float a, float b, float f)
template<typename T>
static constexpr T Pi ()
template<typename T>
static constexpr T Pi2 ()
static Vector3D RotatePointOnOrigin2D (Vector3D p, float angle)
template<typename T>
static constexpr T Square (const T &a)
template<typename T>
static constexpr T ToDegrees (T rad)
template<typename T>
static constexpr T ToRadians (T deg)

Detailed Description

Definition at line 21 of file Math.h.

Member Function Documentation

◆ Clamp()

◆ Cross()

constexpr auto carla::geom::Math::Cross ( const Vector3D & a,
const Vector3D & b )
inlinestaticconstexpr

◆ Distance()

auto carla::geom::Math::Distance ( const Vector3D & a,
const Vector3D & b )
inlinestatic

◆ Distance2D()

auto carla::geom::Math::Distance2D ( const Vector3D & a,
const Vector3D & b )
inlinestatic

Definition at line 82 of file Math.h.

References DistanceSquared2D().

Referenced by DistanceArcToPoint(), DistanceSegmentToPoint(), and carla::road::Map::GetWaypoint().

◆ DistanceArcToPoint()

std::pair< float, float > carla::geom::Math::DistanceArcToPoint ( Vector3D p,
Vector3D start_pos,
float length,
float heading,
float curvature )
static

Returns a pair containing:

  • first: distance across the arc from start_pos to p' where p' = p projected on Arc
  • second: Euclidean distance from p to p'
Todo
: Because Unreal's coordinates, hacky way to correct the -y, this must be changed in the future

Definition at line 33 of file Math.cpp.

References DEBUG_ASSERT, Distance2D(), Pi(), RotatePointOnOrigin2D(), carla::geom::Vector3D::Vector3D(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by carla::road::element::GeometryArc::DistanceTo(), and TEST().

◆ DistanceSegmentToPoint()

std::pair< float, float > carla::geom::Math::DistanceSegmentToPoint ( const Vector3D & p,
const Vector3D & v,
const Vector3D & w )
static

Returns a pair containing:

  • first: distance from v to p' where p' = p projected on segment (w - v)
  • second: Euclidean distance from p to p'
    Parameters
    ppoint to calculate distance
    vfirst point of the segment
    wsecond point of the segment

Definition at line 18 of file Math.cpp.

References Clamp(), Distance2D(), DistanceSquared2D(), and Dot2D().

Referenced by carla::road::element::GeometryLine::DistanceTo(), carla::road::Map::GetClosestWaypointOnRoad(), and TEST().

◆ DistanceSquared()

◆ DistanceSquared2D()

constexpr auto carla::geom::Math::DistanceSquared2D ( const Vector3D & a,
const Vector3D & b )
inlinestaticconstexpr

Definition at line 74 of file Math.h.

References Square(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by Distance2D(), and DistanceSegmentToPoint().

◆ Dot()

◆ Dot2D()

constexpr auto carla::geom::Math::Dot2D ( const Vector3D & a,
const Vector3D & b )
inlinestaticconstexpr

Definition at line 66 of file Math.h.

References carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

Referenced by DistanceSegmentToPoint().

◆ GenerateRange()

std::vector< int > carla::geom::Math::GenerateRange ( int a,
int b )
static

Definition at line 159 of file Math.cpp.

Referenced by ACarlaGameModeBase::DebugShowSignals().

◆ GetForwardVector()

Vector3D carla::geom::Math::GetForwardVector ( const Rotation & rotation)
static

Compute the unit vector pointing towards the X-axis of rotation.

Definition at line 117 of file Math.cpp.

References carla::geom::Rotation::pitch, ToRadians(), and carla::geom::Rotation::yaw.

Referenced by carla::geom::Rotation::GetForwardVector().

◆ GetRightVector()

Vector3D carla::geom::Math::GetRightVector ( const Rotation & rotation)
static

Compute the unit vector pointing towards the Y-axis of rotation.

Definition at line 128 of file Math.cpp.

References carla::geom::Rotation::pitch, carla::geom::Rotation::roll, ToRadians(), and carla::geom::Rotation::yaw.

Referenced by carla::geom::Rotation::GetRightVector().

◆ GetUpVector()

Vector3D carla::geom::Math::GetUpVector ( const Rotation & rotation)
static

Compute the unit vector pointing towards the Y-axis of rotation.

Definition at line 144 of file Math.cpp.

References carla::geom::Rotation::pitch, carla::geom::Rotation::roll, ToRadians(), and carla::geom::Rotation::yaw.

Referenced by carla::geom::Rotation::GetUpVector().

◆ GetVectorAngle()

double carla::geom::Math::GetVectorAngle ( const Vector3D & a,
const Vector3D & b )
static

Returns the angle between 2 vectors in radians.

Definition at line 14 of file Math.cpp.

References Dot(), and carla::geom::Vector3D::Length().

Referenced by carla::road::Map::CreateRtree(), and carla::traffic_manager::InMemoryMap::SetUp().

◆ LinearLerp()

constexpr float carla::geom::Math::LinearLerp ( float a,
float b,
float f )
inlinestaticconstexpr

Definition at line 86 of file Math.h.

◆ Pi()

◆ Pi2()

template<typename T>
constexpr T carla::geom::Math::Pi2 ( )
inlinestaticconstexpr

Definition at line 31 of file Math.h.

References Pi().

Referenced by AInertialMeasurementUnit::ComputeCompass(), CaService::GetHeading(), and ARadar::SendLineTraces().

◆ RotatePointOnOrigin2D()

Vector3D carla::geom::Math::RotatePointOnOrigin2D ( Vector3D p,
float angle )
static

◆ Square()

template<typename T>
constexpr T carla::geom::Math::Square ( const T & a)
inlinestaticconstexpr

Definition at line 54 of file Math.h.

Referenced by DistanceSquared(), and DistanceSquared2D().

◆ ToDegrees()

◆ ToRadians()


The documentation for this class was generated from the following files: