Visgraph.first_half: def of bend-visgraph@2.0.0.0 Import: import bend-visgraph@2.0.0.0/visgraph.bend as Visgraph Lines 760-771 of bend-visgraph@2.0.0.0/visgraph.bend: https://jend.leeeet.dev/read.txt?path=bend-visgraph@2.0.0.0/visgraph.bend&start_line=760&end_line=771 import Base # How many of the first `count` of `len` points do half the sweeps' work. A # natural sweep walks every point right of its start, so the first c starts # walk c (2 len - 1 - c) / 2 points; a horizontal sweep stops early, so # halving the starts is close enough. def first_half(g: Visibility, +len: U32, +count: U32) -> U32: match g: case Natural{}: +b = F32.sub(F32.mul(2.0, U32.to_f32(len)), 1.0) +c = U32.to_f32(count) U32.min(count, F32.to_u32(F32.div(F32.sub(b, F32.sqrt(F32.sub(F32.mul(b, b), F32.mul(2.0, F32.mul(c, F32.sub(b, c)))))), 2.0))) case Horizontal{}: U32.div(count, 2) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sqrt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32.to_u32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_f32 https://jend.leeeet.dev/definition.txt?path=bend-visgraph@2.0.0.0/visgraph.bend&name=Visibility