[026] How to Control Approximate Split (~) Works in Esri CityEngine

Discover the 1/3 threshold rule for approximate splits to perfectly manage leftover geometry dimensions without creating useless polygons.

This tutorial explores the specific mathematical criteria CityEngine uses to handle remaining dimensions when using the approximate split operator (~). By understanding the "1/3 rule," you can predict exactly when a rule will create an additional segment or simply distribute the remainder across existing ones, ensuring your procedural models remain clean and geometrically logical.

Core Logic of Approximate Split (~)

Let's continue from last time and look into the specific criteria for approximate splitting.

To explain it simply: if the remaining length exceeds 1/3 of the approximate split value following the '~' operator, CityEngine reduces the approximate size and performs one additional split.

Basic Split Example (134m Rectangle)

I will draw a rectangle with a width of 134m. From the top, I will set the StartRules to Lot1, Lot2, and Lot3 in sequence.

134m width layout with three lots
img 1 : Initial setup of three lots with a width of 134m

Take a look at the code below.


Lot1 --> split(x){~99 : A}*
Lot2 --> split(x){~100 : A}*
Lot3 --> split(x){~101 : A}*

A --> color(1,0,0) X.

Rule Behavior Breakdown (Lot1 / Lot2 / Lot3)

Line 1: Lot1 performs an approximate repeating split with ~99.

The leftover area is 35m, so 35/99 ≈ 0.3535, which is a value greater than 1/3 (0.333...).

Line 2: Lot2 performs an approximate repeating split with ~100.

The leftover area is 34m, so 34/100 = 0.34, which is also a value greater than 1/3.

Line 3: Lot3 performs an approximate repeating split with ~101.

The leftover area is 33m, so 33/101 ≈ 0.326, which is a value smaller than 1/3.

Let's look at the results.

Result Interpretation of 134m Split

Split results for 134m width
img 2 : Visualization of the 1/3 threshold rule in action

As you can see in the figure, segments where the leftover portion exceeds 1/3 of the approximate split value are split once more, whereas segments where it is 1/3 or less are not split further.

In the case of Lot1 and Lot2, because the leftover exceeds 1/3, they split one more time, dividing the area into equal parts.

Extended 300m Split Example

To help with your understanding, I'll add one more example before finishing for today. I will perform an approximate repeating split on a 300m wide rectangle using the following values. Try to guess how they will be split by looking at the image and the code.

300m split example setup
img 3 : Various approximate split values applied to a 300m width

Approximate Split Behavior Across Multiple Values

Looking at the results:

Results of 300m approximate split
img 4 : Comparison of resulting segments based on different approximate values

I hope the results came out as you expected.

Let's try just one more. If we split a 300m rectangle as shown below, what shape will it take?

Advanced Repeating Split Structure


Lot1 --> split(x){ 50 : A | { ~10 : B | ~20 : C }* | 50 : A }

A --> color(1,0,0) X.
B --> color(0,1,0) X.
C --> color(0,0,1) X.

The result is...

Nested approximate split result
img 5 : Complex nested split using fixed and approximate operators

How Fixed and Approximate Splits Interact

Shall we do one more? What would it look like if we split a 300m wide rectangle with the following code?


Lot1 --> 
    split(x){ 50 : A | 2 : split(x){~5 : B | ~10 : C}* | 50 : A | 1 : split(x){~10 : B | ~20 : C}* | 50 : A }*

A --> color(1,0,0) X.
B --> color(0,1,0) X.
C --> color(0,0,1) X.

Line 2: There are areas fixed at 50m at both ends and in the middle, and between them are areas divided by a 2:1 ratio.

Multi-Level Repeating Split Logic

The area with the ratio of 2 has been approximate-repeating split by 5 and 10, and the area with the ratio of 1 has been approximate-repeating split by 10 and 20.

Furthermore, the entire sequence is being repeating-split again.

The resulting pattern is shown below.

Final complex repeating split result
img 6 : Advanced repeating split logic applied across the entire shape

I believe it turned out exactly as you expected.

In the next session, we will learn how to split based on the percentage (%) ratio of the shape's size.

"We can only see a short distance ahead, but we can see plenty there that needs to be done."
— Alan Turing, Computing Machinery and Intelligence (1950)
Continue Learning
Explore complete tutorial collections for CityEngine and Global Mapper.

Comments

Popular posts from this blog

029] How to Split Polygon Areas with Intersecting Lines in Global Mapper

[008] How to Understand CGA Rule Structure in CityEngine (Beginner Guide)

046] How to Create Parallel Offset Lines in Global Mapper