def weight

bend-visgraph@2.0.0.0 · visgraph.bend:112

import bend-visgraph@2.0.0.0/visgraph.bend as Visgraph
import Base

112def weight(+k: Weight, +x1: F32, +x2: F32, +y1: F32, +y2: F32, +s: F32) -> F32:
113  match k:
114    case Unweighted{}:
115      0.0
116    case Distance{}:
117      F32.sqrt(sq_distance(x1, x2, y1, y2))
118    case SqDistance{}:
119      sq_distance(x1, x2, y1, y2)
120    case VDistance{}:
121      F32.sub(y2, y1)
122    case AbsVDistance{}:
123      F32.abs(F32.sub(y2, y1))
124    case HDistance{}:
125      F32.sub(x2, x1)
126    case AbsHDistance{}:
127      F32.abs(F32.sub(x2, x1))
128    case Slope{}:
129      known_slope(s, x1, x2, y1, y2)
130    case AbsSlope{}:
131      F32.abs(known_slope(s, x1, x2, y1, y2))
132    case Angle{}:
133      F32.atan(known_slope(s, x1, x2, y1, y2))
134    case AbsAngle{}:
135      F32.atan(F32.abs(known_slope(s, x1, x2, y1, y2)))
136    case NumPenetrations{}:
137      0.0

Uses (8)

Used by (2)