var ( steepDegrees = float64(18) steepRadians = steepDegrees * math.Pi / 180 steepSlope = math.Tan(steepRadians) steepSlopeSq = float32(steepSlope * steepSlope) ) func obstructed(obs []bool, pts [][3]float32, rings int) { var ( lo = 0 stop = len(pts) ) for lo < stop { obs[lo] = false var ( far = lo + 1 hi = lo + rings ) for ; far < hi; far++ { var ( x = pts[far][0] y = pts[far][1] z = pts[far][2] ) var ( steep = false near = lo ) for ; near < far; near++ { var ( dx = pts[near][0] - x dy = pts[near][1] - y dz = pts[near][2] - z ) var ( riseSq = dz * dz runSq = dx*dx + dy*dy ) if riseSq >= steepSlopeSq*runSq { steep = false break } } if steep { break } obs[far] = false } for ; far < hi; far++ { obs[far] = true } lo = hi } }
To receive a hint, submit unfixed code.