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) "
+ "Springs have the format (ideal, inverse_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) "
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);
+ spacer.add_spring (ideal, inv_hooke);
}
for (SCM s = rods; scm_is_pair (s); s = scm_cdr (s))
Simple_spacer::solve (Real line_len, bool ragged)
{
Real conf = configuration_length (force_);
+ double inv_hooke = 0;
+ for (vsize i=0; i < springs_.size (); i++)
+ inv_hooke += springs_[i].inverse_hooke_;
ragged_ = ragged;
line_len_ = line_len;
- if (conf < line_len_)
+ if ((inv_hooke > 0) && (conf < line_len_))
force_ = expand_line ();
else if (conf > line_len_)
force_ = compress_line ();
`next-line' can be #f, meaning that `line' is the last line."
(let* ((title (paper-system-title? line))
(next-title (and next-line (paper-system-title? next-line))))
- (cond ((and title next-title)
- (ly:output-def-lookup layout 'between-title-space))
- (title
- (ly:output-def-lookup layout 'after-title-space))
- (next-title
- (ly:output-def-lookup layout 'before-title-space))
- (else
- (ly:prob-property
- line 'next-space
- (ly:output-def-lookup layout 'between-system-space))))))
+ (ly:prob-property
+ line 'next-space
+ (ly:output-def-lookup layout
+ (cond ((and title next-title) 'between-title-space)
+ (title 'after-title-space)
+ (next-title 'before-title-space)
+ (else 'between-system-space))))))
(define (line-next-padding line next-line layout)
"Return padding to use between `line' and `next-line'.
"Ideal distance between `line' reference position and `next-line'
reference position. If next-line is #f, return #f."
(and next-line
- (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
- (if ignore-padding 0 (line-next-padding line next-line layout)))
- (interval-start (paper-system-staff-extents line))))
- (line-next-space line next-line layout))))
+ (max (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
+ (if ignore-padding 0 (line-next-padding line next-line layout)))
+ (interval-start (paper-system-staff-extents line))))
+ (line-next-space line next-line layout))
+ (line-minimum-distance line next-line layout ignore-padding))))
(define (first-line-position line layout)
"Position of the first line on page"
'())))
(springs (map (lambda (prev-line line)
(list (line-ideal-distance prev-line line paper ignore-padding)
- (/ 1.0 (line-next-space prev-line line paper))))
+ (line-next-space prev-line line paper)))
lines
cdr-lines))
(rods (map (let ((i -1))