Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(241)

Delta Between Two Patch Sets: lily/bezier.cc

Issue 5626052: Gets vertical skylines from grob stencils (Closed)
Left Patch Set: Created 13 years, 1 month ago
Right Patch Set: Run astyle on c++ files Created 12 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lily/beam.cc ('k') | lily/clef.cc » ('j') | lily/skyline.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 1998--2012 Jan Nieuwenhuizen <janneke@gnu.org> 4 Copyright (C) 1998--2012 Jan Nieuwenhuizen <janneke@gnu.org>
5 5
6 LilyPond is free software: you can redistribute it and/or modify 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 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 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 tj *= t; 132 tj *= t;
133 } 133 }
134 134
135 #ifdef PARANOID 135 #ifdef PARANOID
136 assert (fabs (o[X_AXIS] - polynomial (X_AXIS).eval (t)) < 1e-8); 136 assert (fabs (o[X_AXIS] - polynomial (X_AXIS).eval (t)) < 1e-8);
137 assert (fabs (o[Y_AXIS] - polynomial (Y_AXIS).eval (t)) < 1e-8); 137 assert (fabs (o[Y_AXIS] - polynomial (Y_AXIS).eval (t)) < 1e-8);
138 #endif 138 #endif
139 139
140 return o; 140 return o;
141 }
142
143 Real
144 Bezier::slope_at_point (Real t) const
145 {
146 Offset second_order[3];
147 Offset third_order[2];
148
149 for (vsize i = 0; i < 3; i++)
150 second_order[i] = ((control_[i + 1] - control_[i]) * t) + control_[i];
151
152 for (vsize i = 0; i < 2; i++)
153 third_order[i] = ((second_order[i + 1] - second_order[i]) * t) + second_orde r[i];
154
155 if (third_order[1][X_AXIS] - third_order[0][X_AXIS] == 0)
156 return infinity_f;
157
158 return (third_order[1][Y_AXIS] - third_order[0][Y_AXIS]) / (third_order[1][X_A XIS] - third_order[0][X_AXIS]);
141 } 159 }
142 160
143 /* 161 /*
144 Cache binom (3, j) t^j (1-t)^{3-j} 162 Cache binom (3, j) t^j (1-t)^{3-j}
145 */ 163 */
146 struct Polynomial_cache 164 struct Polynomial_cache
147 { 165 {
148 Polynomial terms_[4]; 166 Polynomial terms_[4];
149 Polynomial_cache () 167 Polynomial_cache ()
150 { 168 {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 else 395 else
378 subdivide (t_min, &bez1, &bez2); 396 subdivide (t_min, &bez1, &bez2);
379 if (t_max == 1.0) 397 if (t_max == 1.0)
380 return bez2; 398 return bez2;
381 else 399 else
382 { 400 {
383 bez2.subdivide ((t_max - t_min) / (1 - t_min), &bez3, &bez4); 401 bez2.subdivide ((t_max - t_min) / (1 - t_min), &bez3, &bez4);
384 return bez3; 402 return bez3;
385 } 403 }
386 } 404 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b