POV-Ray : Newsgroups : povray.binaries.images : Rotation matrices : Re: Rotation matrices Server Time
3 May 2024 01:46:42 EDT (-0400)
  Re: Rotation matrices  
From: Tor Olav Kristensen
Date: 3 Mar 2023 13:25:00
Message: <web.64023b43565eea12d105cea189db30a9@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > > ...  I would also like to figure out if there's a nice
> > > degrees-to-fractions-of-pi algorithm out there, and I could implement that.
> > > I'll probably just hard-code an array of text objects.
> >
> > You can divide the angle by 180 and convert the resulting decimal number to a
> > fraction. Then you can use David Eppstein's "find rational approximation to
> > given real number" code as suggested in the first answer here:
> >
> >
https://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions
>
>
> I tried at least 2 different ways to go about this, but I didn't have any
> success and fell into some kind of trap in the recursion programming that
> short-circuits things.   It was a mess that I spent too many hours trying to
> fix.
>
> I have more application cases that I'd like to apply this sort of thing to, if
> you give me a nudge in the proper direction.

I just had a look at you code and found that perhaps you are
misunderstanding what the value of this C expression is:

(ai = (long)x)

This is an assignment, where the value in X is converted to an
unsigned long int, then converted to the type of ai (which is
also an unsigned long int) and then stored in ai. The value of
the whole parenthesis expression is now equal to ai and can be
used in further calculations.

See this page:
https://stackoverflow.com/questions/9514569/what-does-an-assignment-return

In POV-Ray's SDL this expression:

(ai = x)

- is a comparison that is true when ai equals x and false otherwise.
So the value of the parenthesis expression is either 0 (for false)
or 1 (for true).

See "Relational expressions" (and the text right before) here:
https://wiki.povray.org/content/Reference:Numeric_Expressions

Also, you should call your macros with the second argument
(for the d parameter) greater than or equal to the greatest
denominator that you will accept. I.e. If you will accept
denominators up to 100, then pass 100 (not something small as
0.000001).

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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