POV-Ray : Newsgroups : povray.newusers : Accuracy with parametric: An infinite car garage : Accuracy with parametric: An infinite car garage Server Time
27 Apr 2024 07:16:50 EDT (-0400)
  Accuracy with parametric: An infinite car garage  
From: fuglede
Date: 22 Oct 2014 04:15:00
Message: <web.54476672a2cd0dec840175ab0@news.povray.org>
I'm in the process of creating an infinitely tall car garage and came across two
problems. Here's what I want it to look like, as well as an implicit description
of how I've made it:
  http://gfycat.com/ScholarlyMeekAtlanticridleyturtle
So, I take a cylinder, cut out four slices as prisms by doing so at the origin
and translating along an axis. I then proceed to take an infinite number (i.e.
eleven) of these, stack them vertically, and I want to connect them by smooth
ramps.

Now, I found that the nicest results for the ramps I would get by using the
parametric objects, since I could then describe everything in polar coordinates
and describe the height of the ramp by a nice differentiable trigonometric
function (code below).

So, problem #1: as you can see from final structure, even though the entire
thing consists of a bunch of vertical translates, the "middle" set of ramps has
some issues with lighting (the checker pigment is all smeared). I found that I
could limit this effect by giving lower values of accuracy, but if I go below
0.000007, I'll get a segmentation fault when rendering. Here's a still showing
the problem:
  https://i.imgur.com/p7ZkDTZ.png

Is there any way around this issue?

My second problem is probably related. If I try to double the angle of the
slices (i.e. change Angle to 8/360*2*pi in the code below), some translates
behave weirdly. Again, here's a still:
  https://i.imgur.com/cDYNLHD.png
As you can see, the topmost ramps have some strange cuts that the bottommost do
not, even though they're all just translates of the same thing. Is there any way
to fix that?

Here's the full code. The relevant part is in #declare Stairs.

-------------------------------------

#declare Radius = 2.5;
#declare Height = 1;
#declare Angle = 4/360*2*pi;

#declare CameraDistance = 10;
#declare CameraAngle = 5*pi/8+2*pi*1;

camera {
    location <CameraDistance*cos(CameraAngle), CameraDistance*sin(CameraAngle),
-Height/3>
    sky <0,0,1>
    look_at 0
}

// We first create the disks as very thin cylinders, so as to be able to use CSG
// later on.
#declare Disk = cylinder {
    <0, 0, -0.001>, <0, 0, 0>, Radius
    pigment { checker pigment { color rgb <0.9,0.3,0.3> filter 0.3 }, pigment{
color rgb <0.8,0.1,0.1> filter 0.3 } }
    finish { phong 0.7 specular 0.6 }
}

// From the disks, we will cut out four slices (with angle 2*Angle, given
below).
// These will be given as if they had a vertex at the origin, then translated to
// each of the punctures.
//
// The punctures have <x,y>-coordinates <-1.5,0>, <-0.5,0>, <0.5,0> and <1.5,0>.


#declare CutOut = prism {
    linear_sweep
    linear_spline
    -0.5,
    0.5,
    4,
    <0,0>, <-2*Radius*sin(Angle),-2*Radius>, <2*Radius*sin(Angle),-2*Radius>,
<0,0>
    rotate x*90
}

#declare CutDisk = difference {
    object { Disk }
    union {
        object { CutOut translate -0.5*x }
        object { CutOut translate 0.5*x }
        object { CutOut translate -1.5*x }
        object { CutOut translate 1.5*x }
    }
}

// Now to the ramps between each floor. We take these to go upwards from our
reference
// disk. Once again, we construct a ramp at the origin where we can use polar
coordinates,
// and we translate it afterwards.
#declare Stairs = parametric {
    function { v*cos(u) },
    function { v*sin(u) },
    // Differentiable stairs:
    function { Height*(cos(pi*(u-(-3*pi/2-Angle))/(2*Angle))+1)/2 }
    <-3*pi/2-Angle,0>, <-3*pi/2+Angle,Radius+1>
    // For whatever reason, the numerics tend to die on one ramp layer without a
fairly low value of 'accuracy' (i.e. high accuracy).
    // Unfortunately, with values lower than the one given below, the rotation
animations die with a segmentation fault.
    accuracy 0.000007
    precompute 10 x,y,z
    contained_by{box{<-Radius,-Radius,-0.1>,<Radius,Radius,1.1>}}
    // It would be neat to let the ramps have filter values but this causes
graining.
    pigment { checker pigment { color rgb <0.9,0.3,0.3> }, pigment{ color rgb
<0.8,0.1,0.1> } }
    finish { phong 0.7 specular 0.6 }
}

// We now translate all the ramps into the slices we cut out of the disks.
// When translating however, the ramps end up sticking out of the cylinder, but
this we can fix
// with a simple simple difference.
#declare DiskWithStairs = union{
    object { CutDisk }
    difference {
        object { Stairs translate -1.5*x }
        object { cylinder { <0,0,-0.1>, <0,0,Height+1.1>, Radius inverse } }
    }
    difference {
        object { Stairs translate -0.5*x }
        object { cylinder { <0,0,-0.1>, <0,0,Height+1.1>, Radius inverse } }
    }
    difference {
        object { Stairs translate 0.5*x }
        object { cylinder { <0,0,-0.1>, <0,0,Height+1.1>, Radius inverse } }
    }
    difference {
        object { Stairs translate 1.5*x }
        object { cylinder { <0,0,-0.1>, <0,0,Height+1.1>, Radius inverse } }
    }
}

union {
    object { DiskWithStairs translate -5*Height*z }
    object { DiskWithStairs translate -4*Height*z }
    object { DiskWithStairs translate -3*Height*z }
    object { DiskWithStairs translate -2*Height*z }
    object { DiskWithStairs translate -1*Height*z }
    object { DiskWithStairs translate 0*z }
    object { DiskWithStairs translate 1*Height*z }
    object { DiskWithStairs translate 2*Height*z }
    object { DiskWithStairs translate 3*Height*z }
    object { DiskWithStairs translate 4*Height*z }
    object { DiskWithStairs translate 5*Height*z }
}


Post a reply to this message

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