CARLA
Static Public Member Functions | List of all members
carla::geom::Math Class Reference

#include <Math.h>

Static Public Member Functions

template<typename T >
static T Clamp (T a, T min=T(0), T max=T(1))
 
static 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: More...
 
static std::pair< float, float > DistanceSegmentToPoint (const Vector3D &p, const Vector3D &v, const Vector3D &w)
 Returns a pair containing: More...
 
static auto DistanceSquared (const Vector3D &a, const Vector3D &b)
 
static auto DistanceSquared2D (const Vector3D &a, const Vector3D &b)
 
static auto Dot (const Vector3D &a, const Vector3D &b)
 
static 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. More...
 
static Vector3D GetRightVector (const Rotation &rotation)
 Compute the unit vector pointing towards the Y-axis of rotation. More...
 
static Vector3D GetUpVector (const Rotation &rotation)
 Compute the unit vector pointing towards the Y-axis of rotation. More...
 
static double GetVectorAngle (const Vector3D &a, const Vector3D &b)
 Returns the angle between 2 vectors in radians. More...
 
static 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 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()

template<typename T >
static T carla::geom::Math::Clamp ( a,
min = T(0),
max = T(1) 
)
inlinestatic

◆ Cross()

static auto carla::geom::Math::Cross ( const Vector3D a,
const Vector3D b 
)
inlinestatic

◆ Distance()

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

Definition at line 78 of file Math.h.

References DistanceSquared().

Referenced by carla::geom::ComputeVertexWeight(), carla::geom::Location::Distance(), carla::road::Road::GetNearestLane(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Distance2D()

static 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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(), RotatePointOnOrigin2D(), carla::geom::Vector3D::x, and carla::geom::Vector3D::y.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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(), LinearLerp(), and TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DistanceSquared()

static auto carla::geom::Math::DistanceSquared ( const Vector3D a,
const Vector3D b 
)
inlinestatic

◆ DistanceSquared2D()

static auto carla::geom::Math::DistanceSquared2D ( const Vector3D a,
const Vector3D b 
)
inlinestatic

Definition at line 74 of file Math.h.

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

Referenced by Distance2D(), and DistanceSegmentToPoint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Dot()

static auto carla::geom::Math::Dot ( const Vector3D a,
const Vector3D b 
)
inlinestatic

◆ Dot2D()

static auto carla::geom::Math::Dot2D ( const Vector3D a,
const Vector3D b 
)
inlinestatic

Definition at line 66 of file Math.h.

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

Referenced by DistanceSegmentToPoint().

+ Here is the caller graph for this function:

◆ GenerateRange()

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

Definition at line 151 of file Math.cpp.

Referenced by ACarlaGameModeBase::DebugShowSignals(), and LinearLerp().

+ Here is the caller graph for this function:

◆ 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(), and LinearLerp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRightVector()

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

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

Definition at line 125 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(), and LinearLerp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetUpVector()

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

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

Definition at line 138 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(), and LinearLerp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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(), LinearLerp(), and carla::traffic_manager::InMemoryMap::SetUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LinearLerp()

static float carla::geom::Math::LinearLerp ( float  a,
float  b,
float  f 
)
inlinestatic

Definition at line 86 of file Math.h.

References DistanceArcToPoint(), DistanceSegmentToPoint(), GenerateRange(), GetForwardVector(), GetRightVector(), GetUpVector(), GetVectorAngle(), and RotatePointOnOrigin2D().

+ Here is the call graph for this function:

◆ Pi()

template<typename T >
static constexpr T carla::geom::Math::Pi ( )
inlinestatic

Definition at line 25 of file Math.h.

◆ Pi2()

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

Definition at line 31 of file Math.h.

◆ RotatePointOnOrigin2D()

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

Definition at line 111 of file Math.cpp.

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

Referenced by carla::nav::Navigation::AddOrUpdateVehicle(), DistanceArcToPoint(), and LinearLerp().

+ Here is the caller graph for this function:

◆ Square()

template<typename T >
static T carla::geom::Math::Square ( const T &  a)
inlinestatic

Definition at line 54 of file Math.h.

Referenced by DistanceSquared(), and DistanceSquared2D().

+ Here is the caller graph for this function:

◆ ToDegrees()

template<typename T >
static constexpr T carla::geom::Math::ToDegrees ( rad)
inlinestatic

Definition at line 37 of file Math.h.

Referenced by carla::road::MapBuilder::AddSignalPositionInertial(), carla::road::MapBuilder::ComputeSignalTransform(), carla::road::Lane::ComputeTransform(), and ARayCastSemanticLidar::SimulateLidar().

+ Here is the caller graph for this function:

◆ ToRadians()

template<typename T >
static constexpr T carla::geom::Math::ToRadians ( deg)
inlinestatic

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