A* Pathfinding Project  4.3.2
The A* Pathfinding Project for Unity 3D
JobRVO.VO Struct Reference

Velocity Obstacle. More...

Detailed Description

Velocity Obstacle.

This is a struct to avoid too many allocations.

See also
https://en.wikipedia.org/wiki/Velocity_obstacle

Public Member Functions

 VO (float2 center, float2 offset, float radius, float inverseDt, float inverseDeltaTime)
 Creates a VO for avoiding another agent. More...
 
void Draw (float2 circleCenter, float2 drawingOffset)
 
float2 Gradient (float2 p, out float weight)
 Gradient and value of the cost function of this VO. More...
 
float2 ScaledGradient (float2 p, out float weight)
 Gradient and value of the cost function of this VO. More...
 

Static Public Member Functions

static float2 Normalize (float2 v, out float length)
 
static float SignedDistanceFromLine (float2 a, float2 dir, float2 p)
 Returns a negative number of if p lies on the left side of a line which with one point in a and has a tangent in the direction of dir. More...
 

Public Attributes

float2 circleCenter
 
bool colliding
 
float2 cutoffDir
 
float2 cutoffLine
 
float2 dir1
 
float2 dir2
 
float2 line1
 
float2 line2
 
float radius
 
bool segment
 
float weightBonus
 
float weightFactor
 

Constructor & Destructor Documentation

◆ VO()

VO ( float2  center,
float2  offset,
float  radius,
float  inverseDt,
float  inverseDeltaTime 
)

Creates a VO for avoiding another agent.

Parameters
centerThe position of the other agent relative to this agent.
offsetOffset of the velocity obstacle. For example to account for the agents' relative velocities.
radiusCombined radius of the two agents (radius1 + radius2).
inverseDt1 divided by the local avoidance time horizon (e.g avoid agents that we will hit within the next 2 seconds).
inverseDeltaTime1 divided by the time step length.

Member Function Documentation

◆ Draw()

void Draw ( float2  circleCenter,
float2  drawingOffset 
)

◆ Gradient()

float2 Gradient ( float2  p,
out float  weight 
)

Gradient and value of the cost function of this VO.

The VO has a cost function which is 0 outside the VO and increases inside it as the point moves further into the VO.

This is the negative gradient of that function as well as its value (the weight). The negative gradient points in the direction where the function decreases the fastest.

The value of the function is the distance to the closest edge of the VO and the gradient is normalized.

◆ Normalize()

static float2 Normalize ( float2  v,
out float  length 
)
static

◆ ScaledGradient()

float2 ScaledGradient ( float2  p,
out float  weight 
)

Gradient and value of the cost function of this VO.

Very similar to the Gradient method however the gradient and value have been scaled and tweaked slightly.

◆ SignedDistanceFromLine()

static float SignedDistanceFromLine ( float2  a,
float2  dir,
float2  p 
)
static

Returns a negative number of if p lies on the left side of a line which with one point in a and has a tangent in the direction of dir.

The number can be seen as the double signed area of the triangle {a, a+dir, p} multiplied by the length of dir. If dir.magnitude=1 this is also the distance from p to the line {a, a+dir}.

Member Data Documentation

◆ circleCenter

float2 circleCenter

◆ colliding

bool colliding

◆ cutoffDir

float2 cutoffDir

◆ cutoffLine

float2 cutoffLine

◆ dir1

float2 dir1

◆ dir2

float2 dir2

◆ line1

float2 line1

◆ line2

float2 line2

◆ radius

float radius

◆ segment

bool segment

◆ weightBonus

float weightBonus

◆ weightFactor

float weightFactor

The documentation for this struct was generated from the following file: