Search code examples
javaanylogic

how to calculate the relative velocity of two agents in anylogic


now I use the pedsource to generate pedestrians in anylogic. I want to calculate the relative velocity of two specific pedestrians. ("getspeed()" seems not consider the direction) is there any way to calculate it?

thanks!


Solution

  • I have looked at the Pedestrian API and under Coordinates you can get the 3D (X, Y, Z) positions of the pedestrians (in meters) and their target (tX, tY, tZ) so why don't you use them to extract the direction you want.

    Functions:

    For pedestrians location: getX(), getY(), getZ()

    For their targets: getTargetX(), getTargetY(), getTargetZ()

    So by calculating the directional vector for two points in 3D space you can draw it.

    Ref:

    determining-a-vector-given-two-points