Street Rule files - the arc radius problem

07-25-2019 07:20 AM
New Contributor III

While round corners for crossings and junctions are nice to look at, their mere existance has driven me nuts when programming cga rule files for roads with crosswalks. A simple example using the complete_streets rule: 

The center line of the street is not actually in the center of the street, but in the center of the uv space. Furthermore, geometry.dv(0) returns 12.3 rather than the actual value 7.

Here's my workaround to eliminate all geometry that de-centers the uv space and skews geometry.dv. 

First, we need to know how the v-component of the uv space is subdivided in the first place. From my observations v is always integral, controlled by the laneWidth.

attr v_range = max(1, rint(streetWidth / laneWidth))‍‍‍‍

Additionally, v starts at 0 at the left side of the street, all geometry that is constructed for the round corners has either negative v component or is larger than v_range. Knowing this it is easy to clamp out all unwanted geometry by doing a uv split.

split(v, uvSpace, 0)
    abs(geometry.vMin() : NIL
    | v_range                   : texture("builtin:uvtest.png") X.
    | ~1                            : NIL      // Or use geometry.vMax() - v_range 

As you can see the corner geometry does not bother the street layout calculation anymore. The actual street width can also be computed with ease (also for simple non-orthogonal street inlets) : 

attr realStreetWidth = v_range * geometry.dv(unitSpace, 0) / geometry.dv(uvSpace, 0)‍‍

I hope this helps you guys as much as it helped me with creating better street rule files. 



0 Replies