POV-Ray : Newsgroups : povray.newusers : Why didn't this work? : Re: Why didn't this work? Server Time
5 Sep 2024 14:16:39 EDT (-0400)
  Re: Why didn't this work?  
From: Warp
Date: 6 Jul 2000 13:48:02
Message: <3964c652@news.povray.org>
Tom Melly <tom### [at] tomandluf9couk> wrote:
: When you scale an object, all that POV does is to move all parts of the
: object from their origin to their origin*scale.

  Well, this is the impression you get, but strictly speaking it's not true.
  Povray doesn't move anything (it doesn't _add_ anything to the location of
the object).
  Objects do NOT have origin. Povray does NOT know where the origin of an
object is.
  Ok, ok, let me take that back. Povray does know where the origin of an
object is: It's at the global origin (ie. coordinates <0,0,0>). What I meant
was that in povray's inner world there's no such a thing as "object origin".
  Objects are basically mathematical functions with a matrix transformation
applied to it. Mathematical functions do not have "origins" except the one
at <0,0,0>.
  For some objects one could think of a logical origin. For a sphere it would
be its center. For a box it would be the exact middle of a box.
  But for other objects this can be a lot more difficult. As an example, let's
take a triangle. What is the "center", the origin of a triangle? Is it the
point which distance is equal to all the sides? Is it the point where the
perpendicular lines through the middle of the sides coincide? Is it the point
where half-angle lines from each corner coincide? Perhaps it's the average
of the vertex points? The list is almost endless and most of those points are
different for most triangles.
  So povray doesn't even try to guess. For it (uh, I should say "she" instead)
the origin of the object is the mathematical origin, period.
  You can easily apply transformations relative to whatever "origin" you want:

translate -MyOrigin
(transform in whatever way I like here)
translate MyOrigin

  Now, what happens with scaling?
  Scaling is just a multiplication. If you scale by 2, the object size is
multiplied by 2.
  Well, what exactly happens is that the local "universe" of the object is
divided by two (with the matrix applied to the object), so that the object
is locally in a "universe" with a 1/2 scaling.
  So it doesn't matter where the object is. Every point in the surface of
the object will be twice as far from the origin than before the scaling.
  If the object is located so that "your" origin is at <0,0,0>, then you get
the effect you expected, ie. the surface goes twice as far from <0,0,0> than
before, ie. it's twice as big.
  If "your" origin is not at <0,0,0> and since every point will be twice
as far from <0,0,0>, you will end up with "your" origin being twice as far
from the origin as before.

  If you didn't read anything else, read at least that last paragraph. It
summarizes what's happening.

  Now, this is easy to understand (or at least I hope so). But let's not
talk about non-uniform scaling... :)
  (Although there's nothing mysterious there: The only difference is that
scaling is performed in a component-by-component basis, so that you have
to think about the points as separate coordinate components.)

  So povray doesn't "translate" anything (since translation is adding something
to the points), it just multiplies.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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