POV-Ray : Newsgroups : povray.binaries.images : Re: Rotating Squares problem : Re: Rotating Squares problem Server Time
15 Nov 2024 00:20:50 EST (-0500)
  Re: Rotating Squares problem  
From: Mike Williams
Date: 9 Oct 2003 02:12:35
Message: <3f84fc53@news.povray.org>
I ran some code which calculated some mathematically correct spirals and set
a scoring system based on the following criteria:

  There are a reasonable number of iterations
  The rotation of the outer square is close to 90 degrees
  The size of the outer square is close to 5x5

Any two of these conditions can be met easily, but it looks like this is
about as close as you can get to satisfying all three while maintaining
mathematically correct placement.

In this image there are 47 squares, the final square is rotated by 89.994
degrees and the length of its side is 4.564

I've posted a PNG image because any JPG that didn't have absolutely awful
compression artefacts was considerably larger than this PNG.

#include "colors.inc"
#include "textures.inc"
#include "metals.inc"

#version 3.5;
global_settings {
   assumed_gamma 2.2
   max_trace_level 25
}

light_source {< 500, 500, -500> White * 1.0}

background {White}

camera {orthographic
   location <0,0,-7>
   look_at  <0,0,3>
}

#declare WallTex =  texture {pigment {Red} finish {ambient 0.5}}

#declare X = 1;
#declare Z = 0;
#declare N = 0;
#declare WallFan =
union {
   #while (Z <= 90)
      difference {
         box {<-X,-X,-0.01>,<X,X,0.01> texture {WallTex}}
         box {<-X+0.05,-X+0.05,-0.02>,<X-0.05,X-0.05,0.02> texture
{WallTex}}
         rotate <0,0,Z>
      }
      // Length of new hypotenuse
      #declare H = X * 1.032 + 0.003;
      // solve simulataneous equations A+B=H, A^2 + B^2 = X^2
      #declare A = (2*H + sqrt(4*H*H  - 8*(H*H - X*X)))/4;
      // use trig to find the angle
      #declare Z = Z + degrees(acos(A/X));
      #declare X = H;
   #end
}

object {WallFan}

// Size reference box behind wall fan
box {<-5,-5,-0.005>,<5,5,0.005> pigment {Blue}}


Post a reply to this message


Attachments:
Download 'WallFan.png' (129 KB)

Preview of image 'WallFan.png'
WallFan.png


 

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