5.0

5.0 | 4 ratings Rate this file 11 downloads (last 30 days) File Size: 3.27 KB File ID: #7233

curvspace

by Yo Fukushima

 

22 Mar 2005 (Updated 24 Mar 2005)

No BSD License  

Generate evenly spaced points along an existing curve in 2D or 3D.

Download Now | Watch this File

File Information
Description

CURVSPACE(P,N) generates N points that interpolates a curve (represented by a set of points) with an equal spacing. Each row of P defines a point, which means that P should be a n x 2 (2D) or a n x 3 (3D) matrix.

(Example)
x = -2*pi:0.5:2*pi;
y = 10*sin(x);
z = linspace(0,10,length(x));
N = 50;
p = [x',y',z'];
q = curvspace(p,N);

The above example creates 50 evenly spaced points along a sinusoidal curve.

Acknowledgements
This submission has inspired the following:
Kirchhoff Vortex Contour Dynamics Simulation
MATLAB release MATLAB 5.3.1 (R11.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
18 May 2005 meng mingyang

useful program! It's exact what I want!
Thank you very much!

18 May 2005 meng mingyang

It's not as my imagination,but it illumined me .Thank you!

03 Feb 2006 Valer Jurcak

Works fine, thaks. Please make N input also as percentual legth.
if N < 1 % e.g. 0.1 make new point every 10% of totaldist.
    N = N * totaldist;
end

25 Mar 2006 Daniel Daniel

Works Great! This is an incredibly useful tool. Unlike Matlab's interp functions the X-data does not have to be distint.

Thankyou for this handy function.

17 Jan 2007 Sven Mensing

Thank you for your excellent function. If you replace the distance by

function l = distance(x,y)
l = sqrt(sum((x-y).^2,2));

and calculate the distance between the points as follows:

dist_bet_pts = distance ( p(1:(length(p)-1),:), p(2:length(p),:));

you can increase the speed of curvspace by 300%.

Thanks again

Sven Mensing

08 Jan 2009 Andrea Tagliasacchi

thanks a lot, I didn't want to lose time re-implementing it!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
approximation Yo Fukushima 22 Oct 2008 07:43:59
interpolation Yo Fukushima 22 Oct 2008 07:43:59
linspace Yo Fukushima 22 Oct 2008 07:43:59
point Yo Fukushima 22 Oct 2008 07:43:59
interp Yo Fukushima 22 Oct 2008 07:43:59
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com