<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/collision-detection-in-c-vg8nvrypp" -->

---
title: Collision Detection in C | daily.dev
description: A live coding session implementing collision detection in C for a custom game engine. Covers the math behind sphere-box and rectangle-circle intersection using...
canonical: https://daily.dev/posts/collision-detection-in-c-vg8nvrypp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Collision Detection in C | daily.dev
og:description: A live coding session implementing collision detection in C for a custom game engine. Covers the math behind sphere-box and rectangle-circle intersection using...
og:url: https://daily.dev/posts/collision-detection-in-c-vg8nvrypp
og:image: https://api.daily.dev/og/posts/vG8NVryPP.png
og:image:alt: Collision Detection in C
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Collision Detection in C

**[Tsoding Daily](https://daily.dev/sources/tsoding_daily)** · 207 min read · 0 upvotes · 0 comments

## Summary

A live coding session implementing collision detection in C for a custom game engine. Covers the math behind sphere-box and rectangle-circle intersection using the closest-point technique (clamping center coordinates with min/max), then extends it to 3D. Also introduces a voxel-based barrier system using a hash set, adds a new 'barrier' entity kind to the game's entity system, computes axis-aligned bounding boxes from model vertices at asset-build time, and derives a rect-rect collision check by testing segment non-overlap per axis and negating.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=HNX5AJGoOrU>

## Similar posts on daily.dev

- [Box3D Debuts As New Open-Source 3D Physics Engine](https://daily.dev/posts/box3d-debuts-as-new-open-source-3d-physics-engine-xsk1j9ymw) · Phoronix · 0 upvotes · 0 comments
- [Announcing Box3D :: Box2D](https://daily.dev/posts/announcing-box3d-box2d-mu8ehdvki) · Lobsters · 0 upvotes · 0 comments
- [Inscribed Spheres :: Box2D](https://daily.dev/posts/inscribed-spheres-box2d-dvq55o0po) · 
        
            Box2D 
        
     · 0 upvotes · 0 comments

---

Tags: [#game-development](https://daily.dev/tags/game-development), [#c](https://daily.dev/tags/c), [#data-structures](https://daily.dev/tags/data-structures)

[View this post on daily.dev](https://daily.dev/posts/collision-detection-in-c-vg8nvrypp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Collision Detection in C","url":"https://daily.dev/posts/collision-detection-in-c-vg8nvrypp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/collision-detection-in-c-vg8nvrypp"},"datePublished":"2026-04-09T15:13:03.601Z","dateModified":"2026-04-09T15:13:25.076Z","description":"A live coding session implementing collision detection in C for a custom game engine. Covers the math behind sphere-box and rectangle-circle intersection using...","image":"https://i.ytimg.com/vi/HNX5AJGoOrU/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/HNX5AJGoOrU/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Tsoding Daily","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Tsoding Daily","logo":"https://media.daily.dev/image/upload/s--6msWm9pp--/f_auto/v1728806157/logos/tsoding_daily","url":"https://daily.dev/sources/tsoding_daily"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/collision-detection-in-c-vg8nvrypp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"game-development,c,data-structures","timeRequired":"PT207M","video":{"@type":"VideoObject","name":"Collision Detection in C","description":"A live coding session implementing collision detection in C for a custom game engine. Covers the math behind sphere-box and rectangle-circle intersection using...","thumbnailUrl":"https://i.ytimg.com/vi/HNX5AJGoOrU/sddefault.jpg","uploadDate":"2026-04-09T15:13:03.601Z","duration":"PT207M","url":"https://api.daily.dev/r/vG8NVryPP","embedUrl":"https://www.youtube.com/embed/HNX5AJGoOrU"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Tsoding Daily","item":"https://daily.dev/sources/tsoding_daily"},{"@type":"ListItem","position":3,"name":"Collision Detection in C"}]}
```

