POV-Ray : Newsgroups : povray.newusers : Camera position for spline object Server Time
26 Sep 2022 08:54:40 EDT (-0400)
  Camera position for spline object (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Cousin Ricky
Subject: Re: Camera position for spline object
Date: 26 May 2022 11:37:44
Message: <628f9ec8$1@news.povray.org>
On 2022-05-26 10:17 (-4), Tor Olav Kristensen wrote:
> 
> But I'm now wondering if the original poster used another spline type in the
> other tool. The spline type in the POV-Ray code is "b_spline". But I've not been
> able to find out what spline type that is supposed to be. I very much doubt that
> it is the B-splines described here:
> 
> https://en.wikipedia.org/wiki/B-spline
> 
> Perhaps the b stands for Bezier (?) Maybe someone can verify this...

POV-Ray's b_spline is indeed a 3rd degree B-spline.  I verified this a
few years ago by plotting points derived by de Boor's algorithm against
a POV-Ray b_spline.  I have a very poor understanding of what is going
on mathematically, but I do know that b_spline is not a Bezier curve.

I found the Wikipedia article quite confusing, especially since all of
the illustrations have the curves intersecting the endpoints, yet de
Boor's algorithm, which the article links to, does not produce this
result.  I know that Bezier curves are related to B-splines, but I
haven't figured out how.


Post a reply to this message


Attachments:
Download 'b-spline_tryout.png' (19 KB)

Preview of image 'b-spline_tryout.png'
b-spline_tryout.png


 

From: Robert McGregor
Subject: Re: Camera position for spline object
Date: 26 May 2022 17:30:00
Message: <web.628ff08a6b948b6687570eabd4644d08@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:

> I found the Wikipedia article quite confusing, especially since all of
> the illustrations have the curves intersecting the endpoints, yet de
> Boor's algorithm, which the article links to, does not produce this
> result.  I know that Bezier curves are related to B-splines, but I
> haven't figured out how.

This is very helpful, IMHO:

https://www.geeksforgeeks.org/difference-between-spline-b-spline-and-bezier-curves/


Post a reply to this message

From: Bald Eagle
Subject: Re: Camera position for spline object
Date: 26 May 2022 21:20:00
Message: <web.629026786b948b661f9dae3025979125@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:

> POV-Ray's b_spline is indeed a 3rd degree B-spline.  I verified this a
> few years ago by plotting points derived by de Boor's algorithm against
> a POV-Ray b_spline.  I have a very poor understanding of what is going
> on mathematically, but I do know that b_spline is not a Bezier curve.

It is not, necessarily, but I believe that all Bezier curves are b-splines.

> I found the Wikipedia article quite confusing, especially since all of
> the illustrations have the curves intersecting the endpoints, yet de
> Boor's algorithm, which the article links to, does not produce this
> result.  I know that Bezier curves are related to B-splines, but I
> haven't figured out how.

Yeah, you have to get into the details and have them fresh in your mind to have
most of the articles that purport to "explain" the difference to make any sense.
 It's more that they describe them - in the way the POV-Ray documentation
"explains" things.   It's a lot clearer and makes more sense if you already know
the answers...  :D

Try:
https://opensourc.es/blog/b-spline/

And also, I believe that The NURBS Book has a pretty comprehensive explanation
of what all the various splines types are that lead up to the development of
NURBS - Non Uniform Rational B-Splines.

IIRC, the key points have to due with multiplicity of knot vectors, and a lot
more localized influence of any given knot on the shape of the overall curve.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Camera position for spline object
Date: 28 May 2022 15:55:00
Message: <web.62927c9e6b948b668051087f89db30a9@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> On 2022-05-26 10:17 (-4), Tor Olav Kristensen wrote:
> >
> > But I'm now wondering if the original poster used another spline type in the
> > other tool. The spline type in the POV-Ray code is "b_spline". But I've not been
> > able to find out what spline type that is supposed to be. I very much doubt that
> > it is the B-splines described here:
> >
> > https://en.wikipedia.org/wiki/B-spline
> >
> > Perhaps the b stands for Bezier (?) Maybe someone can verify this...
>
> POV-Ray's b_spline is indeed a 3rd degree B-spline.  I verified this a
> few years ago by plotting points derived by de Boor's algorithm against
> a POV-Ray b_spline.

Ok. I did the same test as you. It seems to be b-splines with a closed knot
vector. Their order is 4, i.e. 3rd degree (as you found) plus 1.


> I have a very poor understanding of what is going
> on mathematically, but I do know that b_spline is not a Bezier curve.

As Bill mentioned; B-spline curves are a superset of Bezier curves.


> I found the Wikipedia article quite confusing, especially since all of
> the illustrations have the curves intersecting the endpoints, yet de
> Boor's algorithm, which the article links to, does not produce this
> result.  I know that Bezier curves are related to B-splines, but I
> haven't figured out how.

To make B-splines intersect the endpoints, you can use open knot vectors.

Alternatively you can repeat the endpoints. To see how to do this,
have a look at the source code below and the attached image.

The file NURBS_29.inc in below can be found here:
http://news.povray.org/povray.binaries.scene-files/thread/%3Cweb.4c327e199f459e99c734aecd0%40news.povray.org%3E/


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"
#include "NURBS_29.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

default {
    texture {
        pigment { color White }
        finish {
            diffuse 0
            emission color White
        }
    }
}

background { color Gray10 }

camera {
    orthographic
    location -5*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Size = 7;

#declare PP =
    array[Size] {
        <-3, +2,  0>, // 0
        <-3, -1,  0>, // 1
        <-1, -2,  0>, // 2
        <-1, +2,  0>, // 3
        <+1, +2,  0>, // 4
        <+2, -2,  0>, // 5
        <+3,  0,  0>  // 6
    }
;

#declare Radius = 0.01;

union {
    ShowPoints1A3D(
        PP,  // Points1A3D
        false, // WrapU
        6*Radius  // Radius
    )
    pigment { color Gray40 }
    translate +5*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Uniform B-Spline of order 4 with closed knot vector

sphere_sweep {
    b_spline
    Size,
    #for (I, 0, Size - 1)
        PP[I], 8*Radius
    #end // for
    tolerance 0.1
    pigment { color Cyan }
    translate +4*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Order = 4;
#declare Open = false;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// The circumstantial way

#macro B_Spline_Function1A(OrderU, KnotsU, Values1A)

    #local SizeU = Size1A(Values1A);
    #local BlendU_Fns = BlendFunctions(SizeU, OrderU, KnotsU);

    function(_t) {
        0
        #for (I, 0, SizeU - 1)
            #local C = Values1A[I];
            #switch (C)
                #case (-1)
                    -BlendU_Fns[I](_t)
                    #break
                #case (0)
                    #break
                #case (+1)
                    +BlendU_Fns[I](_t)
                    #break
                #else
                    +BlendU_Fns[I](_t)*C
            #end // switch
        #end // for
    }

#end // macro B_Spline_Function1A


#declare KK =
    UniformKnotVector(
        Open,  // Open
        Order,  // Order
        Size  // NrOfPoints
    )
;
// Closed: { -3/4,-2/4,-1/4, 0/4, 1/4, 2/4, 3/4, 4/4, 5/4, 6/4, 7/4 }
// Open:   {  0/4, 0/4, 0/4, 0/4, 1/4, 2/4, 3/4, 4/4, 4/4, 4/4, 4/4 }

#declare PPx = ExtractComponent1A(PP, x);
#declare PPy = ExtractComponent1A(PP, y);
#declare PPz = ExtractComponent1A(PP, z);

#declare B_Spline_FnX =
    B_Spline_Function1A(
        Order,  // OrderU
        KK,  // KnotsU
        PPx  // Values1A
    )
;
#declare B_Spline_FnY =
    B_Spline_Function1A(
        Order,  // OrderU
        KK,  // KnotsU
        PPy  // Values1A
    )
;
#declare B_Spline_FnZ =
    B_Spline_Function1A(
        Order,  // OrderU
        KK,  // KnotsU
        PPz  // Values1A
    )
;

union {
    ShowFunctions1A3D(
        B_Spline_FnX,  // xFn
        B_Spline_FnY,  // yFn
        B_Spline_FnZ,  // zFn
        false,  // WrapU
        0, // MinU
        1, // MaxU
        200,  // ResU
        6*Radius  // Radius
    )
    pigment { color Blue }
    translate +3*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Alternative way,
// but now with 2 repeated points in both the beginning and the end.

#declare NewSize = Size + 4;

#declare QQ =
    array[NewSize] {
        PP[0], //  0
        PP[0], //  1

        PP[0], //  2
        PP[1], //  3
        PP[2], //  4
        PP[3], //  5
        PP[4], //  6
        PP[5], //  7
        PP[6], //  8

        PP[6], //  9
        PP[6]  // 10
    }
;

// Uniform B-Spline
union {
    Show_UBS_1A3D(
        QQ,  // Points1A3D
        Open,  // OpenU
        Order,  // OrderU
        false,  // WrapU
        200,  // ResU
        2*Radius  // Radius
    )
    pigment { color Red }
    translate +1*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Now check if also the built in B-spline sphere sweep can be
// tricked into reaching the points in the beginning and the end.

sphere_sweep {
    b_spline
    NewSize,
    #for (I, 0, NewSize - 1)
        QQ[I], 4*Radius
    #end // for
    tolerance 0.1
    pigment { color Green }
    translate +2*z
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message


Attachments:
Download 'b_spline_sphere_sweep.png' (33 KB)

Preview of image 'b_spline_sphere_sweep.png'
b_spline_sphere_sweep.png


 

From: Aj
Subject: Re: Camera position for spline object
Date: 31 May 2022 05:15:00
Message: <web.6295db626b948b66689ede133d902b29@news.povray.org>
Thank you so much for the help, I really appreciate it. The idea is to create a
smooth curve passing  through the 6 control points. The screenshot that I posted
was a 3d plot obtained using matlab.Now all I need is to shit the the first
point in the negative z direction so that upper half doesn't look larger than
the upper half.
A better version of what I am trying to do can be found in this video.

https://www.cosseratrods.org/videos/RALvideos/Case2-front_view_web.mp4

I have a small favor to ask. any advice on how to make this close to the model
in the video would be great.

Thank you once again.








"m@b" <sai### [at] googlemailcom> wrote:
> On 23/05/2022 1:08 am, Aj wrote:
> > Hello everyone,
> >
> > I created a spline object using the following code, but I could not get the
> > proper camera position. I was wondering if there is some systematic way to
> > figure out the camera position, and angle and look at vectors for a given shape.
> > Or is it just trial and error? Can someone please help me to get the proper
> > camera setup so as to obtain the figure attached:
> >
> >
>
> The points in your sphere_sweep don't plot the figure in the screen
> shot, the points form a more or less straight line in the z direction.
> (1.png) (Points 5 & 6 are the same.)
>
> Looking again at the screen shot, I notice that the 3 axes are at
> different scales. If I apply scaling and rotation to the points I can
> get something like your figure. Scale = <200,10,1> rotate<0,90,0> (2.png)
>
> Note that I have moved the camera to <0,0,-200>, looking at <0,0,0>. I
> find it easier to keep track of x,y,z if the camera is in the minus z
> position.
>
> If you want a point for the camera to look at, you can find the mean
> center of your plot thus:
>
>   #declare Thing_max = max_extent(Thing);
>   #declare Thing_min = min_extent(Thing);
>   #declare Thing_centre = (max_extent(Thing) + min_extent(Thing))/2;
>
> (Red sphere)
>
> ---------------------------------------------------------------
> #include"colors.inc"
>   camera {
>      //location <-0.0872 , -1.8850 ,   4.8301 >*3.5
>      location <0,0,-200>
>      look_at <0,0,0>
>      angle 22
>      }
>
>
> light_source { <100,100,-100>  color rgb<1,1,1> }
>
> background {color rgb<0.5,0.5,0.5> }
>
> #declare Scale = <200,10,1>;
> //#declare Scale = <1,1,1>;
>
> #declare P01 = Scale*< 0,         0,         -20>;
> #declare P02 = Scale*< 2.583e-09,-2.7093e-08, 3>;
> #declare P03 = Scale*< 0.075646, -0.91834,    8.9288>;
> #declare P04 = Scale*< 0.076898, -2.3756,    14.7492>;
> #declare P05 = Scale*<-0.15231,  -4.2038,    20.4593>;
> #declare P06 = Scale*<-0.15231,  -4.2038,    20.4593>;
>
> #declare Thing = union{
>
>      sphere{P01 0.9 pigment{rgb<0,1,0>}}
>      sphere{P02 0.9 pigment{rgb<0,1,0>}}
>      sphere{P03 0.9 pigment{rgb<0,1,0>}}
>      sphere{P04 0.9 pigment{rgb<0,1,0>}}
>      sphere{P05 0.9 pigment{rgb<0,1,0>}}
>      sphere{P06 0.5 pigment{rgb<0,1,0>}}
>
>
>          sphere_sweep {
>           //b_spline
>           linear_spline
>           6,
>               P01,0.5,
>               P02,0.5,
>               P03,0.5,
>               P04,0.5,
>               P05,0.5,
>               P06,0.5
>           tolerance 0.1
>           texture{ pigment{ color rgb<0.69,0.99,0.15>}
>            finish { phong 1
>             ambient 0.3
>           }
>           }
>           //scale<2,2,0.35>   rotate<-90,0,0>  translate<0,-2,3>
>
>          }
>
>
>
> //rotate<0,90,0>
> rotate<-90,0,0>
> }
>
>
>   #declare Thing_max = max_extent(Thing);
>   #declare Thing_min = min_extent(Thing);
>   #declare Thing_centre = (max_extent(Thing) + min_extent(Thing))/2;
>
> sphere{Thing_centre, 1.5 pigment{rgb<1,0,0>} rotate<0,360*clock,0>}
>
> //box{Thing_min, Thing_max pigment{rgbt<1,0,0,0.8>}
> rotate<0,360*clock,0>}
>
> object{Thing rotate<0,360*clock,0>}


Post a reply to this message

From: Aj
Subject: Re: Camera position for spline object
Date: 19 Jul 2022 14:20:00
Message: <web.62d6f5686b948b66cb63c1d33d902b29@news.povray.org>
"m@b" <sai### [at] googlemailcom> wrote:
> On 23/05/2022 1:08 am, Aj wrote:
> > Hello everyone,
> >
> > I created a spline object using the following code, but I could not get the
> > proper camera position. I was wondering if there is some systematic way to
> > figure out the camera position, and angle and look at vectors for a given shape.
> > Or is it just trial and error? Can someone please help me to get the proper
> > camera setup so as to obtain the figure attached:
> >
> >
>
> The points in your sphere_sweep don't plot the figure in the screen
> shot, the points form a more or less straight line in the z direction.
> (1.png) (Points 5 & 6 are the same.)
>
> Looking again at the screen shot, I notice that the 3 axes are at
> different scales. If I apply scaling and rotation to the points I can
> get something like your figure. Scale = <200,10,1> rotate<0,90,0> (2.png)
>
> Note that I have moved the camera to <0,0,-200>, looking at <0,0,0>. I
> find it easier to keep track of x,y,z if the camera is in the minus z
> position.
>
> If you want a point for the camera to look at, you can find the mean
> center of your plot thus:
>
>   #declare Thing_max = max_extent(Thing);
>   #declare Thing_min = min_extent(Thing);
>   #declare Thing_centre = (max_extent(Thing) + min_extent(Thing))/2;
>
> (Red sphere)
>
> ---------------------------------------------------------------
> #include"colors.inc"
>   camera {
>      //location <-0.0872 , -1.8850 ,   4.8301 >*3.5
>      location <0,0,-200>
>      look_at <0,0,0>
>      angle 22
>      }
>
>
> light_source { <100,100,-100>  color rgb<1,1,1> }
>
> background {color rgb<0.5,0.5,0.5> }
>
> #declare Scale = <200,10,1>;
> //#declare Scale = <1,1,1>;
>
> #declare P01 = Scale*< 0,         0,         -20>;
> #declare P02 = Scale*< 2.583e-09,-2.7093e-08, 3>;
> #declare P03 = Scale*< 0.075646, -0.91834,    8.9288>;
> #declare P04 = Scale*< 0.076898, -2.3756,    14.7492>;
> #declare P05 = Scale*<-0.15231,  -4.2038,    20.4593>;
> #declare P06 = Scale*<-0.15231,  -4.2038,    20.4593>;
>
> #declare Thing = union{
>
>      sphere{P01 0.9 pigment{rgb<0,1,0>}}
>      sphere{P02 0.9 pigment{rgb<0,1,0>}}
>      sphere{P03 0.9 pigment{rgb<0,1,0>}}
>      sphere{P04 0.9 pigment{rgb<0,1,0>}}
>      sphere{P05 0.9 pigment{rgb<0,1,0>}}
>      sphere{P06 0.5 pigment{rgb<0,1,0>}}
>
>
>          sphere_sweep {
>           //b_spline
>           linear_spline
>           6,
>               P01,0.5,
>               P02,0.5,
>               P03,0.5,
>               P04,0.5,
>               P05,0.5,
>               P06,0.5
>           tolerance 0.1
>           texture{ pigment{ color rgb<0.69,0.99,0.15>}
>            finish { phong 1
>             ambient 0.3
>           }
>           }
>           //scale<2,2,0.35>   rotate<-90,0,0>  translate<0,-2,3>
>
>          }
>
>
>
> //rotate<0,90,0>
> rotate<-90,0,0>
> }
>
>
>   #declare Thing_max = max_extent(Thing);
>   #declare Thing_min = min_extent(Thing);
>   #declare Thing_centre = (max_extent(Thing) + min_extent(Thing))/2;
>
> sphere{Thing_centre, 1.5 pigment{rgb<1,0,0>} rotate<0,360*clock,0>}
>
> //box{Thing_min, Thing_max pigment{rgbt<1,0,0,0.8>}
> rotate<0,360*clock,0>}
>
> object{Thing rotate<0,360*clock,0>}

Thank you so much for the help and really sorry I was not able to reply to
everyone as I met with an accident and now I am fit to work. So, I made the
changes in my code and got the following results( please refer to the picture
attached ). So if you see the green object appears to be smaller in length
compared to the white object. Is there a way to restrict the length of the
spline object such that it does not change when the control points move and only
the curvature changes?
To make more sense of what I mean by that, please refer to the website :
https://www.cosseratrods.org/videos/RALvideos/Case2-front_view_web.mp4


Post a reply to this message


Attachments:
Download 'pyel1.png' (15 KB)

Preview of image 'pyel1.png'
pyel1.png


 

<<< Previous 10 Messages Goto Initial 10 Messages

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