Commits

bergsoe committed ab311dc

A box_center utility method for vectors.

  • Participants
  • Parent commits 0419079

Comments (0)

Files changed (2)

File src/PaplVector.ml

   val scale : t -> t -> t
   val divide : float -> t -> t
   val unit : t -> t
+  val box_center : box_t -> t
 end
 
 module type DOT = sig
       else
         x /: len
 
+  let box_center (lower, upper) = 0.5 *: (lower +: upper)
+
 (* Space operations *)
 
   let interpolate a b =

File src/PaplVector.mli

 *)
 
   val unit : t -> t
+(** Scale a vector to unit length.
+
+    The length is measured by [dist2]. If the length of the vector is zero (or
+    very near zero), an exception is thrown.
+*)
+
+  val box_center : box_t -> t
+(** The center of a box.
+
+    The center of the box [(a, b)] is [0.5 *: (a +: b)].
+*)
 end
 
 module type DOT = sig