Re: Is there somebody familiar with nurbs or b-Spline? [message #55537] |
Mon, 27 August 2007 08:46  |
airy.jiang
Messages: 37 Registered: May 2007
|
Member |
|
|
On 8 27 , 11 05 , hradilv <hrad...@yahoo.com> wrote:
> On Aug 27, 4:19 am, airy.ji...@gmail.com wrote:
>
>> In fact,I'm still trying to read the DXF file into IDL.The Spline in
>> the DXF is construct with nurbs line.The IDL have a
>> method :Spline_P,but it can't reconstruct completely the same
>> shape.Who can tell me how to use the nurbs create the Spline.I know
>> it's complex and hard to describe,so ,if there are some source code
>> can be showed it would be perfect.
>> Thanks!
>
> This function worked for me:
>
> First I get all the controlpts for the spline. Then, in my function
> ncp=# of control points, the controlpts are (in my case) 2 X ncp.
> nsegs is the number of line segments per controlpt that I want to make
> my spline into (4L is usually enough for me). The returned value is
> the 2 X (nsegs*ncp) line segments needed to dray a polyline.
>
> Hope this helps.
>
> function eval_spline, ncp, controlpts, nsegs
>
> tarray = findgen(nsegs)/(nsegs)
> np = (ncp-1)/3
>
> sval = fltarr(2,nsegs*np+1)
> for i=0l, np-1 do begin
> p0 = controlpts[*,3*i]
> p1 = controlpts[*,3*i+1]
> p2 = controlpts[*,3*i+2]
> p3 = controlpts[*,3*i+3]
>
> sval[*,nsegs*i] = p0
> for j=1l, nsegs-1 do begin
> t = tarray[j]
> vert = p0*(1-t)*(1-t)*(1-t) + p1*3.0*t*(1-t)*(1-t) +
> p2*3.0*t*t*(1-t) + p3*t*t*t
> sval[*,nsegs*i+j] = vert
> endfor
> endfor
> sval[*,nsegs*np] = controlpts[*,ncp-1]
>
> return, sval
> end
Hi,hradilv!I knew you'll comein.^_^In fact I'm waiting for you!
Somedays befor,I've used your code "plot_dxf" made some test.But I'm
sorry about that the result of the spline is looked not very good.I'll
made a screenshot of the result next day(it's very late at here and
the I'm not at the office but my home).Hope I can made more discussion
with you.
Thank you!And hope more people who is familiar with these things can
join here.
|
|
|