]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/spring.hh
ce3dbfd93b8bf16e779d21d9ece71d9090feea10
[lilypond.git] / lily / include / spring.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef SPRING_HH
21 #define SPRING_HH
22
23 #include "lily-proto.hh"
24 #include "smobs.hh"
25
26 class Spring : public Simple_smob<Spring>
27 {
28 public:
29   static SCM equal_p (SCM, SCM);
30   static const char type_p_name_[];
31 private:
32   Real distance_;
33   Real min_distance_;
34
35   Real inverse_stretch_strength_;
36   Real inverse_compress_strength_;
37
38   Real blocking_force_;
39
40   void update_blocking_force ();
41
42 public:
43   Spring ();
44   Spring (Real distance, Real min_distance);
45
46   Real distance () const {return distance_;}
47   Real min_distance () const {return min_distance_;}
48   Real inverse_stretch_strength () const {return inverse_stretch_strength_;}
49   Real inverse_compress_strength () const {return inverse_compress_strength_;}
50   Real blocking_force () const {return blocking_force_;}
51
52   Real length (Real f) const;
53
54   void set_distance (Real);
55   void set_min_distance (Real);
56   void ensure_min_distance (Real);
57   void set_inverse_stretch_strength (Real);
58   void set_inverse_compress_strength (Real);
59   void set_blocking_force (Real);
60   void set_default_strength ();
61   void set_default_compress_strength ();
62   void set_default_stretch_strength ();
63
64   void operator *= (Real);
65   bool operator > (Spring const &) const;
66 };
67
68 Spring merge_springs (vector<Spring> const &springs);
69
70 #endif /* SPRING_HH */