Hi I tried using the distance command and the coordinates of 2 ellipses to detect if they are colliding.
But the programm uses the start coordinates and not the coordinates after they moved.
Is there another possibility to detect if things are colliding?
What could be the problem if my coordinates are not updated?
Excuse me, could you post your code please?
Because when your ellipses move you must have the coordinates in some variables. Maybe other than the initial variable.
For dist() use the correct variables you also use to display the ellipses
Thats the 2 classes I use for the ellipses and in the second one is also the part for the collision: https://codeshare.io/2K1MAY
I also tried using new variales bur they just would´nt get updated.
Control your code whether the variables you use to display you also use to check the distance
I´ve checked my code several times and now the processing tells me that the class i try to reference does not exist. The variables i use for dist() are the exact ones i have to use and are not misspelled.
I can’t run your code.
The Brain class is missing?
Are your ellipses actually circles, or are they elliptical?
Ellipse-ellipse collision detection can be wickedly hard. Axis-aligned ellipses are a bit better, but still awful. It is worth doing almost anything else to avoid the math
The math: ellipse-ellipse collision
Ellipse–circle and ellipse–ellipse collision detection – iki.fi/o
x = cb^2/(2(b^2 - 1)) - 1/2sqrt(c^2b^4/(b^2 - 1)^2 + (c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)/(3(b^4 - 2b^2 + 1)) - (c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)/(b^2 - 1)^2 + (- 108c^2(b^4c - b^2c)^2b^4 + 72(b^4 - 2b^2 + 1)c^2(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)b^4 + 2(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)^3 + 108(b^4 - 2b^2 + 1)(b^4c - b^2c)^2 + 36*(b^4c - b^2c)^2*(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1) + sqrt((- 108c^2*(b^4c - b^2c)^2b^4 + 72(b^4 - 2b^2 + 1)c^2(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)b^4 + 2(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1)^3 + 108(b^4 - 2b^2 + 1)(b^4c - b^2c)^2 + 36*(b^4c - b^2c)^2*(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1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^2c)^2 + 36*(b^4c - b^2c)^2*(c^2b^4 - b^4 + d^2b^2 + 2b^2 - 1))^2 - 4(- 12*(b^4 - 2b^2 + 1)c^2b^4 + 12(b^4c - b^2c)^2 + (c^2b^4 - b^4 + d^2b^2 + 2*b^2 - 1)^2)^3))^(1/3)))))
– options include scaling the coordinate axes to make them circle-circle, for example, or creating a good-enough convex hull and doing polygon-polygon, or creating a buffer and using picking e.g. with the Picking library.