nsys-math-utils 0.9.0

Math types and traits
Documentation
macro_rules! impl_line_ray_common {
  ( $primitive:ident, $point:ident, $unit:ident, $affine:ident, $from:ident, $param:ty
  ) => {
    impl <S> $primitive <S> {
      #[inline]
      pub const fn new (base : $point <S>, direction : $unit <S>) -> Self {
        $primitive { base, direction }
      }

      #[inline]
      pub fn point (self, t : $param) -> $point <S> where S : Ring {
        self.base + *self.direction * t
      }

      #[inline]
      pub fn affine_line (self) -> frame::$affine <S> where S : Ring {
        frame::$affine {
          origin: self.base,
          basis:  self.direction.into()
        }
      }
    }
    impl <S : Real> Default for $primitive <S> {
      fn default() -> Self {
        $primitive {
          base:      $point::origin(),
          direction: $unit::axis_y()
        }
      }
    }
    impl <S> From <$from <S>> for $primitive <S> {
      fn from ($from { base, direction } : $from <S>) -> $primitive <S> {
        $primitive { base, direction }
      }
    }
  }
}