POV-Ray : Newsgroups : povray.general : 3.2.1.6.5 in docs--clarification needed Server Time
29 Jul 2024 10:17:30 EDT (-0400)
  3.2.1.6.5 in docs--clarification needed (Message 21 to 24 of 24)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kenneth
Subject: Re: 3.2.1.6.5 in docs--clarification needed
Date: 1 Mar 2013 00:40:01
Message: <web.51303c93ef3a5b59c2d977c20@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 27.02.2013 22:32, schrieb Kenneth:
>
> > In the v3.62 docs section 3.2.1.6.4  "Declaring User-Defined Vector Functions"
> > (immediately preceding the one I mentioned), there's another similar(??)
> > example...
> >
> >   #declare foo = function {
> >     transform {
> >       rotate <90, 0, 0>
> >       scale 4
> >     }
> >   }
> >
> >   #declare myvector = foo(4, 3, 7);
> >
> > Would myvector ever return anything other than rotate <90,0,0> and scale 4? Or
> > am I still totally confused? (BTW, the spline function example in that section
> > *does* make sense to me, if I'm grasping the fundamental idea correctly.)
>
> The example is equivalent to
>
> #declare fooTrans = transform {
>    rotate <90, 0, 0>
>    scale 4
> }
>
> #declare myvector = vtransform(<4,3,7>, fooTrans);
>
> i.e. the function interprets the three parameters as coordinates in 3D
> space, rotates the corresponding point by 90 degrees around the x axis,
> and scales it by a factor of 4.

I've been working with a test scene to try and understand what "myvector" does
here, but I'm conceptually lost (as to both the function example and just the
vtransform version.) My scene may not even be appropriate.

I assume that it's just a 3-component vector; but the 'scale' part is a mystery.
What is the concept of 'scaling a point'? Does it just mean that the chosen
point in space, by being scaled, then moves 'up and away' from the origin? (like
scale would do to any point on an *object* if it were not at the origin to begin
with.) If so, then I *think* I understand what happens to 'the point' at
<4,3,7>--the vector is the new 3D position of that point--a single point--after
it's rotated and 'scaled' from it's original <4,3,7> position.

But how to use it: Can I apply myvector to a box object, for example? Is it then
supposed to rotate *and scale* the entire box? Or just move it to the new
coordinates? If this is making any sense at all, then how/where would I use it
in the box code to do so? (Translate, transform, etc.?) My attempts have all
failed, or make no visual sense because I'm not even sure what to expect. *Any*
example of its use would be helpful.

So, using myvector = vtransform(<4,3,7>, fooTrans)...

box{0,1 translate -.5
   Then....????....
      transform{myvector} // produces a fatal error
// Or...
      translate myvector // this works, but the results don't make sense--the
// box is no longer at the origin, and is (obviously--I think?) unscaled.

I do have a vague sense about something: The box as built isn't AT the
coordinates <4,3,7>...but I don't know what that means when myvector is applied
to it.


Post a reply to this message

From: clipka
Subject: Re: 3.2.1.6.5 in docs--clarification needed
Date: 1 Mar 2013 04:56:20
Message: <51307b44@news.povray.org>
Am 01.03.2013 06:34, schrieb Kenneth:

> I assume that it's just a 3-component vector; but the 'scale' part is a mystery.
> What is the concept of 'scaling a point'? Does it just mean that the chosen
> point in space, by being scaled, then moves 'up and away' from the origin? (like
> scale would do to any point on an *object* if it were not at the origin to begin
> with.)

Absolutely!

> If so, then I *think* I understand what happens to 'the point' at
> <4,3,7>--the vector is the new 3D position of that point--a single point--after
> it's rotated and 'scaled' from it's original <4,3,7> position.
>
> But how to use it: Can I apply myvector to a box object, for example? Is it then
> supposed to rotate *and scale* the entire box? Or just move it to the new
> coordinates? If this is making any sense at all, then how/where would I use it
> in the box code to do so? (Translate, transform, etc.?) My attempts have all
> failed, or make no visual sense because I'm not even sure what to expect. *Any*
> example of its use would be helpful.

Transforming a single point in space in such a way comes in handy when 
you have an existing object, and a point of interest on that object, and 
want to translate, scale & rotate the object around the scene and move 
that point accordingly.

For instance, you might want to model barrel, with a hole in a 
particular place that leaks water:

// the barrel in its original position,
// and where the leak would be then
#declare LeakyBarrel  = cylinder { <0,0,0>, <0,3,0>, 1 }
#declare LeakOnBarrel = <1,1,0>;

#declare BarrelTransform = transform {
   rotate y*10
   rotate z*30
   translate x*10 + y*5
}

// the barrel moved around the scene,
// and the new leak position in world space
object { LeakyBarrel ... transform { BarrelTransform } }
#declare LeakPos = vtransform(LeakOnBarrel, BarrelTransform);

// now do something useful with the leak position;
// as suggested, let's make water drop vertically down from it
#local DropPos = LeakPos;
#while (DropPos.y > 0)
   sphere { DropPos, 0.1 ... }
   #local Drop = Drop - y*1;
#end

// let's also make the camera follow the leak:
camera {
   ...
   look_at vtransform(LeakPos, BarrelTransform)
}


Hope this sheds light onto the matter.


Post a reply to this message

From: Trevor G Quayle
Subject: Re: 3.2.1.6.5 in docs--clarification needed
Date: 1 Mar 2013 11:00:01
Message: <web.5130cfc9ef3a5b5981c811d20@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> What is the concept of 'scaling a point'? Does it just mean that the chosen
> point in space, by being scaled, then moves 'up and away' from the origin? (like
> scale would do to any point on an *object* if it were not at the origin to begin
> with.) If so, then I *think* I understand what happens to 'the point' at
> <4,3,7>--the vector is the new 3D position of that point--a single point--after
> it's rotated and 'scaled' from it's original <4,3,7> position.

Remeber, all transforms are relative to the origin.  So scaling a point would
move it away from the orgin proportional to its distance and the scale.  If it
is at the origin, it basically has no effect.




-tgq


Post a reply to this message

From: Kenneth
Subject: Re: 3.2.1.6.5 in docs--clarification needed
Date: 6 Mar 2013 02:40:08
Message: <web.5136f226ef3a5b59c2d977c20@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 01.03.2013 06:34, schrieb Kenneth:
>
> > *Any* example of its use would be helpful.
>
> Transforming a single point in space in such a way comes in handy when
> you have an existing object, and a point of interest on that object, and
> want to translate, scale & rotate the object around the scene and move
> that point accordingly.

Sorry for my extended silence; THANKS for posting your example. I'm
experimenting with it, as well as other related stuff--making some nice
discoveries and conceptual leaps!


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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