A* Pathfinding Project  4.0.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
Agent.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 (Vector2 center, Vector2 offset, float radius, float inverseDt, float inverseDeltaTime)
 Creates a VO for avoiding another agent.
 
Vector2 Gradient (Vector2 p, out float weight)
 Gradient and value of the cost function of this VO.
 
Vector2 ScaledGradient (Vector2 p, out float weight)
 Gradient and value of the cost function of this VO.
 

Static Public Member Functions

static Vector2 ComplexMultiply (Vector2 a, Vector2 b)
 Complex number multiplication.
 
static VO SegmentObstacle (Vector2 segmentStart, Vector2 segmentEnd, Vector2 offset, float radius, float inverseDt, float inverseDeltaTime)
 Creates a VO for avoiding another agent.
 
static float SignedDistanceFromLine (Vector2 a, Vector2 dir, Vector2 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.
 

Public Attributes

Vector2 circleCenter
 
bool colliding
 
Vector2 cutoffDir
 
Vector2 cutoffLine
 
Vector2 dir1
 
Vector2 dir2
 
Vector2 line1
 
Vector2 line2
 
float radius
 
bool segment
 
Vector2 segmentEnd
 
Vector2 segmentStart
 
float weightBonus
 
float weightFactor
 

Constructor & Destructor Documentation

VO ( Vector2  center,
Vector2  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

static Vector2 ComplexMultiply ( Vector2  a,
Vector2  b 
)
static

Complex number multiplication.

Used to rotate vectors in an efficient way.

See Also
https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division
Vector2 Gradient ( Vector2  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.

Vector2 ScaledGradient ( Vector2  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.

static VO SegmentObstacle ( Vector2  segmentStart,
Vector2  segmentEnd,
Vector2  offset,
float  radius,
float  inverseDt,
float  inverseDeltaTime 
)
static

Creates a VO for avoiding another agent.

Note that the segment is directed, the agent will want to be on the left side of the segment.

static float SignedDistanceFromLine ( Vector2  a,
Vector2  dir,
Vector2  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

Vector2 circleCenter
bool colliding
Vector2 cutoffDir
Vector2 cutoffLine
Vector2 dir1
Vector2 dir2
Vector2 line1
Vector2 line2
float radius
bool segment
Vector2 segmentEnd
Vector2 segmentStart
float weightBonus
float weightFactor

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