POV-Ray : Newsgroups : povray.newusers : Trig problem Server Time
27 Nov 2024 07:33:08 EST (-0500)
  Trig problem (Message 1 to 4 of 4)  
From: Will W
Subject: Trig problem
Date: 16 Mar 2003 15:49:00
Message: <3e74e33c@news.povray.org>
I didn't notice anything about this in the FAQs I've seen, and it might not
be a POV problem.

The rotate command isn't working the way I expect on my system. Here is a
simple test that fails for me:

// --   begin code --
light_source { <0,0,-10> rgb 1 parallel }
plane { -z, -1 pigment { checker rgb 1, rgb 0.8 } }
camera { location <5, 2.5, -5>  look_at  <2.5, 2.5, 1>  angle 67 }

// baseline of points:
// up 2 units for each unit over:
// 60 degree slope (verify by shadow)
union {
   #declare I = 0;
   #while (I < 6)
      sphere { <0,0,0>, 0.1 pigment { rgb <1,0,0> } translate <0.5*I, I,
0> }
      #declare I = I+1;
   #end
}

// This should intersect each point
cylinder {<0,0,0>, <5,0,0>, 0.075 pigment { rgb <0,0,1> } rotate 60*z }
//--  end code --

Instead of the cylinder intersecting each point as I would expect, it
appears to have rotated only about 58 degrees. (The parallel light shadows
on the checker background demonstrate that the points are being placed
correctly). This is on a Dell 4400 using a Pentium 4 at 1.6 GHz, with 256 Mb
ram.

So are Intel's FP trig routines messed up that badly? My googling shows some
concerns with 15th digit accuracy with Intel's basic sin and cos, but what
I'm seeing looks like at least ten orders of magnitude worse than that.

Is POV somehow at fault? If so, what work-arounds are there?

Is there (yet another) gaping hole in what I remember from my long ago trig
courses?


--
Will Woodhull
Thornhenge, SW Oregon, USA
willl.at.thornhenge.net


Post a reply to this message

From: Warp
Subject: Re: Trig problem
Date: 16 Mar 2003 16:13:11
Message: <3e74e8e6@news.povray.org>
You have a mistake in your thinking.

  The slope of a line rotated 60 degrees is not 2 (ie. for each unit in
the x direction the line goes up 2 units).

  The fact that the cosine of 60 degrees is 0.5 confused you.

  The slope of a line rotated by 60 degrees is sin(60)/cos(60) which
is about 1.7320508027 (quite different from 2).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Mike Williams
Subject: Re: Trig problem
Date: 16 Mar 2003 16:21:13
Message: <GweJACAPqOd+EwLB@econym.demon.co.uk>
Wasn't it Will W who wrote:
>I didn't notice anything about this in the FAQs I've seen, and it might not
>be a POV problem.
>
>The rotate command isn't working the way I expect on my system. Here is a
>simple test that fails for me:
>
>// --   begin code --
>light_source { <0,0,-10> rgb 1 parallel }
>plane { -z, -1 pigment { checker rgb 1, rgb 0.8 } }
>camera { location <5, 2.5, -5>  look_at  <2.5, 2.5, 1>  angle 67 }
>
>// baseline of points:
>// up 2 units for each unit over:
>// 60 degree slope (verify by shadow)
>union {
>   #declare I = 0;
>   #while (I < 6)
>      sphere { <0,0,0>, 0.1 pigment { rgb <1,0,0> } translate <0.5*I, I,
>0> }
>      #declare I = I+1;
>   #end
>}
>
>// This should intersect each point
>cylinder {<0,0,0>, <5,0,0>, 0.075 pigment { rgb <0,0,1> } rotate 60*z }
>//--  end code --
>
>Instead of the cylinder intersecting each point as I would expect, it
>appears to have rotated only about 58 degrees. (The parallel light shadows
>on the checker background demonstrate that the points are being placed
>correctly). This is on a Dell 4400 using a Pentium 4 at 1.6 GHz, with 256 Mb
>ram.
>
>So are Intel's FP trig routines messed up that badly? My googling shows some
>concerns with 15th digit accuracy with Intel's basic sin and cos, but what
>I'm seeing looks like at least ten orders of magnitude worse than that.
>
>Is POV somehow at fault? If so, what work-arounds are there?
>
>Is there (yet another) gaping hole in what I remember from my long ago trig
>courses?

POV is correct, it's your trig that's wrong. The angle that goes up 2
for each 1 across is atan(2)=63.4349 degrees. A 60 degree angle goes 2
along the *diagonal* for each 1 across, which is slightly different.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Will W
Subject: Re: Trig problem
Date: 16 Mar 2003 16:57:37
Message: <3e74f351@news.povray.org>
Thanks, Warp and Mike, for setting me straight. I'm going to write on the
blackboard fifty times:

        The "side opposite" is NOT the "hypoteneuse".

--
Will Woodhull
Thornhenge, SW Oregon, USA
willl.at.thornhenge.net


Post a reply to this message

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