POV-Ray : Newsgroups : povray.newusers : unexpected scale results Server Time
1 Nov 2024 16:25:07 EDT (-0400)
  unexpected scale results (Message 1 to 9 of 9)  
From: jofg
Subject: unexpected scale results
Date: 7 Dec 2007 20:10:00
Message: <web.4759ee8a2b8d7db3e4c81d9c0@news.povray.org>
// This exercise is from the 2.2.7.1  Transformations, scale and translate
section of
// the PovRay tutorial,
// but it seems to have returned unexpected results
// can you render this? thanks


  #include "colors.inc"

    camera
    {
       location <16, 32, -20.0>
       look_at  <8, 8,  0.0>
    }

    plane
    {
       y, -1.0
       pigment {
       checker color Gray65 color Gray30
               }
    }

light_source { <5, 10, 0> color White }
light_source { <-5, 10, 10> color White }


    sphere { < 2, 2, 2 >,1  // draws sphere at this location
      pigment { Blue }
      scale <4,3,.5>       // squishes and strectches according to scale
           }

    sphere { < 0, 3, 0 >,1  // draws sphere at this location
      pigment { Green }
      scale 2               // doubles the diameter of sphere
           }


    sphere { <10, 10, 10>,1 // draws sphere at this location for reference point
      pigment { Orange }
           }


    //// Please explain why these spheres where translated to a new location
after being scaled, thanks


    sphere { <12, 10, 10>,1 // draws sphere at this location, should be next to
Orange
      pigment { Yellow }
      scale < 3,2,4 >      // squishes and strectches according to scale, but
where did it go??
      // comment this scale out, to see Yellow sphere
           }

    sphere { <10, 10, 10>,1
      pigment { Red }
      translate 4*x         // draws sphere at <14,10,10>, should be next to
Yellow next to Orange
      scale <2,.4,.5>       // squishes and strectches according to scale, but
where did it go??
      // comment this scale out, to see Red sphere

           }


Post a reply to this message

From: Warp
Subject: Re: unexpected scale results
Date: 7 Dec 2007 20:33:00
Message: <4759f44c@news.povray.org>
jofg <jos### [at] yahoocom> wrote:
>     //// Please explain why these spheres where translated to a new location
> after being scaled, thanks

  Suppose you have this:

object { MyObject scale 2 }

  What do you expect happens to that object? It should be uniformly scaled
twice its size, no? The resulting object should look exactly the same as
the original one, just twice as large, no?

  Well, assume that MyObject is defined as follows:

#declare MyObject =
  union
  { sphere { <0, 0, 0>, 1 }
    sphere { <2, 0, 0>, 1 }
  };

  This is the union of two spheres which touch each other at a point
(more precisely, at <1, 0, 0>). After this object is instantiated and
scaled above, the result should still be a union of sphere which touch
at a point. A uniform scale should not and does not change this.

  In order for this to happen at least one of the spheres must change
position besides being scaled larger, so that the end result is two
spheres twice as large as the originals, which touch at one point.

  Since the object is scaled with respect to the origin, the first sphere
will not move, but the second sphere will move to <4, 0, 0>, and of course
their radiuses will double. (And thus the new point where they touch is
<2, 0, 0>.) The end result is an object which looks identical to the
original object, just twice as large.

  Well, what happens if instead of that we declare MyObject as:

#declare MyObject =
  sphere { <2, 0, 0>, 1 };

  Now it's the same object, except that the first sphere has been removed.

  What happens if we instantiate this object and scale it twice as large,
as above? Should the behavior of this sphere change in some way simply
because now it's alone and not in a union with another sphere?

  No. Objects are always scaled with respect to the origin. This lone
sphere will still be scaled in the same way regardless of whether it's
in a union with another sphere or not. The transformation is independent
of this. The end result is still a sphere centered at <4, 0, 0> (and
with radius 2).

  The point is, transformations don't know nor care about what is the
"center" of the object. Many object do not have a "center". The "center"
of the object is always the origin, nothing else, and all transformations
are done with respect to that.

-- 
                                                          - Warp


Post a reply to this message

From: nemesis
Subject: Re: unexpected scale results
Date: 7 Dec 2007 22:10:00
Message: <web.475a0af3b93ae2ada71cf50d0@news.povray.org>
BTW, works the same in Blender and possibly other modellers as well.


Post a reply to this message

From: Alain
Subject: Re: unexpected scale results
Date: 8 Dec 2007 00:41:49
Message: <475a2e9d$1@news.povray.org>
jofg nous apporta ses lumieres en ce 2007/12/07 20:08:
> // This exercise is from the 2.2.7.1  Transformations, scale and translate
> section of
> // the PovRay tutorial,
> // but it seems to have returned unexpected results
> // can you render this? thanks

>     //// Please explain why these spheres where translated to a new location
> after being scaled, thanks
> 
> 
>     sphere { <12, 10, 10>,1 // draws sphere at this location, should be next to
> Orange
>       pigment { Yellow }
>       scale < 3,2,4 >      // squishes and strectches according to scale, but
> where did it go??
>       // comment this scale out, to see Yellow sphere
>            }
This sphere is now centered at <12*3, 10*2, 10*4> or <36, 20, 40>
> 
>     sphere { <10, 10, 10>,1
>       pigment { Red }
>       translate 4*x         // draws sphere at <14,10,10>, should be next to
> Yellow next to Orange
This sphere is now at <14,10,10>
>       scale <2,.4,.5>       // squishes and strectches according to scale, but
> where did it go??
>       // comment this scale out, to see Red sphere
It's location is now <28, 0.4, 0.5>
> 
>            }
> 
When you want to scale or rotate an object, it's always beter to define it at 
the origin (around <0,0,0>), scale oan/or rotate it, THEN translate to where you 
want it to apears.

All scalings and rotations are ALWAYS performed relative to the origin of the 
coordinate system. So, the location of any object NOT at the origin will also 
change. Scaling will move the object on a line passing by the origin. Rotations 
will make the object orbit the coresponding axis.

-- 
Alain
-------------------------------------------------
You know you've been raytracing too long when you keep a blacklist of people who 
ask questions about 3DFX products.
Alex McLeod a.k.a. Giant Robot Messiah


Post a reply to this message

From: scott
Subject: Re: unexpected scale results
Date: 11 Dec 2007 04:57:35
Message: <475e5f0f$1@news.povray.org>
> BTW, works the same in Blender and possibly other modellers as well.

Not used Blender that much, but in other modellers you define an "object 
centre" point, and all transformations apply relative to that point.  So if 
you have a complex scene with an object (or group) you can rotate/scale 
about the object centre rather than the whole scene centre...


Post a reply to this message

From: Warp
Subject: Re: unexpected scale results
Date: 11 Dec 2007 08:27:00
Message: <475e9023@news.povray.org>
scott <sco### [at] laptopcom> wrote:
> > BTW, works the same in Blender and possibly other modellers as well.

> Not used Blender that much, but in other modellers you define an "object 
> centre" point, and all transformations apply relative to that point.  So if 
> you have a complex scene with an object (or group) you can rotate/scale 
> about the object centre rather than the whole scene centre...

  How do you select whether you want to apply a transformation to a group
of objects as if it was a single object with a common center point, or
whether you want the transformation to be applied to each object individually,
independently of the other objects?

  Anyways, it's quite trivial to apply a transformation to an object in
POV-Ray in relation to a defined local center point:

#declare MyObject = ...;
#declare MyObjectCenter = <centerX, centerY, centerZ>;

...

object
{ MyObject

  translate -MyObjectCenter
  // add local transforms here
  translate MyObjectCenter
}

-- 
                                                          - Warp


Post a reply to this message

From: scott
Subject: Re: unexpected scale results
Date: 11 Dec 2007 09:45:33
Message: <475ea28d$1@news.povray.org>
>  How do you select whether you want to apply a transformation to a group
> of objects as if it was a single object with a common center point, or
> whether you want the transformation to be applied to each object 
> individually,
> independently of the other objects?

You either apply the transformation to the group, or to all the items in the 
group (usually an ungroup command will leave all the objects selected in the 
group, so you can apply the transformation and then re-group).  Each 
"object", whether it is a primitive or a group, has a centre point (that you 
can actually modify if you want), all transformations on an object are 
relative to the object's centre point.

>  Anyways, it's quite trivial to apply a transformation to an object in
> POV-Ray in relation to a defined local center point:

Yes, but if you've built a union of several objects, and then decide that 
actually you want each one to be rotated by a certain amount, or scaled by a 
certain amount, but to keep its position, it's quite hard work as you have 
to manually add the transformations to every single object in the union.

All I was saying is that there are more efficient ways to do that sort of 
thing in other software.


Post a reply to this message

From: nemesis
Subject: Re: unexpected scale results
Date: 11 Dec 2007 12:20:01
Message: <web.475ec65db93ae2ad773c9a3e0@news.povray.org>
"scott" <sco### [at] laptopcom> wrote:
> > BTW, works the same in Blender and possibly other modellers as well.
>
> Not used Blender that much, but in other modellers you define an "object
> centre" point, and all transformations apply relative to that point.

yes, you can do that in Blender as well.  Except it's a pain in the ass
positioning the cursor or reaching for "New center" in the menu.  I actually do
it the way I do it in pov:  create at center, do transforms and position them
later.  much faster...


Post a reply to this message

From: William Tracy
Subject: Re: unexpected scale results
Date: 11 Dec 2007 19:14:41
Message: <475f27f1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Warp wrote:
>   Anyways, it's quite trivial to apply a transformation to an object in
> POV-Ray in relation to a defined local center point:

Hell, if that's too hard, there's macros in transforms.inc that do it
all for you.

- --
William Tracy
afi### [at] gmailcom -- wtr### [at] calpolyedu

You know you've been raytracing too long when you seriously entertain
thoughts about learning C so you can improve POV-Ray without waiting for
the POV Team to do it.
    -- Taps a.k.a. Tapio Vocadlo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHXyfwKrVIcTMekC8RAoccAJ9N+xlJYn0CYObPuw5FVMFE5GuB9wCguX4d
6VtGNGNzeoXZUwLhgOiegxY=
=VZA8
-----END PGP SIGNATURE-----


Post a reply to this message

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