POV-Ray : Newsgroups : povray.binaries.images : Rotating Squares problem : Re: Rotating Squares problem Server Time
12 Aug 2024 07:28:48 EDT (-0400)
  Re: Rotating Squares problem  
From: Mike Williams
Date: 8 Oct 2003 15:32:36
Message: <qgiG2GAyXGh$EwK3@econym.demon.co.uk>
Wasn't it Patrick Dugan who wrote:
>I would like any help someone can give regarding a math problem in Povray.
>
>I have included an image of what I'm trying to accomplish, however it's
>never quite perfect.  I'm trying to start with a small square in the center
>(1x1 size) and increase its size to 5x5 and rotate the square as I go.  I
>want the squares to match up so each square corner perfectly matches up with
>a line on the next larger square.  Basically end up with a curving line made
>of many squares. I'm doing it all by trail and error and never getting it
>clean enough.  The square image here is small and doesn't show the
>discrepancies as much, but once it is increased in size it never lines up
>cleanly. Is there a math formulae to create this?  Is there a name for this
>type of thing?

I can work out the math for calculating what the correct amount of
rotation (Z) should be, given the values for your "Reduction" variable,
like this (using the unincremented value of X):

// Length of new hypotenuse
   #declare H = X + Reduce;

// solve simultaneous equations A+B=H, A^2 + B^2 = X^2
// (By substituting "H-A" for "B", moving everything
// over the left hand side and using the standard
// quadratic equation solver for A.
   #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));

// then increment X
   #declare X = X + Reduce;


The problem then is that when you create the fan, the 5x5 square is
significantly past vertical.

I did some experiments with different initial values of "Reduction" and
its increment, (changing the while clause to "#while (Z <= 90)" helps)
but it seems that the squares want to become vertical again at a size
between 3.9 and 4.4 rather than 5. To get the size close to 5x5 I had to
use very low values for "Reduction" and its increment, which causes
hundreds of squares to be generated.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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