d3 / d3-geo-polygon

Clipping and geometric operations for spherical polygons.
https://d3.observablehq.cloud/d3-geo-polygon/
Other
110 stars 22 forks source link

is it possible to only draw some of the faces? #62

Closed bathoorn closed 4 months ago

bathoorn commented 4 months ago

i can only draw the first face by setting .parents([-1])

but if i only wanted to draw for example the first 3 faces of a cube would that be possible?

i have this question as i like to laser cut the faces out of would an turn them into a globe. Drawing only a few faces would make it easier to fit on the laser cutter.

Fil commented 4 months ago

Yes, if you change parents you can make an incomplete tree; it still has to be a tree though.

bathoorn commented 4 months ago

so for the rombic i can do this rhombic.parents([-1, 0, 6, 2, 1, 9, 11, 3, 4, 8, 6, 10, ]) which will give me only the firtst 6 faces the rest are simply not connected to this

image

for the next 6 faces doing this rhombic_f.parents([4, 0, 6, 2, 1, 9, 11, 3, 4, 8, -1, 10, ]) result in this error: RangeError: Maximum call stack size exceeded. I must be doing something wrong there, but i can't seem to find what

the original parent list is this parents = [ -1, // 0 0, // 1 6, // 2 2, // 3 1, // 4 9, // 5 11, // 6 3, // 7 4, // 8 8, // 9 5, // 10 10, // 11 ];

bathoorn commented 4 months ago

oh i figured it out parent 0 is always the root and should have value -1

so i have to reorganize the faces for that to work

Fil commented 4 months ago

Yes—not super easy to manipulate, I agree.

bathoorn commented 4 months ago

Well it does what it is supposed to do really well. My use case is not really what it was made for. But it can be done.

I think this can be closed.

bathoorn commented 4 months ago

It works by reordering the faces.