|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |