comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Is there somebody familiar with nurbs or b-Spline?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Is there somebody familiar with nurbs or b-Spline? [message #55537] Mon, 27 August 2007 08:46 Go to next message
airy.jiang is currently offline  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.
Re: Is there somebody familiar with nurbs or b-Spline? [message #55539 is a reply to message #55537] Mon, 27 August 2007 08:05 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
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
Re: Is there somebody familiar with nurbs or b-Spline? [message #55671 is a reply to message #55537] Mon, 27 August 2007 21:41 Go to previous message
airy.jiang is currently offline  airy.jiang
Messages: 37
Registered: May 2007
Member
I use the plot_dxf.pro and IDL method Spline_P made some test,but the
result is still not very good.
This is the link where I have uploaded the test results.There are 3
pictures.First is the result made by your code which used the function
eval_spline.Second is the result made by your code but with the
modificaion of the eval_spline.I just did a little change.
Like this: Spline_P, controlpts[0,*],controlpts[1,*],x,y
sval = [Transpose(x),Transpose(y)]
The third picture is a screenshot of the file opened by the
autocad2004 .
You can see the shapes of them are nearly the same bu not enough.Can
we make it a better effect?
Thank you !
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Weighted histogram
Next Topic: Is there somebody familiar with nurbs or b-Spline?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:39:22 PDT 2025

Total time taken to generate the page: 0.00446 seconds