[Fawkes Git] branch/tneumann/angle_distance_fix: mathext: fixed angle_distance for values >2pi

Tobias Neumann tobias.neumann at alumni.fh-aachen.de
Tue Feb 9 23:55:14 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, tneumann/angle_distance_fix has been updated
        to  c4a99d154657d9a7284be18813f6c0a330578fa9 (commit)
      from  636d76b2640a90582006efe163e47c08ed5cc919 (commit)

http://git.fawkesrobotics.org/fawkes.git/tneumann/angle_distance_fix

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit c4a99d154657d9a7284be18813f6c0a330578fa9
Author:     Tobias Neumann <t.neumann at fh-aachen.de>
AuthorDate: Tue Feb 9 23:49:55 2016 +0100
Commit:     Tobias Neumann <t.neumann at fh-aachen.de>
CommitDate: Tue Feb 9 23:49:55 2016 +0100

    mathext: fixed angle_distance for values >2pi
    
    since a discussion about the cpp version of this function this shortens
    the code and enables the function to work with values grater than 2pi.
    Thanks to Bahram Maleki-Fard for introducing this short version of this
    function.

http://git.fawkesrobotics.org/fawkes.git/commit/c4a99d1
http://trac.fawkesrobotics.org/changeset/c4a99d1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/lua/fawkes/mathext.lua |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* c4a99d154657d9a7284be18813f6c0a330578fa9 - - - - - - - - - -
Author:  Tobias Neumann <t.neumann at fh-aachen.de>
Date:    Tue Feb 9 23:49:55 2016 +0100
Subject: mathext: fixed angle_distance for values >2pi

 src/lua/fawkes/mathext.lua |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

_Diff for modified files_:
diff --git a/src/lua/fawkes/mathext.lua b/src/lua/fawkes/mathext.lua
index af2eabe..3e3a16c 100644
--- a/src/lua/fawkes/mathext.lua
+++ b/src/lua/fawkes/mathext.lua
@@ -62,18 +62,12 @@ function math.normalize_mirror_rad(angle_rad)
 end
 
 --- Determines the distance between two angle provided as radians. 
---  Quadrants of the angles are considered to determine really the minimal
---  angle difference.
 --  @param angle_rad1 first angle in radian
 --  @param angle_rad2 second angle in radian
 --  @return distance between the two angles
 --
 function math.angle_distance(angle_rad1, angle_rad2)
-  if(angle_rad2 > angle_rad1) then
-    return angle_rad2 - angle_rad1 < math.pi and angle_rad2 - angle_rad1 or - 2.0 * math.pi + angle_rad2 - angle_rad1;
-  else
-    return angle_rad1 - angle_rad2 < math.pi and angle_rad2 - angle_rad1 or   2.0 * math.pi - angle_rad1 + angle_rad2;
-  end
+  return math.abs( math.normalize_mirror_rad(angle_rad1 - angle_rad2) )
 end
 
 --- Get algebraic sign (-1 or +1)




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list