How to specify a path as a mathematical function?

Post questions on how to use or achieve an effect in Inkscape.
dhfx
Posts: 2
Joined: Wed Aug 20, 2008 12:38 pm

How to specify a path as a mathematical function?

Postby dhfx » Wed Aug 20, 2008 12:53 pm

I need to do a technical figure showing a sinusoidal waveform plus some vertical and horizontal cursor lines and baselines. Is there any way to specify a line path in the shape of a sine function, multiplied by another function to give the effect of slowly-varying amplitude?

I would do it in Dia except there's no way AFAIK to get the sinusoid, other than importing a bitmap - but I want something scalable, to export the result as .emf for inclusion in a Word document.

I haven't yet tried generating a plot in Matlab and importing it, then tracing the curve. Has anyone successfully done this?

Thanks in advance for any helpful answers.


- dhfx

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: How to specify a path as a mathematical function?

Postby microUgly » Wed Aug 20, 2008 4:49 pm

I don't think defining mathematical graphs is possible in inkscape. I think hand tracing a bitmap might be your best bet. Although I wouldn't be surprised if MatLab could export to a vector format that could be used in Inkscape.

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: How to specify a path as a mathematical function?

Postby sas » Wed Aug 20, 2008 6:37 pm

Inkscape has a function plotter extension (Effects -> Render -> Function Plotter). The way it works is a bit strange (you have to select a rectangle for it to work on), but it should allow you to make a suitable path.

The version of this extension in Inkscape 0.46 has a serious flaw (the curve is misshapen if you specify a formula for the derivative), so you may need to download the latest version of funcplot.py from SVN.

dhfx
Posts: 2
Joined: Wed Aug 20, 2008 12:38 pm

Re: How to specify a path as a mathematical function?

Postby dhfx » Thu Aug 21, 2008 10:53 am

Thank you, I think the function plotter is what I'm looking for. Is there a good writeup anywhere on how to use it? I tried creating a rectangle but couldn't select it in a way that the function plotter would see.

User avatar
loonquawl
Posts: 135
Joined: Thu May 15, 2008 7:57 pm

Re: How to specify a path as a mathematical function?

Postby loonquawl » Thu Aug 21, 2008 5:43 pm

Should be sufficient to create a rectangle (must have fill and/or stroke visible). Then 'catch it' in a selection box and, for a test, use these values:
start x = 0
end x = 1
multiply.. =check
y value bottom = -1
y value top = 1
Samples = 20 (that is the number of nodes, higher = better)
Isotrop.. = uncheck
Use polar... = uncheck
Function = sin(x)
Calc first derivative numerically = check ( the nodes will then have handles that accord to the first derivative of the function at that point , meaning a smoother curve (an bad, bad errors if you have a complex formula and too few samples/nodes))
First derivative = Leave Blank
remove rectangle = uncheck
draw axes = uncheck
live preview = uncheck

-> then 'Apply'

racl101
Posts: 1
Joined: Wed Feb 10, 2010 8:07 am

Re: How to specify a path as a mathematical function?

Postby racl101 » Sat Feb 13, 2010 5:13 am

@loonqwal: Thanks a lot posting the parameters for plotting a simple sine wave. It was really useful to me.


Return to “Help with using Inkscape”