[goffice] Fixed closed bezier spline evaluation. [#646700]



commit 2e5ed71324cf5758e3cd8a9808351b9875e09457
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Apr 4 17:24:19 2011 +0200

    Fixed closed bezier spline evaluation. [#646700]

 ChangeLog                 |    5 +++++
 NEWS                      |    3 +++
 goffice/utils/go-bezier.c |    8 ++++----
 3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 34a56eb..8d685a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-04  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/utils/go-bezier.c (go_bezier_spline_init): fixed closed bezier
+	spline evaluation. [#646700]
+
 2011-03-28  Morten Welinder  <terra gnome org>
 
 	* goffice/utils/go-style.c (fill_init): Don't leak the size group.
diff --git a/NEWS b/NEWS
index 67995a9..b7a07b5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.8.15:
 
+Jean:
+	* Fixed closed bezier spline evaluation. [#646700]
+
 Morten:
 	* Plug leaks.
 
diff --git a/goffice/utils/go-bezier.c b/goffice/utils/go-bezier.c
index 7b4347e..0e4b04f 100644
--- a/goffice/utils/go-bezier.c
+++ b/goffice/utils/go-bezier.c
@@ -58,7 +58,7 @@ go_bezier_spline_init (double const *x, double const *y, int n, gboolean closed)
 
 	and in the closed case:
 
-	|4 1 ...              1||b[0]  |     |y[1]-y[n]    |
+	|4 1 ...              1||b[0]  |     |y[1]-y[n-1]  |
 	|1 4 1 ...             ||b[1]  |     |y[2]-y[0]    |
 	|0 1 4 1 ...           ||b[2]  |     |y[3]-y[1]    |
 	|0 0 1 4 1 ...         ||...   | = 3 |...          |
@@ -150,9 +150,9 @@ go_bezier_spline_init (double const *x, double const *y, int n, gboolean closed)
 		/* We can now evaluate b[0]:
 		 b[0]=c[0]*(c[1]*b[0]+d[1])+d[0]+e[0]*(c[m]*b[0]+d[m])
 		 which rearranges to:
-		 b[0]*(1-c[0]*c[1]-e[0]*c[m])=c[0]*c[1]+d[0]+e[0]*d[m]
+		 b[0]*(1-c[0]*c[1]-e[0]*c[m])=c[0]*d[1]+d[0]+e[0]*d[m]
 		*/
-		b[0] = (c[0] * c[1] + d[0] + e[0] * d[m]) / (1. - c[0] * c[1] - e[0] * c[m]);
+		b[0] = (c[0] * d[1] + d[0] + e[0] * d[m]) / (1. - c[0] * c[1] - e[0] * c[m]);
 
 		/* Replacing b[0] now gives the other b values */
 		for (i = 1; i < n; i++) {
@@ -191,7 +191,7 @@ go_bezier_spline_init (double const *x, double const *y, int n, gboolean closed)
 			d[i] = c[i] * d[i+1] + d[i] + e[i] * d[m];
 			c[i] = t;
 		}
-		b[0] = (c[0] * c[1] + d[0] + e[0] * d[m]) / (1. - c[0] * c[1] - e[0] * c[m]);
+		b[0] = (c[0] * d[1] + d[0] + e[0] * d[m]) / (1. - c[0] * c[1] - e[0] * c[m]);
 		for (i = 1; i < n; i++) {
 			b[i] = c[i] * b[0] + d[i];
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]