Re: [Inkscape-user] Extracting formulas from curves?
Felipe,
I have a statistical relationship in mind and I find it is convenient to use Inkscape to create the graphs of what I think it should look like under different conditions. Having done that, it would be nice to be able to extract the formula for each curve that I have drawn. The curve of the relationship that I am thinking of should have only a single y value for each x coordinate, so it should be a function.
Thanks,
Phil.
From: Felipe Sanches <felipe.sanches@...2592...> - 2009-01-30 02:02 well.. maybe.
it is a bezier curve. It is a parametric curve whose coordinates are defined by quadractic equations:
x(t) = a*t² + b*t + c y(t) = d*t² + e*t + f
finding the values of a,b,c,d,e and f involves looking at the coordinates of the control points of that curve and doing a bit of math
Not all bezier curves can be described as 1 parameter functions, though... I think that it is indeed possible to do that with the one you provided since it appears to have a single y value for each x coordinate, thus it satisfy the requirements to be called a function.
what are you trying to do with this math stuff?
On Thu, Jan 29, 2009 at 10:14 PM, Philip Rhoades <phil@...2593...> wrote:
People,
Is there a way of extracting the formula for the curve from the
attached svg
ie in something resembling a conventional y = f(x) format?
Thanks,
Phil.
-- Philip Rhoades
GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@...2593...
well... that curve looks like half of a gaussian curve. And people usually model things using gaussian ditributions in statistics.
On Fri, Jan 30, 2009 at 10:26 AM, Philip Rhoades <phil@...2067...> wrote:
Felipe,
I have a statistical relationship in mind and I find it is convenient to use Inkscape to create the graphs of what I think it should look like under different conditions. Having done that, it would be nice to be able to extract the formula for each curve that I have drawn. The curve of the relationship that I am thinking of should have only a single y value for each x coordinate, so it should be a function.
Thanks,
Phil.
From: Felipe Sanches <felipe.sanches@...2592...> - 2009-01-30 02:02 well.. maybe.
it is a bezier curve. It is a parametric curve whose coordinates are defined by quadractic equations:
x(t) = a*t² + b*t + c y(t) = d*t² + e*t + f
finding the values of a,b,c,d,e and f involves looking at the coordinates of the control points of that curve and doing a bit of math
Not all bezier curves can be described as 1 parameter functions, though... I think that it is indeed possible to do that with the one you provided since it appears to have a single y value for each x coordinate, thus it satisfy the requirements to be called a function.
what are you trying to do with this math stuff?
On Thu, Jan 29, 2009 at 10:14 PM, Philip Rhoades <phil@...2593...> wrote:
People,
Is there a way of extracting the formula for the curve from the
attached svg
ie in something resembling a conventional y = f(x) format?
Thanks,
Phil.
-- Philip Rhoades
GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@...2593...
-- Philip Rhoades
GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@...2067...
This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Felipe,
That was just an example - I think the family of curves are more likely to look like the attached - it would be nice if there was some automatic equation extraction method . .
Thanks,
Phil.
Felipe Sanches wrote:
well... that curve looks like half of a gaussian curve. And people usually model things using gaussian ditributions in statistics.
On Fri, Jan 30, 2009 at 10:26 AM, Philip Rhoades <phil@...2067...> wrote:
Felipe,
I have a statistical relationship in mind and I find it is convenient to use Inkscape to create the graphs of what I think it should look like under different conditions. Having done that, it would be nice to be able to extract the formula for each curve that I have drawn. The curve of the relationship that I am thinking of should have only a single y value for each x coordinate, so it should be a function.
Thanks,
Phil.
From: Felipe Sanches <felipe.sanches@...2592...> - 2009-01-30 02:02 well.. maybe.
it is a bezier curve. It is a parametric curve whose coordinates are defined by quadractic equations:
x(t) = a*t² + b*t + c y(t) = d*t² + e*t + f
finding the values of a,b,c,d,e and f involves looking at the coordinates of the control points of that curve and doing a bit of math
Not all bezier curves can be described as 1 parameter functions, though... I think that it is indeed possible to do that with the one you provided since it appears to have a single y value for each x coordinate, thus it satisfy the requirements to be called a function.
what are you trying to do with this math stuff?
On Thu, Jan 29, 2009 at 10:14 PM, Philip Rhoades <phil@...2593...> wrote:
People,
Is there a way of extracting the formula for the curve from the
attached svg
ie in something resembling a conventional y = f(x) format?
Thanks,
Phil.
-- Philip Rhoades
GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@...2593...
-- Philip Rhoades
GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@...2067...
This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
I believe what you are looking for is either called "curve fitting" or "regression analysis" software.
You would just need to render the svg to a series of X/Y points and run them through this type of software to get a best fit equation (depending on the curve family chosen, of course)
-Rob A>
Rob,
Thanks for note - I will check them out but I thought it should be possible to use the information in the .svg file - as long as the curve is a fn, then the formula should be able to be determined . .
Regards,
Phil.
Rob Antonishen wrote:
I believe what you are looking for is either called "curve fitting" or "regression analysis" software.
You would just need to render the svg to a series of X/Y points and run them through this type of software to get a best fit equation (depending on the curve family chosen, of course)
-Rob A>
David,
Thanks for the note. Software exists that solves simultaneous quadratic equations - has anyone tried to interface stuff like that to info for a single segment in a .svg file? - I couldn't find anything . .
Regards,
Phil.
David Gressett wrote:
The two Bezier quadratics that you could extract from the Inkscape file (assuming that the curve representing the function is a single Bezier curve segment) contain all the information that you need. You need to look for "simultaneous quadratic equations". If your curve is in multiple segments, each segment will have to be solved separately, and each segment will have to be represented as a separate y=f(x) function.
Philip Rhoades wrote:
Rob,
Thanks for note - I will check them out but I thought it should be possible to use the information in the .svg file - as long as the curve is a fn, then the formula should be able to be determined . .
Regards,
Phil.
Rob Antonishen wrote:
I believe what you are looking for is either called "curve fitting" or "regression analysis" software.
You would just need to render the svg to a series of X/Y points and run them through this type of software to get a best fit equation (depending on the curve family chosen, of course)
-Rob A>
The two Bezier quadratics that you could extract from the Inkscape file (assuming that the curve representing the function is a single Bezier curve segment)
I am not entirely clear on which way the data is flowing here. Are you trying to do a curve-fit to an existing curve (not in Inkscape) and then subsequently represent it in svg, or are you drawing a curve in svg and then trying to represent it as f(x)?
In any event, just quick comment. The typical svg path element is a cubic Bezier which can only be represented parametrically as a function of t, not as an explicit f(x) relationship. However, there is a subset that might be interesting to look at. If you take a cubic Bezier curve and force the 4 control points to be equally spaced in the x axis, then what happens is that x(t) becomes linear and y(t) remains cubic. So you now have an explicit function y(x) which is still SVG-compatible, and is a cubic polynomial. So you could do a standard curve fit using cubic polynomials, and still be able to represent the result in svg.
Alvin,
Alvin Penner wrote:
The two Bezier quadratics that you could extract from the Inkscape file (assuming that the curve representing the function is a single Bezier curve segment)
I am not entirely clear on which way the data is flowing here. Are you trying to do a curve-fit to an existing curve (not in Inkscape) and then subsequently represent it in svg, or are you drawing a curve in svg and then trying to represent it as f(x)?
Yes.
In any event, just quick comment. The typical svg path element is a cubic Bezier which can only be represented parametrically as a function of t, not as an explicit f(x) relationship. However, there is a subset that might be interesting to look at. If you take a cubic Bezier curve and force the 4 control points to be equally spaced in the x axis, then what happens is that x(t) becomes linear and y(t) remains cubic. So you now have an explicit function y(x) which is still SVG-compatible, and is a cubic polynomial. So you could do a standard curve fit using cubic polynomials, and still be able to represent the result in svg.
That is exactly what I would like to do! - with other software available this should not be hard? For the particular case I am thinking of, the quadratic would be sufficient. What would be nice is to be able to extract this equation directly from Inkscape . .
Regards,
Phil.
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
now it seems it is just a matter of writing an inkscape extension...
On Sat, Jan 31, 2009 at 10:05 AM, Alvin Penner <penner@...2467...> wrote:
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
-- View this message in context: http://www.nabble.com/eraser-tool-opinions--tp21675675p21762725.html Sent from the Inkscape - User mailing list archive at Nabble.com.
This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
Felipe,
Good idea - I'll have a look at that . .
Thanks to all for comments!
Regards,
Phil.
Felipe Sanches wrote:
now it seems it is just a matter of writing an inkscape extension...
On Sat, Jan 31, 2009 at 10:05 AM, Alvin Penner <penner@...2467...> wrote:
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
-- View this message in context: http://www.nabble.com/eraser-tool-opinions--tp21675675p21762725.html Sent from the Inkscape - User mailing list archive at Nabble.com.
This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
On Sun, 01 Feb 2009 06:12:45 +1100, Philip Rhoades wrote:
Felipe,
Good idea - I'll have a look at that . .
Thanks to all for comments!
Regards,
Phil.
Felipe Sanches wrote:
now it seems it is just a matter of writing an inkscape extension...
On Sat, Jan 31, 2009 at 10:05 AM, Alvin Penner <penner@...2467...> wrote:
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
Except neither the x nor the y points are equally spaced, so neither will be a linear mapping of t.
--hendrik
On Sun, Mar 15, 2009 at 09:07:53PM -0600, Carl D. Sorensen wrote:
On 3/15/09 6:27 PM, "Hendrik Boom" <hendrik@...2611...> wrote:
On Sun, 01 Feb 2009 06:12:45 +1100, Philip Rhoades wrote:
Felipe,
Good idea - I'll have a look at that . .
Thanks to all for comments!
Regards,
Phil.
Felipe Sanches wrote:
now it seems it is just a matter of writing an inkscape extension...
On Sat, Jan 31, 2009 at 10:05 AM, Alvin Penner <penner@...2467...> wrote:
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
Except neither the x nor the y points are equally spaced, so neither will be a linear mapping of t.
From what I know, equal spacing on x is only necessary if you want to have
an easy way of writing y=f(x), instead of y=f1(t), x=f2(t), with t going from 0 to 1.
Yes, exactly. But I think that that's what the OP asked for. Maybe maybe he'll accept this instead.
-- hendrik
On 3/15/09 6:27 PM, "Hendrik Boom" <hendrik@...2611...> wrote:
On Sun, 01 Feb 2009 06:12:45 +1100, Philip Rhoades wrote:
Felipe,
Good idea - I'll have a look at that . .
Thanks to all for comments!
Regards,
Phil.
Felipe Sanches wrote:
now it seems it is just a matter of writing an inkscape extension...
On Sat, Jan 31, 2009 at 10:05 AM, Alvin Penner <penner@...2467...> wrote:
the equations that you need to use are given at : http://en.wikipedia.org/wiki/B%C3%A9zier_curve In order to implement these equations you'll need the control points. For example, in the file tst.svg, the four control points are : point 1 = (481.42857,378.07647) point 2 = (284.28571,378.07647) point 3 = (377.14286,632.36218 point 4 = (280,633.79076)
Except neither the x nor the y points are equally spaced, so neither will be a linear mapping of t.
From what I know, equal spacing on x is only necessary if you want to have
an easy way of writing y=f(x), instead of y=f1(t), x=f2(t), with t going from 0 to 1.
Carl
participants (8)
-
unknown@example.com
-
Alvin Penner
-
Carl D. Sorensen
-
David Gressett
-
Felipe Sanches
-
Hendrik Boom
-
Philip Rhoades
-
Rob Antonishen