I assume the rows of @accel are x,y,z values. Also, @accel=[,[],[]] creates a 3deep array: the outer array has a single element, which is an arrayref; inside that arrayref are four arrayrefs with three elements each. To simplify that structure, I changed the outer brackets [] to parentheses () so it's a 2deep array instead of 3deep array, so each element of @accel is an arrayref of three values, which is what I think you wanted.

When I tried running

... I found that $spline_xy=Math::Spline::->new(...) and $spline_xz both die when they are created; if I change the third row to having an x value of -0.6437 instead of -0.7437, it fixes it, so I am assuming that it's because those x-values are the same.

Were you intending the middle two of the four points to be points on the curve (so the interpolation would hit them exactly); or are they "control points", where the interpolation doesn't hit them directly, but instead only touches on the outer two, and the inner two just define directions (like this image from Bézier_curve)? Because, from what I can tell, Math::Spline makes sure that it hits the points from the instantiation-list rather than treats them as controls.

If what you really wanted was more along the lines of a Bézier curve, let me know, because that's pretty simple to code up without a module.


In reply to Re: How to smooth values of an x,y,z array using Math::Spline by pryrt
in thread How to smooth values of an x,y,z array using Math::Spline by cormanaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.