[Numpy-discussion] Creating parallel curves
Charles R Harris
charlesr.harris@gmail....
Sun Feb 12 14:27:23 CST 2012
On Sun, Feb 12, 2012 at 1:21 PM, Andrea Gavana <andrea.gavana@gmail.com>wrote:
> Jonathan,
>
> On 12 February 2012 20:53, Jonathan Hilmer wrote:
> > Andrea,
> >
> > Here is how to do it with splines. I would be more standard to return
> > an array of normals, rather than two arrays of x and y components, but
> > it actually requires less housekeeping this way. As an aside, I would
> > prefer to work with rotations via matrices, but it looks like there's
> > no support for that built in to Numpy or Scipy?
> >
> > def normal_vectors(x, y, scalar=1.0):
> > tck = scipy.interpolate.splrep(x, y)
> >
> > y_deriv = scipy.interpolate.splev(x, tck, der=1)
> >
> > normals_rad = np.arctan(y_deriv)+np.pi/2.
> >
> > return np.cos(normals_rad)*scalar,
> np.sin(normals_rad)*scalar
>
>
> Thank you for this, I'll give it a go in a few minutes (hopefully I
> will also be able to correctly understand what you did). One thing
> though, at first glance, it appears to me that your approach is very
> similar to mine (meaning it will give "parallel" curves that cross
> themselves as in the example I posted). But maybe I am wrong, my
> apologies if I missed something.
>
> Thank you so much for your answer.
>
>
Crossing curves is the correct behavior for this method, think propagating
wavefronts and the appearance of light on the bottom of a swimming pool
when there are ripples on the surface. I think you need to define what you
really want from 'parallel'.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120212/ec05a916/attachment.html
More information about the NumPy-Discussion
mailing list