]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spring.cc
Issue 4636: lilypond-mode.el: consult LilyPond-lilypond-command et al at runtime
[lilypond.git] / lily / spring.cc
index f4123b9891527abc9c8633c7abe3f48a1c77fd6f..5dfc3c804ce1792612d3563deb695378ec687e5d 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2007--2014 Joe Neeman <joeneeman@gmail.com>
+  Copyright (C) 2007--2015 Joe Neeman <joeneeman@gmail.com>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@
 
 #include "spring.hh"
 
+using std::vector;
+
 Spring::Spring ()
 {
   distance_ = 1.0;
@@ -84,8 +86,8 @@ Spring::update_blocking_force ()
 void
 Spring::operator *= (Real r)
 {
-  distance_ = max (min_distance_, distance_ * r);
-  inverse_compress_strength_ = max (0.0, distance_ - min_distance_);
+  distance_ = std::max (min_distance_, distance_ * r);
+  inverse_compress_strength_ = std::max (0.0, distance_ - min_distance_);
   inverse_stretch_strength_ *= r;
   update_blocking_force ();
 }
@@ -111,13 +113,13 @@ merge_springs (vector<Spring> const &springs)
       avg_distance += springs[i].distance ();
       avg_stretch += springs[i].inverse_stretch_strength ();
       avg_compress += 1 / springs[i].inverse_compress_strength ();
-      min_distance = max (springs[i].min_distance (), min_distance);
+      min_distance = std::max (springs[i].min_distance (), min_distance);
     }
 
   avg_stretch /= Real (springs.size ());
   avg_compress /= Real (springs.size ());
   avg_distance /= Real (springs.size ());
-  avg_distance = max (min_distance + 0.3, avg_distance);
+  avg_distance = std::max (min_distance + 0.3, avg_distance);
 
   Spring ret = Spring (avg_distance, min_distance);
   ret.set_inverse_stretch_strength (avg_stretch);
@@ -153,7 +155,7 @@ Spring::set_min_distance (Real d)
 void
 Spring::ensure_min_distance (Real d)
 {
-  set_min_distance (max (d, min_distance_));
+  set_min_distance (std::max (d, min_distance_));
 }
 
 void
@@ -189,7 +191,6 @@ Spring::set_blocking_force (Real f)
 
   blocking_force_ = -infinity_f;
   min_distance_ = length (f);
-  distance_ = max (distance_, min_distance_);
   update_blocking_force ();
 }
 
@@ -216,7 +217,7 @@ Spring::set_default_stretch_strength ()
 Real
 Spring::length (Real f) const
 {
-  Real force = max (f, blocking_force_);
+  Real force = std::max (f, blocking_force_);
   Real inv_k = force < 0.0 ? inverse_compress_strength_ : inverse_stretch_strength_;
 
   if (isinf (force))
@@ -228,6 +229,6 @@ Spring::length (Real f) const
   // There is a corner case here: if min_distance_ is larger than
   // distance_ but the spring is fixed, then inv_k will be zero
   // and we need to make sure that we return min_distance_.
-  return max (min_distance_, distance_ + force * inv_k);
+  return std::max (min_distance_, distance_ + force * inv_k);
 }