https://github.com/akkartik/mu/blob/main/linux/raytracing/ray.mu

     1 type ray {
     2   orig: vec3  # point
     3   dir: vec3
     4 }
     5
     6 # A little different from the constructor at https://raytracing.github.io/books/RayTracingInOneWeekend.html
     7 # We immediately normalize the direction vector so we don't have to keep doing
     8 # so.
     9 fn initialize-ray _self: (addr ray), o: (addr vec3), d: (addr vec3) {
    10   var self/esi: (addr ray) <- copy _self
    11   var dest/eax: (addr vec3) <- get self, orig
    12   copy-object o, dest
    13   dest <- get self, dir
    14   vec3-unit d, dest
    15 }
    16
    17 fn ray-at _self: (addr ray), t: float, out: (addr vec3) {
    18   var self/esi: (addr ray) <- copy _self
    19   var src/eax: (addr vec3) <- get self, dir
    20   copy-object src, out
    21   vec3-scale-up out, t
    22   src <- get self, orig
    23   vec3-add-to out, src
    24 }