Get all fixed points in range from translation vector

EDIT : Oh wow, apologies I spaced out. This is meant for the scripting section.

I’m hoping to achieve positions/collisions determinism in a small 2D custom physics game by forcing objects to travel through fixed points instead of allowing collisions to be sampled at any unconstrained values.

I need to make sure that 2 objects, starting at the same position with the same unit vector will sample the same exact points.

Let’s say only every 10th of a meter is considered a valid point. 0.1, 0.2, 0.3, etc. For 2D coordinates, (0.1, 0.1) is valid, (0.1, 12.6) is valid, (0.1, 0.42) is not valid.

In an example where a given object’s velocity is (60, 60), running at 60 fps, then over the frame it’d try to translate by (1, 1).

Essentially the translation is split into several steps (0.1, 0.1), (0.2, 0.2), etc and collisions are sampled at every point along the way.

Now let’s say the velocity vector was something like (23.156f, 39.12f) instead. Can you guys think of a way that I could acquire what points I should sample for a given translation?

Also, if you guys spot fundamental flaws in the idea, please let me know

I just used this a few days ago: Bresenham modified algorithm - ALL the points

1 Like

Very cool, thank you

Apologies for a necro, but I discovered that under some circumstances I was getting a bug with my method derived from that website. I don’t know if it was my C# translation or the method itself, but either way it wasn’t working properly - sometimes it was skipping points. However, I just translated a scikit method here (the _line method) and it’s working correctly (and quickly too).

1 Like