Angle difference
#8
(01-31-2023, 09:29 PM)SMcNeill Wrote: From what I read, it appears you're looking for something like this to determine if they're on a collision course:

Code: (Select All)
PRINT collision(0, 10)
PRINT collision(10, 0)
PRINT collision(350, 0)
PRINT collision(0, 350)
PRINT collision(0, 11)
PRINT collision(11, 0)
PRINT collision(349, 0)
PRINT collision(0, 349)


FUNCTION collision (a, b)
    t = ABS((a - b + 360) MOD 360)
    collision = t <= 10 OR t >= 350
END FUNCTION

No the collision detection was being done with thePixelCollision code. The problem was what to do after collision was detected. Do I reverse the spider do I reverse both spiders, do I turn them same direction if head on but opposite direction if their headings almost the same.... 

I figured if both going in approximately same direction to turn one one way and the other the opposite but with my first angle diff code that didn't work maybe with code developed today. I kept getting spiders stuck or spinning, yuck!

Big spiders were setup to go faster than little ones so if on same heading they will collide because the big one overtook the smaller. That's when I needed to know the angle difference in their headings, to swerve the two apart. The angle difference problem had me stumped for awhile and my solution yesterday failed to stop the problems.

Anyway for spider collisions the solution was to just speed up both in direction they were going, looks about right actually.

Maybe I should try this new DiffAngleD and try again.
b = b + ...
Reply


Messages In This Thread
Angle difference - by bplus - 01-31-2023, 05:04 PM
RE: Angle difference - by MasterGy - 01-31-2023, 05:50 PM
RE: Angle difference - by OldMoses - 01-31-2023, 06:15 PM
RE: Angle difference - by bplus - 01-31-2023, 06:44 PM
RE: Angle difference - by OldMoses - 01-31-2023, 07:33 PM
RE: Angle difference - by bplus - 01-31-2023, 08:12 PM
RE: Angle difference - by OldMoses - 01-31-2023, 10:32 PM
RE: Angle difference - by SMcNeill - 01-31-2023, 09:29 PM
RE: Angle difference - by bplus - 01-31-2023, 10:03 PM



Users browsing this thread: 6 Guest(s)