POV-Ray : Newsgroups : povray.advanced-users : Location changing while scaling Server Time
21 Nov 2024 12:44:27 EST (-0500)
  Location changing while scaling (Message 1 to 3 of 3)  
From: yesbird
Subject: Location changing while scaling
Date: 2 Sep 2024 05:46:05
Message: <66d5895d$1@news.povray.org>
Hi, all !

While playing with meshes I've encountered strange behavior of spheres,
positioned at mesh vertices - after changing the scale they are moving
from previous locations (see images). Looks like the scale operation
applied to a whole array of spheres, produced by loop, but the scale
operator is inside the sphere object. I expected they would stay in
place and only change the size.

What I'm missing ? Any suggestions please ...
-- 
YB

// ------------------------------------------------------------------
#version 3.8;
global_settings { assumed_gamma 1 }

camera {
   perspective
   angle 25
   location  <20,15,20> * 0.2
   look_at   <0.5,0.5,0>
   right x * image_width / image_height
}

light_source{<-500,0,0> rgb 1} light_source{<500,0,0> rgb 1}
light_source{<0,0,-500> rgb 1} light_source{<0,0,500> rgb 1}
light_source{<20,15,20> rgb 0.4}

#declare VertexVectors= array[24] {
   <0,0,0>, <0.5,0,0>, <0.5,0.5,0>, //1
   <0.5,0,0>, <1,0,0>, <0.5,0.5,0>, //2
   <1,0,0>, <1,0.5,0>, <0.5,0.5,0>, //3
   <1,0.5,0>, <1,1,0>, <0.5,0.5,0>, //4
   <1,1,0>, <0.5,1,0>, <0.5,0.5,0>, //5
   <0.5,1,0>, <0,1,0>, <0.5,0.5,0>, //6
   <0,1,0>, <0,0.5,0>, <0.5,0.5,0>, //7
   <0,0.5,0>, <0,0,0>, <0.5,0.5,0>  //8
}

// Mesh
mesh2 {
    #local len = dimension_size(VertexVectors,1);
    vertex_vectors {
       len,
           #for (i, 0, len-1)
             VertexVectors[i]
           #end
    }

    face_indices {
       8,
       <0,1,2>,    <3,4,5>,       //1 2
       <6,7,8>,    <9,10,11>,     //3 4
       <12,13,14>, <15,16,17>,    //5 6
       <18,19,20>, <21,22,23>     //7 8
    }

    pigment {rgb 1}
}

// Spheres
#local len = dimension_size(VertexVectors,1) - 1;
#for (i, 0, len)
   sphere { VertexVectors[i], 0.04
            texture { pigment {rgb <0.1, 0.3, 0.1>} }
            scale y * 1.2 // Why they moves ?
   }
#end
// ------------------------------------------------------------------


Post a reply to this message


Attachments:
Download 'test_scale_no.png' (12 KB) Download 'test_scale_yes.png' (12 KB)

Preview of image 'test_scale_no.png'
test_scale_no.png

Preview of image 'test_scale_yes.png'
test_scale_yes.png


 

From: ingo
Subject: Re: Location changing while scaling
Date: 2 Sep 2024 06:50:00
Message: <web.66d597e6785710d117bac71e8ffb8ce3@news.povray.org>
yesbird <sya### [at] gmailcom> wrote:
> Hi, all !
>
> While playing with meshes I've encountered strange behavior of spheres,
> positioned at mesh vertices - after changing the scale they are moving
> from previous locations (see images). [...]
>
> // Spheres
> #local len = dimension_size(VertexVectors,1) - 1;
> #for (i, 0, len)
>    sphere { VertexVectors[i], 0.04
>             texture { pigment {rgb <0.1, 0.3, 0.1>} }
>             scale y * 1.2 // Why they moves ?
>    }
> #end
> // ------------------------------------------------------------------

You should create and scale the sphere at the origin and then move it to the
mesh vertex vector.


// Spheres
#local len = dimension_size(VertexVectors,1) - 1;
#for (i, 0, len)
   sphere { <0,0,0>, 0.04
            texture { pigment {rgb <0.1, 0.3, 0.1>} }
            scale y * 1.2 // Why they moves ?
            translate VertexVectors[i]
  }

ingo


Post a reply to this message

From: yesbird
Subject: Re: Location changing while scaling
Date: 2 Sep 2024 07:06:34
Message: <66d59c3a$1@news.povray.org>
On 02/09/2024 13:48, ingo wrote:
> You should create and scale the sphere at the origin and then move it to the
> mesh vertex vector.
> 
> 
> // Spheres
> #local len = dimension_size(VertexVectors,1) - 1;
> #for (i, 0, len)
>     sphere { <0,0,0>, 0.04
>              texture { pigment {rgb <0.1, 0.3, 0.1>} }
>              scale y * 1.2 // Why they moves ?
>              translate VertexVectors[i]
>    }

Thanks a lot, now it works fine !
--
YB


Post a reply to this message

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