1// module `package::util` (which shares its name with `fn util` declared in the2// root module: modules and declarations live in separate namespaces).4// importing from one's own submodule requires a package-anchored path.5import package::util::ops::double;7// module attribute: marks this module as designed for wildcard imports.8// TODO: wildcards9// @!wildcardable;11// package-visible (default): usable from any module of this package,12// but not across package boundaries and not re-exportable.13const EPSILON: f32 = 1e-5;15// private: visible only within this module.16private const INTERNAL_SCALE: f32 = 2.0;18// public: visible from any package, and re-exportable (see prelude.wesl).19public fn dot2(a: vec2f, b: vec2f) -> f32 {20 return a.x * b.x + a.y * b.y;21}23public fn cross2(a: vec2f, b: vec2f) -> f32 {24 return a.x * b.y - a.y * b.x;25}27// a public function may refer to less-visible items (EPSILON, INTERNAL_SCALE).28public fn norm2(a: vec2f) -> f32 {29 return sqrt(max(dot2(a, a), EPSILON)) * INTERNAL_SCALE / double(1.0);30}