source-academy/modules

[CSG]: transformations not always accurate

Closed this issue · 2 comments

Here is a program that should result in a Mosely snowflake:

https://share.sourceacademy.org/lab29

Here is the output.

Screenshot 2024-03-15 at 11 01 50 AM

The red circle indicates a possible bug: a wrongly displaced component.

While breaking down the program to see how the shapes change with each operation, I changed the unit cube to better visualise what the first iteration of the fractal looks like:

const c = translate(scale(cube('#88ccff'), 0.5, 0.5, 0.5), 0.25, 0.25, 0.25);

This is what I saw:

image

It would appear that the 2 circled portions of the fractal are actually 3 cubes stacked next to each other, and not a single cube. Perhaps that is causing the strangeness seen in the second iteration of the fractal.

Changing center_row to the following appears to fix the fractal (s instead of inner_row):

    const center_row = before_frac(f, 
                           s,
                           before(empty, 
                             s));

image

https://share.sourceacademy.org/lww29

Yes, correct. I found the bug too. Here is the correct program:

https://share.sourceacademy.org/lww29

So sorry for the confusion!