POV-Ray : Newsgroups : povray.general : Buggy trig? Server Time
29 Oct 2024 23:56:56 EDT (-0400)
  Buggy trig? (Message 1 to 10 of 23)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Xplo Eristotle
Subject: Buggy trig?
Date: 3 Jun 2000 20:14:26
Message: <39399F72.5F639DC0@unforgettable.com>
Playing with the animation stuff, I produced this simple scene:

#version unofficial MegaPov 0.5;

camera
	{
	location <0.0, 0, -4>
	look_at <0.0, 0.0, 0.0>
	}

light_source
	{
	<-4, 8, -4>
	rgb .3
	}

text
	{
	ttf "ALIANNA.TTF",
	"RAYTRACING"
	1, <0.0, 0.0, 0.0>
	align_center
	pigment { color rgb <0, 1, 0> }
	rotate <0,-20*(sin(clock*360)),0>
	}

As I understand it, this should produce a nice loop; starting from no
rotation (clock = 0, sin(0) = 0), the right end of the text should be
rotated toward the camera while the left end falls away until a quarter
of the way through the animation, where the rotation reaches -20 degrees
(clock = ~.25, sin(360*.25) = 1). Then, it should rotate back the way it
came until halfway through (sin(360*.5) = 0) and then keep rotating that
direction until 3/4 of the way through the animation where it reaches 20
degrees (sin(360*.75) = -1). And finally, it should rotate back again
until it reaches no rotation.

Problem: it doesn't do this. It seems like the sin function is returning
incorrect values, since when I rendered the animation and dumped the
frames in a GIF animator, the animation didn't describe a full loop.
Instead, it acted as though the function had been sin(clock*270),
starting from no rotation and ending up at 20 degrees rotation.

Can anyone either explain what I'm doing wrong, or reproduce this bug?

-- 
Xplo Eristotle
http://start.at/xplosion/

"And then one day you find ten years have got behind you
No one told you when to run, you missed the starting gun"
    -Pink Floyd


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Buggy trig?
Date: 3 Jun 2000 20:42:49
Message: <3939a609@news.povray.org>
In article <39399F72.5F639DC0@unforgettable.com> , Xplo Eristotle 
<inq### [at] unforgettablecom>  wrote:

> As I understand it, this should produce a nice loop; starting from no
> rotation (clock = 0, sin(0) = 0), the right end of the text should be
> rotated toward the camera while the left end falls away until a quarter
> of the way through the animation, where the rotation reaches -20 degrees
> (clock = ~.25, sin(360*.25) = 1). Then, it should rotate back the way it
> came until halfway through (sin(360*.5) = 0) and then keep rotating that
> direction until 3/4 of the way through the animation where it reaches 20
> degrees (sin(360*.75) = -1). And finally, it should rotate back again
> until it reaches no rotation.

The trigonometric functions use radians which is clearly stated in the
documentation.  See the section about floating-point functions to find out
how to convert from degrees to radians.  However, you can probably solve the
whole thing without using any function and just use rotate (but I don't
understand what you want to do).


      Thorsten


Post a reply to this message

From: Chris Colefax
Subject: Re: Buggy trig?
Date: 3 Jun 2000 20:50:20
Message: <3939a7cc@news.povray.org>
Xplo Eristotle <inq### [at] unforgettablecom> wrote:
> Playing with the animation stuff, I produced this simple scene:
[snip]
> As I understand it, this should produce a nice loop; starting from no
> rotation (clock = 0, sin(0) = 0), the right end of the text should be
> rotated toward the camera while the left end falls away until a quarter
> of the way through the animation, where the rotation reaches -20 degrees
> (clock = ~.25, sin(360*.25) = 1). Then, it should rotate back the way it
> came until halfway through (sin(360*.5) = 0) and then keep rotating that
> direction until 3/4 of the way through the animation where it reaches 20
> degrees (sin(360*.75) = -1). And finally, it should rotate back again
> until it reaches no rotation.
>
> Problem: it doesn't do this. It seems like the sin function is returning
> incorrect values, since when I rendered the animation and dumped the
> frames in a GIF animator, the animation didn't describe a full loop.
> Instead, it acted as though the function had been sin(clock*270),
> starting from no rotation and ending up at 20 degrees rotation.

Or, it seems the sin function is returning the correct values, based on the
fact that it accepts the input angle in radians rather than degrees.  Try
changing your statement to:

   rotate <0,-20*sin(clock*2*pi),0>

and things should work as you expect.


Post a reply to this message

From: Xplo Eristotle
Subject: Re: Buggy trig?
Date: 4 Jun 2000 05:16:30
Message: <393A1E81.CFDE63AD@unforgettable.com>
Chris Colefax wrote:
> 
> Or, it seems the sin function is returning the correct values, based on the
> fact that it accepts the input angle in radians rather than degrees.  Try
> changing your statement to:
> 
>    rotate <0,-20*sin(clock*2*pi),0>
> 
> and things should work as you expect.

Radians? Gah! >_<

That explains a lot. Thanks.

-- 
Xplo Eristotle
http://start.at/xplosion/

"And then one day you find ten years have got behind you
No one told you when to run, you missed the starting gun"
    -Pink Floyd


Post a reply to this message

From: Peter J  Holzer
Subject: Re: Buggy trig?
Date: 4 Jun 2000 12:00:49
Message: <slrn8jkt7v.d52.hjp-usenet@teal.h.hjp.at>
On Sun, 04 Jun 2000 02:43:37 +0100, Thorsten Froehlich wrote:
>The trigonometric functions use radians which is clearly stated in the
>documentation. 

A short history question: Was there a reason for using degrees with
rotate and radians with the trigonometric functions, or did just happen
that way?

	hp

-- 
   _  | Peter J. Holzer    | Nicht an Tueren mangelt es,
|_|_) | Sysadmin WSR       | sondern an der Einrichtung (aka Content).
| |   | hjp### [at] wsracat      |    -- Ale### [at] univieacat
__/   | http://www.hjp.at/ |       zum Thema Portale in at.linux


Post a reply to this message

From: Simen Kvaal
Subject: Re: Buggy trig?
Date: 4 Jun 2000 14:45:19
Message: <393aa3bf@news.povray.org>
>A short history question: Was there a reason for using degrees with
>rotate and radians with the trigonometric functions, or did just happen
>that way?


I'd say it's quite natural that the _functions_ take radians as parameters,
because in mathematics, you rarely use degrees to express angles and/or to
perform trigonometric oerations, to put it that way.

As for the rotations, the degrees is for many a more natural and intuitive
approach to orientation in space. You don't say "turn around pi", but "turn
around 180 degrees." Maybe it would be natural to have alternate
rotate-definitions, accepting radians?

If we started to use degrees instead of radians in the trigonometric
functions, people would be confused, as AFAIK every programming language use
radians. Also, it would be cumbersome to have triginometric functions that
behave differently than the usual. For example, the limit:

limit  sin (x) / x
x->0

is different for the two functions. Functions as arcsin, arctan and so forth
gets trickier to use.

Regards,
Simen Kvaal.


Post a reply to this message

From: Xplo Eristotle
Subject: Re: Buggy trig?
Date: 4 Jun 2000 15:43:16
Message: <393AB164.8B62BCF9@unforgettable.com>
Simen Kvaal wrote:
> 
> >A short history question: Was there a reason for using degrees with
> >rotate and radians with the trigonometric functions, or did just happen
> >that way?
> 
> I'd say it's quite natural that the _functions_ take radians as parameters,
> because in mathematics, you rarely use degrees to express angles and/or to
> perform trigonometric oerations, to put it that way.
> 
> As for the rotations, the degrees is for many a more natural and intuitive
> approach to orientation in space. You don't say "turn around pi", but "turn
> around 180 degrees." Maybe it would be natural to have alternate
> rotate-definitions, accepting radians?

It would be more natural, IMO, to have trig that accepts degrees. When I
was taking trig, we did plenty of work with degrees.. and in fact, since
we specify angles in degrees pretty much everywhere BUT in a classroom -
even my scientific calculator uses degrees by default - I don't see the
point of using radians, which almost no one is familiar with.

I don't WANT to rotate an object by 1/6th pi. I don't *NEED* to rotate
an object by 1/6th pi. But it would be nice to ask for sin(30) and get
.5 back.

(In the spirit of offering a solution, how about a "trig_units" keyword
in the global_settings, where a user could specify "degrees" or "radians"?)

-- 
Xplo Eristotle
http://start.at/xplosion/

"And then one day you find ten years have got behind you
No one told you when to run, you missed the starting gun"
    -Pink Floyd


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Buggy trig?
Date: 4 Jun 2000 18:38:35
Message: <393ada6b@news.povray.org>
In article <slr### [at] tealhhjpat> , 
hjp### [at] SiKituwsracat (Peter J. Holzer) wrote:
> On Sun, 04 Jun 2000 02:43:37 +0100, Thorsten Froehlich wrote:
>>The trigonometric functions use radians which is clearly stated in the
>>documentation.
>
> A short history question: Was there a reason for using degrees with
> rotate and radians with the trigonometric functions, or did just happen
> that way?

In article <393aa3bf@news.povray.org> , "Simen Kvaal"
<sim### [at] studentmatnatuiono> wrote:
> I'd say it's quite natural that the _functions_ take radians as parameters,
> because in mathematics, you rarely use degrees to express angles and/or to
> perform trigonometric oerations, to put it that way.
>
> As for the rotations, the degrees is for many a more natural and intuitive
> approach to orientation in space.

I think this is a good explanation and reasoning.


      Thorsten


Post a reply to this message

From: Rune
Subject: Re: Buggy trig?
Date: 4 Jun 2000 18:43:23
Message: <393adb8b@news.povray.org>
"Xplo Eristotle" wrote:
> It would be more natural, IMO, to have trig that accepts degrees.

I don't see the reason to change how it works or to make new keywords for
it. You can anywhere and anytime use degrees(X) to convert X from radians to
degrees and radians(X) to convert degrees to radians. It's very simple.

> I don't WANT to rotate an object by 1/6th pi. I don't *NEED* to
> rotate an object by 1/6th pi. But it would be nice to ask for
> sin(30) and get .5 back.

Ask for sin(radians(30)) and you get back .5

> (In the spirit of offering a solution, how about a "trig_units"
> keyword in the global_settings, where a user could specify
> "degrees" or "radians"?)

I think it will cause only more trouble. If your scene uses degrees and you
want to use an include file that uses radians you would have to change the
global_settings several times.

And when we in these groups want to help others with trig related problems
we would always have to ask things like, "Did you remember to set trig_units
to 'degrees'?".

I think it is fine as it is.

Greetings,

Rune

---
Updated April 25: http://rsj.mobilixnet.dk
Containing 3D images, stereograms, tutorials,
The POV Desktop Theme, 350+ raytracing jokes,
miscellaneous other things, and a lot of fun!


Post a reply to this message

From: John VanSickle
Subject: Re: Buggy trig?
Date: 4 Jun 2000 19:06:08
Message: <393AE07D.DE80EE@erols.com>
Xplo Eristotle wrote:
> 
> I don't WANT to rotate an object by 1/6th pi. I don't *NEED* to rotate
> an object by 1/6th pi.

Me neither.  I always do it this way:

  matrix <1,0,0, 0,sqrt(.75),.5, 0,-.5,sqrt(.75), 0,0,0>

-- 
ICQ: 46085459


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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