POV-Ray : Newsgroups : povray.binaries.images : Rotating Squares problem Server Time
12 Aug 2024 11:14:04 EDT (-0400)
  Rotating Squares problem (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: None
Subject: Re: Rotating Squares problem
Date: 8 Oct 2003 16:10:36
Message: <Xns940EA48DB33F6None@204.213.191.226>
"Patrick Dugan" <pat### [at] netinsnet> wrote in
news:3f844537@news.povray.org: 

> I would like any help someone can give regarding a math problem in
> Povray. 

Sounds like a trig. problem...

I think Reduce should simply be set to something like:

#declare Reduce = X * tan(radians(4.725));


Post a reply to this message

From: Jellby
Subject: Re: Rotating Squares problem
Date: 8 Oct 2003 16:20:19
Message: <3f847181@news.povray.org>
Among other things, Patrick Dugan 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?

If I have understood it correctly, this is what you want (see picture 
attached).

The green corner (top-right) is the center of the squares, so that what you 
see are just the lower-left quadrants. The black square is the "old" (and 
smaller) one, with side L, the red square is a larger one (side L+x) laid 
over the black one and rotated.

As it is drawn, the cosine of the angle alpha is (L+x)/(sqrt(2)*L), but 
you're interested in angle beta, which is:

beta = 45 - degrees(acos( (L+x)/(sqrt(2)*L) ))
beta = 45 - degrees(acos( (1+x/L)/sqrt(2) ))

If, as it seems, you want to make the squares smaller and smaller, just 
substitute L+x -> L and L -> L-x:

beta = 45 - degrees(acos( L/(sqrt(2)*(L-x)) ))

... unless I've made a mistake...

-- 
light_source{9+9*x,1}camera{orthographic look_at(1-y)/4angle 30location
9/4-z*4}light_source{-9*z,1}union{box{.9-z.1+x clipped_by{plane{2+y-4*x
0}}}box{z-y-.1.1+z}box{-.1.1+x}box{.1z-.1}pigment{rgb<.8.2,1>}}//Jellby


Post a reply to this message


Attachments:
Download 'sample.gif' (11 KB)

Preview of image 'sample.gif'
sample.gif


 

From: Patrick Dugan
Subject: Re: Rotating Squares problem
Date: 8 Oct 2003 16:23:47
Message: <3f847253$1@news.povray.org>
Thanks!    Replacing that line in the code seems to have worked well.


"None" <Non### [at] onca> wrote in message
news:Xns### [at] 204213191226...
> "Patrick Dugan" <pat### [at] netinsnet> wrote in
> news:3f844537@news.povray.org:
>
> > I would like any help someone can give regarding a math problem in
> > Povray.
>
> Sounds like a trig. problem...
>
> I think Reduce should simply be set to something like:
>
> #declare Reduce = X * tan(radians(4.725));


Post a reply to this message

From: None
Subject: Re: Rotating Squares problem
Date: 8 Oct 2003 17:14:31
Message: <Xns940EAF638C27CNone@204.213.191.226>
"Patrick Dugan" <pat### [at] netinsnet> wrote in news:3f847253$1
@news.povray.org:

> Thanks!    Replacing that line in the code seems to have worked well.

Great, I'm glad I could help.


Post a reply to this message

From: Remco de Korte
Subject: Re: Rotating Squares problem
Date: 8 Oct 2003 17:49:48
Message: <3F8485E7.921829B0@onwijs.com>
Patrick Dugan wrote:
> 
> I would like any help someone can give regarding a math problem in Povray.
> 

I didn't quite follow the source posted here and saw that your problem
is already solved but since I've been struggling with the exact same
things some time ago and only barely worked it out, by trial and error,
it struck me now that there might be a fairly simple solutions: drop the
rotation part!
Start with the bottom square (or box), move from the corner along the
side for a fixed percentage of the side length, do that for every side
(in the same direction). The four resulting points will form a new
square. 
Put this in a recursive macro and there you go.

Toch? Jan?

Remco


Post a reply to this message

From: Samuel Benge
Subject: Re: Rotating Squares problem
Date: 9 Oct 2003 12:12:12
Message: <3F8588D8.6080308@hotmail.com>
I'm unschooled in the field of traditional trigonomentry usage.... where 
did you get the number 4.725?

None wrote:

> I think Reduce should simply be set to something like:
> 
> #declare Reduce = X * tan(radians(4.725));
> 


-- 
Samuel Benge

stb### [at] hotmailcom


Post a reply to this message

From: Patrick Dugan
Subject: Re: Rotating Squares problem
Date: 9 Oct 2003 21:15:47
Message: <3f860843$1@news.povray.org>
The number wasn't significant.  I simply testing various Z axis rotation
sizes and by trial and error (mostly error) ended up on that number.

"Samuel Benge" <sbe### [at] hotmailcom> wrote in message
news:3F8### [at] hotmailcom...
> I'm unschooled in the field of traditional trigonomentry usage.... where
> did you get the number 4.725?
>
> None wrote:
>
> > I think Reduce should simply be set to something like:
> >
> > #declare Reduce = X * tan(radians(4.725));
> >
>
>
> -- 
> Samuel Benge
>
> stb### [at] hotmailcom
>


Post a reply to this message

From: None
Subject: Re: Rotating Squares problem
Date: 10 Oct 2003 08:44:44
Message: <Xns941058FAA5D0BNone@204.213.191.226>
Samuel Benge <sbe### [at] hotmailcom> wrote in news:3F8588D8.6080308
@hotmail.com:

> I'm unschooled in the field of traditional trigonomentry usage.... where 
> did you get the number 4.725?

That was simply the angle Patrick was rotating by, I pluged in the angle he 
was using in his code into a standard trig. equation:

tan(angle) = Opposite/Adjacent.

Trigonometry is the measurement of triangles.  A square can be broken down 
into eight right angle triangles.  In the eighth of a square, the Opposite 
(O) and Adjacent (A) are the same.  So if you change the angle while 
keeping O or A the same, it will tell you how much the new A or O should 
be.

Search the net for "trigonometry sin cos tan" for explanations of 
trigonometry.


Post a reply to this message

From: Tim Cook
Subject: Re: Rotating Squares problem
Date: 10 Oct 2003 10:34:37
Message: <3f86c37d$1@news.povray.org>
None wrote:
> Trigonometry is the measurement of triangles.  A square can be broken down 
> into eight right angle triangles.  In the eighth of a square, the Opposite 
> (O) and Adjacent (A) are the same.  So if you change the angle while 
> keeping O or A the same, it will tell you how much the new A or O should 
> be.

For efficiency, it's easier to just break a square into two triangles.
^_^  Also in a square you can't change the angles, or it ceases to be
a square.  They will always be 45 and 90 degrees.


Post a reply to this message

From: None
Subject: Re: Rotating Squares problem
Date: 10 Oct 2003 11:12:37
Message: <Xns9410720C8A5DBNone@204.213.191.226>
Tim Cook <z99### [at] bellsouthnet> wrote in
news:3f86c37d$1@news.povray.org: 

> For efficiency, it's easier to just break a square into two triangles.
> ^_^  Also in a square you can't change the angles, or it ceases to be
> a square.  They will always be 45 and 90 degrees.

Efficiency?  In this case the square is centered at the origin, that's 
where it's rotated from, so that's where the angle is, so we are dealing 
with the eigtht, but we only care about _one_ triangle.  If you want to 
just use two triangles to solve this case, you're going to have to do 
more math, which would be innefficient.

Of course a square's triangle angle can't change, that is exactly what we 
are taking advantage of in this case.  I said: the opposite and adjacent 
sides are the same, so the angle is obviously fixed.  In this case, if 
the angle changes, we are determining by how much we need to adjust the 
sides to keep the angle constant.

It sounds like you took my message completely out of context.  I was 
reffering to the problem at hand, the original question.


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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