To comment on the following update, log in, then open the issue: http://www.openoffice.org/issues/show_bug.cgi?id=72216 Issue #|72216 Summary|in XY chart do not sort x-values for B-splines Component|Chart Version|OOo 2.1 Platform|PC URL| OS/Version|Windows XP Status|UNCONFIRMED Status whiteboard| Keywords| Resolution| Issue type|ENHANCEMENT Priority|P3 Subcomponent|code Assigned to|kla Reported by|regina
------- Additional comments from [EMAIL PROTECTED] Sat Dec 2 15:13:15 -0800 2006 ------- If you use the variant B-Spline in an XY chart, then the points are sorted. Therefor you cannot draw curves, which turn back. But I think, that it is not necessary to sort the points. Please have a look at http://www.apm.tuwien.ac.at/docs/lva/mmgdv/k1___014.htm (German). There you find a description, how to calculate B-Spline curves without sorting the control points. Based on that text I try to describe, how I think it might work. I cannot write C++ and do not know about all the stuff in the source, so I will use pseudo code. I refer to graphics/chart2/source/view/charttypes/Splines.cxx /*I use the names as in the function CalculateBSplines. I comment them, so that you can control, whether I understand them correct: nDegree is the order of the B-splines in mathematical sense. It is 1 higher than the value from the input field “Data points order”. */ nDegree = nDegree + 1; /*The control points are in rInput. They come from the data points which the user specifies. I write it so as if they are indexed from 0 to n in the order they are written in the data series. It should be sure, that each control point is a point and no x-value and no y-value is missing. */ // calculate n n = rInput.SequenceX[0].getLength()-1;//maximum index of control points /* nNewSectorCount gives the number of lines, which will build the polyline which interpolates the B-spline curve. nGranularity is the value from the input field “Resolution”. */ nNewSectorCount = nGranularity * n; // t is the node vector const double* t = createTVector(n, nDegree); /* b will contain function values of the blending functions for a specific argument x. b will have indexes from 0 to n+nDegree. Most of the values in b are zero. You need only values from index i0-nDegree+1 to i0, where i0 is that index for with x is in the interval [t[i0];t[i0+1][. */ double *b = new double [n + nDegree + 1]; /* The arguments x must be in [0; n-nDegree+2]. The number of arguments must be nNewSectorCount+1. I will use ib to count the arguments. For each argument x you get a point. Later on you will draw connection lines between this points. Therefor you need a vector or an array (or how you call it) with index ib from 0 to nNewSectorCount to store the points. I will name it BSplinePoint here. */ xStep = (n - nDegree + 2.0) / nNewSectorCount; x = 0.0; //later on it will be increased by xStep for (ib = 0; ib <= nNewSectorCount; ib ++) { // Calculate the values of the blending functions for this special x value BVector(x, n, nDegree, b, t); /* Calculate the B-spline point with index ib. It is a sum. For the boundaries of the sum you need the value i0 like that in function BVector. */ i0 = floor(x) + nDegree – 1; /* Can you multiply a point as a whole with a number? I write it here for each coordinate.*/ // initialize sum with zero BSplinePoint[ib].xcoordinate = 0.0 BSplinePoint[ib].ycoordinate = 0.0 //summarize for (i = i0-nDegree+1; i <= i0; i ++) { BSplinePoint[ib].xcoordinate = BSplinePoint[ib].xcoordinate+ rInput[i].xcoordinate *b[i] BSplinePoint[ib].ycoordinate = BSplinePoint[ib].ycoordinate+ rInput[i].ycoordinate *b[i] } //next value for x x = x+xStep //next value for ib is automatically generated by the loop } /*Now you have got a vector of points, which are points of the B-spline curve. With this points you can draw a polyline, like you would do, if an user chooses the not smoothed variant line in the XY chart. */ ================ In addition: If the text, which I mentioned, is right, then I think you can improve this: In function BVector goto the loops for( sal_Int32 j=2; j<=k; j++ ) for( i=0; i<=i0; i++ ) b[i] = TLeft(x, i, j, t) * b[i] + TRight(x, i, j, t) * b [i + 1]; } I think, that in the inner loop you need not to start with i=0, but you can start with i=i0-j+1, because the other values of b[] are zero. --------------------------------------------------------------------- Please do not reply to this automatically generated notification from Issue Tracker. Please log onto the website and enter your comments. http://qa.openoffice.org/issue_handling/project_issues.html#notification --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
