Commits

bergsoe  committed a530584

Interface cleanup for the spatial configuration configuration types.

  • Participants
  • Parent commits ab311dc

Comments (0)

Files changed (2)

File src/PaplSBLExpandSampler.ml

                   stop ()
           in
             BatEnum.from next
+
+    let uniform_standard ?rng n outer_box offset =
+      let inner_boxes = standard_boxes_by_offset n offset in
+        uniform_within_boxes ?rng outer_box inner_boxes
   end
 
   module V3D = struct
                   stop ()
           in
             BatEnum.from next
+
+    let uniform_standard ?rng n outer_box offset =
+      let inner_boxes = standard_boxes_by_offset n offset in
+        uniform_within_boxes ?rng outer_box inner_boxes
   end
 
   module I2D = struct
                   | Some q -> q
           in
             BatEnum.from next
+
+    let uniform_standard ?rng n offset =
+      uniform_within_boxes
+        ?rng
+        (fun a -> Some (PaplTransform.SO2.rotate a))
+        (standard_boxes_by_offset n offset)
   end
 
+  let make_se get make make_pos make_rot = (); fun q ->
+    let (pos, rot) = get q in
+      BatEnum.map
+        (fun (t, r) -> make t r)
+        (BatEnum.combine
+           (make_pos pos, make_rot rot))
+
   module SE2 = struct
     type t = PaplTransform.SE2.t
     type pos_box_t = PaplVector.V2D.t * PaplVector.V2D.t
 
     module SE = PaplTransform.SE2
 
-    let uniform_within_boxes
-        ?rng
-        outer_pos_box inner_pos_boxes
-        accept_angle inner_angle_boxes =
-      let make_pos_sampler =
-        V2D.uniform_within_boxes ?rng outer_pos_box inner_pos_boxes in
-      let make_rot_sampler =
-        SO2.uniform_within_boxes ?rng accept_angle inner_angle_boxes in
-      let make_sampler q =
-        let (pos, rot) = SE.get q in
-          BatEnum.map
-            (fun (t, r) -> SE.make t r)
-            (BatEnum.combine
-               (make_pos_sampler pos, make_rot_sampler rot))
-      in make_sampler
+    let make make_pos make_rot =
+      make_se SE.get SE.make make_pos make_rot
   end
 
   module SO3 = struct
+    type t = PaplTransform.SO3.t
+    type box_t = float * float
+
     module SO = PaplTransform.SO3
 
+    let standard_offsets ?rng n offset =
+      BatArray.of_enum
+        (BatEnum.take n
+           (BatEnum.from_loop 1.0
+              (fun n ->
+                 let s = 1.0 /. n in
+                   (s *. offset, n +. 1.))))
+
     let uniform_within_boxes ?rng accept offsets =
       let generators =
         BatArray.map
                in
                  SO.mul rot step)
             (BatArray.enum generators)
+
+    let uniform_standard ?rng n offset =
+      uniform_within_boxes
+        ?rng
+        (fun _ -> true)
+        (standard_offsets n offset)
   end
 
   module SE3 = struct
 
     module SE = PaplTransform.SE3
 
-    let uniform_within_boxes
-        ?rng
-        outer_pos_box inner_pos_boxes accept_angle angle_offsets =
-      let make_pos_sampler =
-        V3D.uniform_within_boxes ?rng outer_pos_box inner_pos_boxes in
-      let make_rot_sampler =
-        SO3.uniform_within_boxes ?rng accept_angle angle_offsets in
-      let make_sampler q =
-        let (pos, rot) = SE.get q in
-          BatEnum.map
-            (fun (t, r) -> SE.make t r)
-            (BatEnum.combine
-               (make_pos_sampler pos, make_rot_sampler rot))
-      in make_sampler
+    let make make_pos make_rot =
+      make_se SE.get SE.make make_pos make_rot
   end
 
   module Time = struct

File src/PaplSBLExpandSampler.mli

-(** SBL extension samplers
+(** SBL expansion samplers
 
     This module constructs samplers that return configurations within the
     vicinity of some configuration.
 
     val uniform_within_boxes :
       ?rng:rng_t -> box_t -> box_t array -> t expand_sampler_t
+
+    val uniform_standard :
+      ?rng:rng_t -> int -> box_t -> t -> t expand_sampler_t
+  end
+
+  module V3D : sig
+    type t = PaplVector.V3D.t
+    type box_t = t * t
+
+    val standard_boxes : int -> box_t -> box_t array
+      (** [standard_boxes n box] is an array of [n] boxes [\[ box(1); box(2); ...;
+          box(n)\]] where [box(i)] is equal to [box] scaled by [1 / i].
+      *)
+
+    val standard_boxes_by_offset : int -> t -> box_t array
+      (** [standard_boxes_by_offset n vec] is equivalent to
+          [standard_boxes n (neg v, v)].
+      *)
+
+    val uniform_within_boxes :
+      ?rng:rng_t -> box_t -> box_t array -> t expand_sampler_t
+
+    val uniform_standard :
+      ?rng:rng_t -> int -> box_t -> t -> t expand_sampler_t
   end
 
   module I2D : sig
       (float -> 'a option) ->
       box_t array ->
       t -> 'a BatEnum.t
+
+    val uniform_standard : ?rng:rng_t -> int -> float -> t expand_sampler_t
+  end
+
+  module SO3 : sig
+    type t = PaplTransform.SO3.t
+    type box_t = float * float
+
+    val standard_offsets : ?rng:rng_t -> int -> float -> float array
+
+    val uniform_within_boxes :
+      ?rng:rng_t ->
+      (t -> bool) ->
+      float array ->
+      t expand_sampler_t
+
+    val uniform_standard : ?rng:rng_t -> int -> float -> t expand_sampler_t
   end
 
   module SE2 : sig
     type pos_box_t = PaplVector.V2D.t * PaplVector.V2D.t
     type rot_box_t = float * float
 
-    val uniform_within_boxes :
-      ?rng:rng_t ->
-      pos_box_t ->
-      pos_box_t array ->
-      (float -> PaplTransform.SO2.t option) ->
-      rot_box_t array ->
+    val make :
+      V2D.t expand_sampler_t ->
+      SO2.t expand_sampler_t ->
       t expand_sampler_t
-  (** [uniform_within_boxes outer_pos_box inner_pos_boxes accept_angle
-      inner_angle_boxes]
-  *)
   end
 
   module SE3 : sig
     type t = PaplTransform.SE3.t
     type pos_box_t = PaplVector.V3D.t * PaplVector.V3D.t
 
-    val uniform_within_boxes :
-      ?rng:rng_t ->
-      pos_box_t ->
-      pos_box_t array ->
-      (PaplTransform.SO3.t -> bool) ->
-      float array ->
+    val make :
+      V3D.t expand_sampler_t ->
+      SO3.t expand_sampler_t ->
       t expand_sampler_t
-  (** [uniform_within_boxes
-      outer_pos_box inner_pos_boxes
-      accept_angle angle_offsets]
-  *)
   end
 
   module Time : sig