[Numpy-discussion] Creating parallel curves
Sun Feb 12 05:47:24 CST 2012
HI Chris and All,
On 10 February 2012 17:53, Chris Barker wrote:
>> 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:
> THis is called "buffering" in GIS parlance -- there are functions
> available to do it in GIS an computational geometry libraries: you
> might look in the shapely package:
Thanks, I hoped this one would prove itself useful, but unfortunately
to me it looks like one of the most impenetrable Python code I have
ever seen. Or maybe my Python is just too weak. The end result is the
I have surfed quite a lot and found many reference to Bezier curves,
with a lot of mathematical acrobatics but little of practical value
(i.e., code :-) ). In the end I stumbled upon a nice function in the
matplotlib library (obviously) which can give me the normal line to
every point in the curve, and I almost got there.
I still have 2 problems (attached sample), picture at
1) If you run the attached sample, you'll see a plot of a cubic
polynomial with two "almost" parallel lines to it on the first
subplot. I say "almost" because at the inflection points of the cubic
something funny happens (see suplot number 2);
2) You can see in subplot 3 that the 3 lines are nicely shown as
"almost" parallel (except the problem at point 1), as the X and Y axes
have the same scale. Unfortunately I can't keep the same scales in my
real plot and I can't use axis=square in matplotlib either. How do I
"normalize" the get_normal_points method to get the same visual
appearance of parallelism on X and Y having different X and Y scales
(i.e., the same X and Y scales as in subplot 1)?
>> But by plotting these thing out with matplotlib it seems to me they
>> don't really look very parallel nor very constant-distance.
> as we say on the wxPython list -- post a fully functional example, so
> we can check it out.
Attached as promised.
Thank you in advance for any suggestion.
"Imagination Is The Only Weapon In The War Against Reality."
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2249 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120212/aa14fa33/attachment.obj
More information about the NumPy-Discussion