[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6400] fix affine transform, some cases were not han
From: |
Gautier Hattenberger |
Subject: |
[paparazzi-commits] [6400] fix affine transform, some cases were not handled |
Date: |
Fri, 12 Nov 2010 09:42:38 +0000 |
Revision: 6400
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6400
Author: gautier
Date: 2010-11-12 09:42:38 +0000 (Fri, 12 Nov 2010)
Log Message:
-----------
fix affine transform, some cases were not handled
Modified Paths:
--------------
paparazzi-software/trunk/sw/lib/ocaml/ocaml_tools.ml
Modified: paparazzi-software/trunk/sw/lib/ocaml/ocaml_tools.ml
===================================================================
--- paparazzi-software/trunk/sw/lib/ocaml/ocaml_tools.ml 2010-11-11
20:21:40 UTC (rev 6399)
+++ paparazzi-software/trunk/sw/lib/ocaml/ocaml_tools.ml 2010-11-12
09:42:38 UTC (rev 6400)
@@ -51,11 +51,26 @@
let regexp_plus_less = Str.regexp "[+-]"
let affine_transform = fun format ->
(* Split after removing blank spaces *)
- match Str.full_split regexp_plus_less (Str.global_replace (Str.regexp "[
\t]+") "" format) with
- [Str.Text a; Str.Delim "+" ; Str.Text b] -> float_of_string a,
float_of_string b
- | [Str.Text a; Str.Delim "-" ; Str.Text b] -> float_of_string a, -.
float_of_string b
- | [Str.Text a; Str.Delim "+"; Str.Delim "-" ; Str.Text b] -> float_of_string
a, -. float_of_string b
- | [Str.Text a] -> float_of_string a, 0.
+ let split = Str.full_split regexp_plus_less (Str.global_replace (Str.regexp
"[ \t]+") "" format) in
+ let first_sign = match List.hd split with
+ Str.Text _ | Str.Delim "+" -> 1.
+ | Str.Delim "-" -> -. 1.
+ | _ -> 0.
+ in
+ let second_sign = match split with
+ [_; Str.Delim "+"; _] | [_; _; Str.Delim "+"; _] -> 1.
+ | [_; Str.Delim "-"; _]
+ | [_; Str.Delim "+"; Str.Delim "-"; _]
+ | [_; _; Str.Delim "-"; _]
+ | [_; _; Str.Delim "+"; Str.Delim "-"; _] -> -1.
+ | _ -> 0.
+ in
+ match split with
+ [Str.Text a; _; Str.Text b]
+ | [_; Str.Text a; _; Str.Text b]
+ | [Str.Text a; _; _; Str.Text b]
+ | [_; Str.Text a; _; _; Str.Text b] -> first_sign *. float_of_string a,
second_sign *. float_of_string b
+ | [Str.Text a] | [_; Str.Text a] -> first_sign *. float_of_string a, 0.
| _ -> 1., 0.
(* Box-Muller transform to generate a normal distribution from a uniform one
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6400] fix affine transform, some cases were not handled,
Gautier Hattenberger <=