# [Numpy-discussion] Creating parallel curves

Andrea Gavana andrea.gavana@gmail....
Sun Feb 12 15:14:48 CST 2012

```Jonathan,

On 12 February 2012 21:59, Jonathan Hilmer wrote:
> Andrea,
>
> I realized that my answer wouldn't be complete, but as people have
> pointed out that's a substantially more difficult question, so I
> wanted to give you a complete answer to just a subset of your problem.
>
> I'm currently writing a variant that avoids the overlapping normal
> vectors by interatively 1.) expanding along normals then 2.)
> condensing points, for every iteration.  However, I'm doing it mostly
> for my own interest since I'm pretty sure it will not be functional
> when complete: your problem is that calculation of derivatives/normals
> is going to become unstable in acute convex regions, and the overlap
> issue there will become more severe.  I would strongly recommend
> adapting some existing library for this problem.

Thank you for your clear explanation.

I feared something like that, but then again I was almost expecting
it... I do wonder, however, if the problem I am having could be
somehow simplified/modified by looking at another situation, in 3D
this time: streamtubes and 3D representation of "tubes"/"pipes" are
relatively common (i.e., VTKTubeFilter from the VTK library,
streamtubes in Mayavi). They all build some kind of "cylindrical"
shape around the main path (curve in 3D) to give the visual effect of
some "tube" surrounding the main path.

What I am trying to do is basically the same thing but in 2D: now, I
have no idea if this can be done, and not even how it could be done.
My math is relatively weak, I can't fathom how to build a 3D tube let
alone splatter it back on a 2D map to give that effect.

I am not sure my original problem and this one are related or not, but
again every suggestion is most welcome.

Thank you.

Andrea.

>
>
> Jonathan
>
>
> On Sun, Feb 12, 2012 at 1:37 PM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
>>
>>
>> On Sun, Feb 12, 2012 at 1:26 PM, Andrea Gavana <andrea.gavana@gmail.com>
>> wrote:
>>>
>>> Charles,
>>>
>>> On 12 February 2012 21:00, Charles R Harris wrote:
>>> >
>>> >
>>> > On Fri, Feb 10, 2012 at 9:38 AM, Andrea Gavana <andrea.gavana@gmail.com>
>>> > wrote:
>>> >>
>>> >> Hi All,
>>> >>
>>> >>    my apologies for my deep ignorance about math stuff; I guess I
>>> >> should be able to find this out but I keep getting impossible results.
>>> >>
>>> >> Basically I have a set of x, y data (around 1,000 elements each) and I
>>> >> want to create 2 parallel "curves" (offset curves) to the original
>>> >> one; "parallel" means curves which are displaced from the base curve
>>> >> by a constant offset, either positive or negative, in the direction of
>>> >> the curve's normal. Something like this:
>>> >>
>>> >
>>> > Note that curves produced in this way aren't actually 'parallel' and can
>>> > even cross themselves.
>>>
>>> I know, my definition of "parallel" was probably not orthodox enough.
>>> What I am looking for is to generate 2 curves that look "graphically
>>> parallel enough" to the original one, and not "parallel" in the true
>>> mathematical sense.
>>>
>>
>> You could try setting a point and 'contracting' the curve towards the point.
>> A point a infinity would give the usual parallel curves. There are probably
>> a lot of perspective like transformations that would do something similar.
>>
>> Chuck
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

>>> import PyQt4.QtGui
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named PyQt4.QtGui
>>>
>>> import pygtk
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named pygtk
>>>
>>> import wx
>>>
>>>
```