POV-Ray : Newsgroups : povray.advanced-users : how to get the equation of a bezier curve Server Time
31 Oct 2024 20:13:24 EDT (-0400)
  how to get the equation of a bezier curve (Message 1 to 2 of 2)  
From: paola
Subject: how to get the equation of a bezier curve
Date: 19 Feb 2013 05:50:01
Message: <web.5123581c75ad2525cb47ddb0@news.povray.org>
Hi,
I'm using bezier.inc and this commands:

#declare Spline1 = array[4] { A1,B1,C1,D1 }
#declare BezRad = 0.01;
#declare FullCurve = true;
DrawSpline(Spline1)

is it possible to get the equation of the resulting curve?
This is the macro:
#macro DrawSpline(id)

  #declare BezThing = sphere { <0,0,0> BezRad texture { BezTex }  }

 #local c = 0;
 #while ( c < 1 )
   #local temp = ReturnPosition(id,c);
     // Find the Next Point on the spline
     #local next = ReturnPosition(id,(c+1/NumberofPoints));
     #if (FullCurve)
       #if ( c < 1 ) cylinder { temp, next BezRad texture { BezTex }
                                #if(NoShadow) no_shadow #end  } #end
     #end
    // Find the proper transformation for the thing
     #local nx = vnormalize(next - temp);
     #local nz = vnormalize(vcross(nx,y));
     #local ny = vcross(nz,nx);
     #local nz = vnormalize(vcross(nx,ny));
   object{ BezThing
           #if(NoShadow) no_shadow #end
            matrix
<nx.x,nx.y,nx.z,ny.x,ny.y,ny.z,nz.x,nz.y,nz.z,temp.x,temp.y,temp.z>
             texture { BezTex }}

   #declare c = c + (1/NumberofPoints);
 #end
 #if (ShowTangents)
     cylinder { id[0],id[1] BezRad*0.75 pigment { rgb 1 } no_shadow}
     cylinder { id[2],id[3] BezRad*0.75 pigment { rgb 1 } no_shadow}
   #end
   #if (CapSpline)
     object { BezThing texture { BezTex } translate id[3] }
   #end
#end

Thanks!!


Post a reply to this message

From: Le Forgeron
Subject: Re: how to get the equation of a bezier curve
Date: 19 Feb 2013 13:12:17
Message: <5123c081$1@news.povray.org>
Le 19/02/2013 11:46, paola nous fit lire :
> Hi,
> I'm using bezier.inc and this commands:
> 
> #declare Spline1 = array[4] { A1,B1,C1,D1 }
> #declare BezRad = 0.01;
> #declare FullCurve = true;
> DrawSpline(Spline1)
> 
> is it possible to get the equation of the resulting curve?

If the implementation is correct, the curve should be
 P(t)= A1.(1-t)^3 +3.B1.t.(1-t)^2+3.C1.t^2.(1-t)+D1.t^3

For t from 0 to 1;


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.