Here's some cute bounding box functions for 2D shapes. A link to a longer list in the next post.
Nov 18, 2025 · 6:27 AM UTC
19
343
4,403
176,310
@iquilezles for Bezier Curve is there some new SDF formula or old Newton Raphson iteration?
1
0
3
2,046
@vadiks2003 That wouldn't be useful in most applications - most acceleration structures want axis aligned shapes and planes so you can do efficient pruning.
0
0
8
1,078
@iquilezles Bezier is drawn as an outlined stroke, but the function does not accept thickness as the formula for the line does.
1
0
1
1,581
@Zibx Oops, i forgot it! As you imagine, inflating the bbox by the same amount as the stoke itself is trivial.
1
0
5
1,186
@iquilezles Gadzooks! My shapes are so irregular and complex! How could I possibly figure their size in an X-Y coordinate plane for use in 2d image manipulation programs!
The Ever-Stalwart and Reliable 2D Bounding Box:
The Ever-Stalwart and Reliable 2D Bounding Box:
0
0
2
404
@iquilezles obviously I like your work! But I'm pretty sure I like how you're able to share it with awesome videos even more!
0
0
3
1,319
@iquilezles dude you have no idea how many hours you’ve saved me with all the sdf things and these too
0
0
0
302
@iquilezles Faster?
vec4 aabbBezier(vec2 p0, vec2 p1, vec2 p2)
{
vec2 b = p1 - p0;
vec2 c = p2 - p1;
vec2 t = clamp(b / (b - c), 0.0, 1.0);
vec2 q = p0 + t * (b + mix(b, c, t));
vec2 mi = min(p0, p2);
vec2 ma = max(p0, p2);
return vec4(min(mi, q), max(ma, q));
}
vec4 aabbBezier(vec2 p0, vec2 p1, vec2 p2)
{
vec2 b = p1 - p0;
vec2 c = p2 - p1;
vec2 t = clamp(b / (b - c), 0.0, 1.0);
vec2 q = p0 + t * (b + mix(b, c, t));
vec2 mi = min(p0, p2);
vec2 ma = max(p0, p2);
return vec4(min(mi, q), max(ma, q));
}
0
0
0
171
@iquilezles And now the biggest rectangle inside the shape 😂
0
0
0
1,261
@iquilezles I had to do this empirically for the cylinder example some time ago. Wonder how my implementation compares. 😄
0
0
0
613
@iquilezles Nice work, What graphics backend did you use for rendering?
0
0
0
100

















