POV-Ray : Newsgroups : povray.advanced-users : "Exploded" vector transform : Re: "Exploded" vector transform Server Time
18 Apr 2024 12:29:05 EDT (-0400)
  Re: "Exploded" vector transform  
From: Kenneth
Date: 10 Aug 2017 11:05:00
Message: <web.598c758c5219365e883fb31c0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> It occured to me just today that my 'city buildings' code might already have
> such a feature in it...

It didn't :-( But it was almost there :-)  With a few changes to it, I came up
with this (just a ONE-dimensional example.) The white boxes are random widths,
and the red lines are there simply to give a better visual indication of the
equal spacing between objects...

-----
#version 3.71; // or 3.7

global_settings{assumed_gamma 1.0}
#default {texture{pigment {rgb 1} finish{ambient 1 emission 0 diffuse 0}}}

camera {
  perspective
  location  <51, 35, -300>
  look_at   <51, 35,  0>
  right     x*image_width/image_height
  angle 21
}

#declare CX = 0;
#declare CY = 0;
#declare X = seed(15);

#declare EQUAL_SPACING = 3.1; // or whatever
#declare MOVER = 0; // to set it up
#while(CX < 20)
#declare MY_OBJECT =
box{0, <.3 + 4*rand(X),10,.1> no_shadow}
#declare SIZE = max_extent(MY_OBJECT);
object{MY_OBJECT translate MOVER*x} // WHITE box
cylinder{0, EQUAL_SPACING*x,.2 // the RED indicators
    texture {pigment{rgb <1,0,0>} finish{ambient 1 emission 0 diffuse 0}}
    translate (MOVER + SIZE.x)*x
    translate 11*y
    }
#declare MOVER = MOVER + (SIZE.x) + (EQUAL_SPACING.x);
#declare CX = CX + 1;
#end
------

HOWEVER... trying to extrapolate this to TWO dimensions (never mind THREE) has
turned out to be a really thorny problem. Basically, it boils down to this: What
part of an IRREGULARLY-shaped object should be considered as the 'point' to
determine its equal spacing from another object? In other words, should it be
the lower left corner of the object? The center? Etc. In either of these cases
(or any other case that I can imagine), the various spacings between one object
and all its adjacent fellows will turn out to be UN-equal.  While trying to work
this out, I put together another trial-code example (which works correctly ONLY
along the X-axis, by the way.) I added round discs to overlap the objects, to
show their 'spheres of influence'. And it doesn't take into account the
possibility that the objects might be randomly ROTATED as well(!)...

--------
#declare EQUAL_SPACING = <6,6,0>; // or whatever
#declare MOVER = <0,0,0>;
#while(CY < 7)
#while (CX < 7)
#declare MY_OBJECT =
box{0,<.3 + 6*rand(X),.3 + 5*rand(X),.1>}
#declare SIZE = max_extent(MY_OBJECT);

object{MY_OBJECT no_shadow translate MOVER}
disc{<.5*(SIZE.x),.5*(SIZE.y),-.01>,<0,0,-1>,.5*sqrt(pow(SIZE.x,2) +
pow(SIZE.y,2))
    texture{pigment{rgbt .85} finish{ambient 1 emission 0 diffuse 0}}
    no_shadow
    translate MOVER
    }

// x_axis equal-length cylinders
cylinder{0, EQUAL_SPACING*x,.2 // RED indicators to show equal spacing
    texture {pigment{rgb <1,0,0>} finish{ambient 1 emission 0 diffuse 0}}
    translate (MOVER + SIZE.x)*x
    translate (MOVER.y -.6)*y
    }
/*
// y-axis equal-length cylinders
cylinder{0, EQUAL_SPACING*y,.2 // CYAN indicators to show equal spacing
    texture {pigment{rgb <0,1,1>} finish{ambient 1 emission 0 diffuse 0}}
    translate (MOVER + SIZE.x)*x
    translate (MOVER.y + SIZE.y)*y
    translate .3*x
    }
*/

#declare MOVER = MOVER + <SIZE.x,0,0> + <EQUAL_SPACING.x,0,0>;
#declare CX = CX + 1;
#end
#declare CX = 0;
#declare CY = CY + 1;

#declare MOVER = <0,CY*EQUAL_SPACING.y,0>; // ???

#end


Post a reply to this message

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