]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/skyline.cc
* flower/file-path.cc:
[lilypond.git] / lily / skyline.cc
index 41aaa19039fa9a97eac3f76562e5e83bfca313a4..2ed56cd7e92dd2058875f76d3ca9c518497b0b67 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2002--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "skyline.hh"
   A skyline is a shape of the form:
 
 
-  ----
-  |  |
-  ---------|  |
-  |          |
-  |          |
-  |          |______
-  --------|                 |___
-
-
+  *                  ----
+  *                  |  |
+  *         ---------|  |
+  *         |           |
+  *         |           |
+  *         |          |______
+  * --------|                |___
+  *
 
   This file deals with building such skyline structure, and computing
   the minimum distance between two opposing skylines.
 
-
   Invariants for a skyline:
 
   skyline[...].width_ forms a partition of the real interval, where
@@ -183,3 +181,22 @@ heighten_skyline (Array<Skyline_entry> *buildings, Real ground)
   for (int i = 0; i < buildings->size (); i++)
     buildings->elem_ref (i).height_ += ground;
 }
+
+Real
+skyline_height (Array<Skyline_entry> const &buildings,
+               Real airplane,
+               Direction sky_dir)
+{
+  Real h = - sky_dir * infinity_f;
+
+  /*
+    Ugh! linear, should be O(log n).
+   */
+  for (int i = 0; i < buildings.size (); i++)
+    if (buildings[i].width_.contains (airplane))
+      h = sky_dir * max (sky_dir * h,
+                        sky_dir * buildings[i].height_);
+  
+  return h;
+}
+