Filling parametric curves

Post questions on how to use or achieve an effect in Inkscape.
User avatar
HisDudeness
Posts: 4
Joined: Sat Jan 25, 2014 2:48 am
Location: Italy

Filling parametric curves

Postby HisDudeness » Tue Jan 28, 2014 1:20 am

Hi everyone! What I'm trying to do is draw the domain of a bi-dimensional integration, and emphasize it.

The method I'm trying to use to achieve this result is drawing the parametric curves delimiting it, along with the Cartesian axes, and then filling the area included by their combination, either with a solid color or a pattern.

The problem I'm getting, as you will notice yourself by opening my svg, is the areas inside the curves have got some regions that won't be filled. There is an invisible, variable-sized border separating the internal sectors from the curves delimiting them. Especially in the zones where two curves intersect creating an angle, it's like the internal zone is a curve approximating it, while it get distant from the linear part.

Let's take a practical example. In this svg there is the first domain I'm trying to draw. It is described by the following equations:

Image

Which means I'm limited upwards by the parabola y=x^2-x, downwards by the straight line y=-x-(1/2), and left and right by the vertical lines x=1 and x=-1.

In this image (border set to zero) you can see how filling a sector of the area I'm interested to highlight leaves some empty spaces. Here I have zoomed the angle between the y-axis and the parabola, the point where the problems are more visible. I have a vertical empty space of less than 0.1pt along the y-axis (so, even setting the smallest border possible would eat the axis), a variable sized space along the parabola (so, trying to fill the biggest gap would eat all of the curve), and a really singular curve-to-straight angle which is impossible to fill without trespassing the borders.

Anyone can help me on this one?

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Filling parametric curves

Postby Lazur » Fri Jan 31, 2014 2:14 am

Welcome aboard!

I'm guessing you are trying to use the bucket fill tool.
What would solve your problem is, using the fill and stroke panel instead on closed paths.
So you would need to draw those objects first.
In your first image, combine (Ctrl+K) the duplicants (Ctrl+D) of the two paths together,
use the node editor tool to connect unconnected segments, and add a fill and no stroke to it with the panel (Shift+Ctrl+F).

Here is how it should look:
SVG Image

Good luck!
Last edited by Lazur URH on Sun Feb 02, 2014 8:08 pm, edited 1 time in total.

User avatar
HisDudeness
Posts: 4
Joined: Sat Jan 25, 2014 2:48 am
Location: Italy

Re: Filling parametric curves

Postby HisDudeness » Sun Feb 02, 2014 7:43 pm

Lazur URH wrote:Welcome aboard!

Thanks!

Lazur URH wrote:I'm guessing you are trying to use the bucket fill tool.

Yeah, sorry, didn't mention that, like it was obvious. I feel so paintbrush, thinking the only way to fill a closed area is the bucket... Guess I have to learn a lot about serious drawing software, learning how to draw a graph like the one I did in that svg already did cost me a lot of tries :lol:

Lazur URH wrote:What would solve your problem is, using the fill and stroke panel instead on closed paths.
So you would need to draw those objects first.
In your first image, combine (Ctrl+K) the duplicants (Ctrl+Shift+D) of the two paths together,
use the node editor tool to connect unconnected segments, and add a fill and no stroke to it with the panel (Shift+Ctrl+F).

Sorry, I'm not following you anymore here. Pardon my ignorance, what's a duplicant first of all? Also, Ctrl+Shift+D pops up the document proprieties to me.
And should I select the curves with node editor and then group them and fill? If I do that, only the area between the parabola and the segment going from its point A to its point C is filled...

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Filling parametric curves

Postby Lazur » Sun Feb 02, 2014 8:20 pm

Oh sorry it was getting late, it is really Ctrl+D.
Shift+Ctrl+D bbrings up the document's properties panel.

Combine them, and connect unconnected nodes.
There is an option of grouping in inkscape, but that won't help here.

Wasn't the question about filling that area?
If it was to fill between only X=[-1;1], then some node editing is necessary too.
First the parabola, the line, and the two vertical parts need to be duplicated, then
the right vertical path's bottom node moved down vertically until it intersects with the line below, then
new nodes to be added to the parabola near the intersection points,
snapping those to the vertical line's intersection points,
combining the four paths together, connecting unconnected nodes and deleting unnecessary ones.
Easier to be done than to be explained.

User avatar
HisDudeness
Posts: 4
Joined: Sat Jan 25, 2014 2:48 am
Location: Italy

Re: Filling parametric curves

Postby HisDudeness » Wed Feb 05, 2014 12:08 am

SVG Image

Well, that worked like a charm. It was instructive too, I had to learn how to connect two paths by fusing their endnodes and add nodes to a curve until it gets one on the endnode of another curve it intersects. Sure it is quite an elaborate way, a little approximate too doing it by hand. I think an extension to automatically fill the area enclosed by some separate intersecting path would be very useful, ad not impossible to do. If I knew how to do it I'd implement it myself, but I'm as ignorant as a goat as far as programming go.

Thanks a lot for your time, you completely solved my problem!

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Filling parametric curves

Postby ragstian » Wed Feb 05, 2014 3:41 pm

Hi

Just for fun I plotted the graph using nothing but Inkscape.
Plotted functions using - Render - Function Plot.
No split path to get the red area - just path difference (from a 2 x 4 unit rectangle).
No external programs used.

SVG Image

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar


Return to “Help with using Inkscape”