POV-Ray : Newsgroups : povray.text.scene-files : Obvious joins : Re: Obvious joins Server Time
3 Jul 2024 01:51:45 EDT (-0400)
  Re: Obvious joins  
From: Tor Olav Kristensen
Date: 8 Oct 2001 20:15:20
Message: <3BC241CF.7D263ECD@hotmail.com>
Rob Brown-Bayliss wrote:
> 
> Hi, I have a macro (follows) that I am useing to try and make 
> corogated sheets with.
> 
> The problem is there are obvoius joins along the sheets, how can I
> remove these so that it actually looks like a single sheet?
>...

Below is a macro I just made that will work in 
a similar way as yours. And I think that it
doesn't have the same problems as yours.

It got quite big and kind of ugly, so I have
tried to comment it a bit (in case you want to
have a closer look at it).

The macro takes an extra parameter that is the
angle that the "upper" and "lower" parts of
the waves runs trough. (Hmmm... Bad explanation
- Try the different settings below to see how
it works.)


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// By Tor Olav Kristensen
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#version 3.1;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#macro WavySheet(Length, Width, T, Radius, Angle)

  #local O = // O-shape
  difference {
    cylinder { -z*Length/2, z*Length/2, Radius + T/2 }
    cylinder { -z*Length,   z*Length,   Radius - T/2 }
  }
  #local U = // U-shape 
  difference { // Make it by cutting in the O-shape
    object { O } 
    #switch (Angle) // Decide what to cut away
      #case (0)         // Remove all
        cylinder { -z*Length, z*Length, Radius + T }
        #break
      #case (180)       // Remove half
        plane { x, 0 }
        #break
      #range (0, 180)   // Remove more than half
        plane {  x, 0 }
        plane { -x, 0 rotate Angle*z }
        #break
      #case (360)       // Remove nothing
        #break
      #range (180, 360) // Remove less than half
        intersection {
          plane {  x, 0 }
          plane { -x, 0 rotate Angle*z }
        }
        #break
      #else // The angle is less than 0 or greater than 360 degrees
        #error "Macro WavySheet: Angle out of range"
    #end // switch
    translate Radius*y // "Elevate" it so that the "rim" touches origo
    rotate -Angle/2*z // Tilt sideways so that the U lies horizontal
  }
  #local S = // S-shape
  union { // Make it from two U-shapes that both "starts" at origo
    object { U }
    object { U rotate 180*z }
  }
  #local vP = vrotate(Radius*y, -Angle/2*z);
  #local W = 4*vP.x;            // "Width" of the S-shape
  #local H = 2*(Radius - vP.y); // "Heigth" of the S-shape
  #declare Nr = int(Width/W); // Number of S-shapes to add to each side
  #if (Nr <= 0) // Only one S-shape is required
    #local Waves = object { S }
  #else         // More than one S-shape is required 
    #local Waves = 
    union {
      object { S } // So put one in the middle
      #local Cnt = 1;
      #while (Cnt <= Nr) // And then add some more to each side
        object { S translate -Cnt*W*x }
        object { S translate  Cnt*W*x }
        #local Cnt = Cnt + 1;
      #end // while
    }
  #end // if

  object { 
    Waves
    clipped_by {
      box {
        -<Width, H + T, Length>,
         <Width, H + T, Length>
         scale <1, 1, 1 + 1E-6>/2
      }
    }
    bounded_by { clipped_by }
  }

#end // macro WavySheet

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#declare LENGTH = 6;
#declare WIDTH = 8;
#declare THICKNESS = 0.3;
#declare RADIUS = 2;
#declare ANGLE = 70;

/*
// Uncomment to see antoher wave shape
#declare LENGTH = 4;
#declare WIDTH = 10;
#declare THICKNESS = 0.2;
#declare RADIUS = 2;
#declare ANGLE = 210;
*/

/*
// And then a quite different shape
#declare LENGTH = 0.5;
#declare WIDTH = 14;
#declare THICKNESS = 0.1;
#declare RADIUS = 3;
#declare ANGLE = 345;
*/


object {
  WavySheet(LENGTH, WIDTH, THICKNESS, RADIUS, ANGLE)
  pigment { color White }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

light_source { <1, 2, -3>*100 color White }

camera {
  location <0, 0, -10>
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =


Post a reply to this message

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