X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsimple-spacer-scheme.cc;h=7308de65846ea2b3c6fe4ec41dcee664d0a1378a;hb=51eff44c691a77454e01ffef7a444c42a287e37c;hp=2d702edcd0d2a30d8d308212d2efdd10a80a8b58;hpb=92918346012f79ef9109ef0c391947af2d3165ca;p=lilypond.git diff --git a/lily/simple-spacer-scheme.cc b/lily/simple-spacer-scheme.cc index 2d702edcd0..7308de6584 100644 --- a/lily/simple-spacer-scheme.cc +++ b/lily/simple-spacer-scheme.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2005--2007 Han-Wen Nienhuys + (c) 2005--2009 Han-Wen Nienhuys */ #include @@ -15,32 +15,40 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged), - "Solve a spring and rod problem for @var{count} objects, that " - "are connected by @var{count-1} springs, and an arbitrary number of rods " - "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) " - "@var{length} is a number, @var{ragged} a boolean " - "Return: a list containing the force (positive for stretching, " - "negative for compressing and #f for non-satisfied constraints) " - "followed by the @var{spring-count}+1 positions of the objects. ") + "Solve a spring and rod problem for @var{count} objects, that" + " are connected by @var{count}-1 @var{springs}, and an arbitrary" + " number of @var{rods}. @var{count} is implicitly given by" + " @var{springs} and @var{rods}. The @var{springs} argument has" + " the format @code{(ideal, inverse_hook)} and @var{rods} is of" + " the form @code{(idx1, idx2, distance)}.\n" + "\n" + "@var{length} is a number, @var{ragged} a boolean.\n" + "\n" + "The function returns a list containing the force (positive for" + " stretching, negative for compressing and @code{#f} for" + " non-satisfied constraints) followed by @var{spring-count}+1" + " positions of the objects.") { - LY_FUNC_NOTE_FIRST_ARG(springs); - int len = scm_ilength (springs); if (len == 0) return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0)); SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs"); SCM_ASSERT_TYPE (scm_ilength (rods) > 0, rods, SCM_ARG1, __FUNCTION__, "list of rods"); - LY_ASSERT_TYPE(scm_is_number, 3); + LY_ASSERT_TYPE (scm_is_number, length, 3); bool is_ragged = ragged == SCM_BOOL_T; Simple_spacer spacer; for (SCM s = springs; scm_is_pair (s); s = scm_cdr (s)) { Real ideal = scm_to_double (scm_caar (s)); - Real hooke = scm_to_double (scm_cadar (s)); + Real inv_hooke = scm_to_double (scm_cadar (s)); - spacer.add_spring (ideal, 1 / hooke); + Spring sp (ideal, 0.0); + sp.set_inverse_compress_strength (inv_hooke); + sp.set_inverse_stretch_strength (inv_hooke); + + spacer.add_spring (sp); } for (SCM s = rods; scm_is_pair (s); s = scm_cdr (s))