Is n^3 -2 a lot?

I’m working on second version of “space”.
But the problem with that is when n (number of objects in space) is equal to 100,
I need to go one million times trough for loop to calculate next move and collisions.
I need to get all of the objects in space so n * n and then calculate collisions for every single one of them so another n^2 * n.
In total it gives me n^3 -2.
Any suggestions to avoid that? (decrease n)

Wouldn’t that only need to be in n^2?
Like:

for every object A in space
	for every other object B in space
		compute influence of object B on A

yeah i realized that ,right after i posted this topic on dev forum.
And it is n^2 + n

You could implement some kind of space partitioning system to rule out objects which definitely don’t need to be checked against each other. This would lower the number of required checks.

This could however be a bit difficult to implement depending on your programming level.

This might help explain the concept however you will likely want to look for some videos and examples of code for further implementation detail.

Good luck with your project :slight_smile:

1 Like