mesa icon indicating copy to clipboard operation
mesa copied to clipboard

ContinuousSpace.get_heading returns wrong result sometimes in toroidal space mode

Open senden9 opened this issue 5 years ago • 0 comments

Describe the bug ContinuousSpace.get_heading returns wrong result when going over the middle line and toroidal space is enabled.

Expected behavior Heading from (51, 51) to (49, 49) should return (-2, -2).

To Reproduce

import numpy as np
from mesa import space

cspace = space.ContinuousSpace(100, 100, True)
print(cspace.get_heading((51, 51), (49, 49)))

Prints (98.0, 98.0). So it goes 180 Degree in the wrong direction.

If I shift the points down I get the right results:

import numpy as np
from mesa import space

cspace = space.ContinuousSpace(100, 100, True)
print(cspace.get_heading((11, 11), (9, 9)))

Prints (-2.0, -2.0). So the correct result.

senden9 avatar Oct 30 '20 16:10 senden9