Skip to content

252 add closest point on rectangle to circle dev - #253

Closed
Johnnyg63 wants to merge 6 commits into
mainfrom
252-add-closest-point-on-rectangle-to-circle-dev
Closed

Johnnyg63 wants to merge 6 commits into
mainfrom
252-add-closest-point-on-rectangle-to-circle-dev

Conversation

@Johnnyg63

Copy link
Copy Markdown
Collaborator

Added a closest method for rect to circle in order to support collisions.

// closest(r,c)
// Returns closest point on rectangle to circle
template<typename T1, typename T2>
inline olc::v_2d closest(const rect& r, const circle& l)
{
// Johnnyg63
const auto pX = std::clamp(l.pos.x, r.pos.x, r.pos.x + r.size.x);
const auto pY = std::clamp(l.pos.y, r.pos.y, r.pos.y + r.size.y);
return { pX, pY };
}

@Johnnyg63
Johnnyg63 requested a review from OneLoneCoder May 30, 2026 13:50
@Johnnyg63 Johnnyg63 linked an issue May 30, 2026 that may be closed by this pull request
@OneLoneCoder

Copy link
Copy Markdown
Owner

I know its been a while, but this PR is a mess probably because its against main and not develop :P

@Johnnyg63

Copy link
Copy Markdown
Collaborator Author

Oh shoot , sorry meant for it to go into develop, I ll do it again correctly

@Johnnyg63

Copy link
Copy Markdown
Collaborator Author

Closing, will create a new PR to for this as it is pointing to main not develop

@Johnnyg63 Johnnyg63 closed this May 31, 2026
@Johnnyg63
Johnnyg63 deleted the 252-add-closest-point-on-rectangle-to-circle-dev branch May 31, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants