C
Join ServerC#
help
❔ Circle line-segment collision detection
Xxellez12/14/2022
Tried following this https://stackoverflow.com/questions/1073336/circle-line-segment-collision-detection-algorithm
//item is line can be horizontal or vertical
float dx = item.X2- item.Position.X;
float dy = item.Y2 - item.Position.Y;
float a = dx * dx + dy * dy;
float b = 2 * (dx * (item.Position.X - ball.Position.X) + dy * (item.Position.Y - ball.Position.Y));
float c = (item.Position.X - ball.Position.X) * (item.Position.X - ball.Position.X) + (item.Position.Y - ball.Position.Y) * (item.Position.Y - ball.Position.Y) - ball.Radius * ball.Radius;
float discriminant = b * b - 4 * a * c;
I dont know if what I tried is accurate to what the link answer does.AAccord12/15/2022
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.