HackerTrans
TopNewTrendsCommentsPastAskShowJobs

Ef996

no profile record

Submissions

Show HN: I was surprised by this interactive GPU line rasterization explanation

twitter.com
6 points·by Ef996·2 месяца назад·0 comments

The Simple Geometry Behind Any Road

sandboxspirit.com
5 points·by Ef996·3 месяца назад·0 comments

The Data Structures of Roads

sandboxspirit.com
5 points·by Ef996·4 месяца назад·0 comments

comments

Ef996
·3 месяца назад·discuss
Author here. Engineers use clothoids as the primary geometry for high-speed roads by offsetting a centerline clothoid. However, the offset of a clothoid is not itself a clothoid, so the left and right edges are not mathematically clothoids.

A clothoid is simply a mathematically ideal way to achieve continuously increasing curvature along a path. In practice, it can be approximated by chaining multiple circular arcs with decreasing radii.
Ef996
·5 месяцев назад·discuss
Nope. But I mean aren't functions of circles essentially some kind of SDFs in 2d? Or at least those of disks.
Ef996
·5 месяцев назад·discuss
I will definitely explore this in the future as architecture is probably my next passion after roads :D
Ef996
·5 месяцев назад·discuss
This is amazing. Some objective would be great
Ef996
·5 месяцев назад·discuss
Author here: i agree the article oversimplified here and in practice vehicle tracks can sometimes be non concentric. But it has nothing to do with differentials. Differentials just allow wheels to rotate at different speeds (as perimeter of a smaller radius circle is smaller the outer one). Non parallelism usually comes from the Ackerman steering or slipping. But rear tracks of a vehicle going slowly through sand will always be concentric. Parallelism is important for engineers because it also allows multiple vehicles to go in parallel on a multi lane road. You can see how that is failing with bezier paths in the CS2 ss in the article. Also hairpin turns are usually designed with arcs in mind as well
Ef996
·5 месяцев назад·discuss
Will share more soon. I have some more recordings of it on x https://x.com/SandboxSpirit if you're interested.
Ef996
·5 месяцев назад·discuss
Thanks for references! I initially considered bevy for this but I was a bit scared it was not mature enough. How do you find it now?
Ef996
·5 месяцев назад·discuss
Haha. I myself tried to play CS like that. Start with a historical core. The thing is the way the game is implemented buildings only have rectangular footprints while in reality buildings occupy the spaces more organically. I actually spent quite some time on google maps trying to see what pattern historical buildings followed to fill in spaces but couldn't get a definitive answer. I drafted it at some point in sketchup. Here is the result

https://imgur.com/a/procedurally-generated-buildings-that-or...
Ef996
·5 месяцев назад·discuss
True. I mostly meant not personal vehicles, so jut buses, trams etc. I supposed emergency services will use those dedicated lanes. or maybe civilization is so advanced those will be served via flying only. Idk just since fiction thinking.
Ef996
·5 месяцев назад·discuss
Yep, good point. I am myself a huge fan of livable oriented infrastructure (bike lanes, pedestrian paths, public transportation) but the hard truth is that roads were initially designed for carriages and later for cars. A though I recurrently have is how would a city designed from scratch by a civilization that uses only bikes and walking look like?
Ef996
·5 месяцев назад·discuss
I am a huge fan of satisfactory as well (probably no surprise for anyone)
Ef996
·5 месяцев назад·discuss
I mean they are not a math nightmare per se if you’re comfortable with the theory. What I meant is that they become comparatively complex to integrate into a system like this. Think about arc length, compute intersections, reparametrization, etc., and with clothoids that usually means some complex numerical algorithms.

Using circular arcs or even simple third-degree polynomials (like cubic parabolas) reduces many of those operations to trivial O(1) function calls, which makes them much cheaper to evaluate and manipulate procedurally, especially when you're computing it 60 times per frame
Ef996
·5 месяцев назад·discuss
Wow, that’s a really detailed deep dive, saved it for a read later. I didn’t even realize clothoids are also tricky to connect. I never really dared to jump into actually implementing them myself.
Ef996
·5 месяцев назад·discuss
Yes, I don't even know how I didn't know about this at the time of wiring the article. But a must read for sure!
Ef996
·5 месяцев назад·discuss
Glad you mentioned it. Cubic parabolas were actually used by eraly railway engineers as good approximations of clothoids back when numerically solving a true euler spiral was a daunting task.

They are visually very close because their curvature increseases approximately linearly along the curve but not exactly. Mathematically speaking if you wirte the cubic parabola as something like y = kx^3, the second derivative (which give the curvature) grows linearly with x which makes it behave similary in gentle transitions.

The problem is that the second derivative is not enough alone for having a true smooth curvature. The real curvature formula has in the denominator the first derivative as well (slope) making it not increase perfectly linearly along the curve. (denominator becomes larger and larger as x incrases)

But yeah, cubic parabola is basaically a good enough approximation. Might be a good solution for a system like this.
Ef996
·5 месяцев назад·discuss
Very happy reading this because I was always thinking exactly the same about historical games. One of my turn offs for any historical city building is when they are grid based. I always found that to be highly unrealistic, but I yeah, was aware that it was just some unneeded complexity and just my nerdy nitpicks. The point you make would’ve actually been a strong argument in my article. Too bad I didn’t have the inspiration to include it. The way historical cities developed in an ordered yet intricate way without any central planning (same as ant colonies) is actually very fascinating and I might write about this at some point.
Ef996
·5 месяцев назад·discuss
For sure I will. Thanks a lot for your interest. To anybody's disappointment, I didn't even know Hacker News was a thing until I saw a ton of traffic coming from it. But I guess I'll be more active here since there are a lot of like-minded people.
Ef996
·5 месяцев назад·discuss
Hello, I am the creator of this road system. The thing is that I myself don't even know what I want to do with it. lol. Maybe an asset or a game (a bit scared to jump in a full fledge game to be honest).

I am a fun of Junxions my self which follow closely. But the approach in my system if very different. Junxions creator uses the same kind of node base/bezier shapes paradigm where intersections happen as node graphs and not automatically as collisions between road segments. It's hard to explain but I am planning to dive into more details on why those two approaches are different in my next blog deep dive.