POV-Ray : Newsgroups : povray.binaries.animations : POVigma: I just can't get it right! : Re: POVigma: I just can't get it right! Server Time
26 Apr 2024 01:48:10 EDT (-0400)
  Re: POVigma: I just can't get it right!  
From: Le Forgeron
Date: 29 Aug 2015 13:30:23
Message: <55e1ec2f$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 29/08/2015 18:02, "Jörg \"Yadgar\" Bleimann" a écrit :
> Hi(gh)!
> 
> And I thought I got it right... forget about it! While with
> speed=0.1 and starting angle=60 degrees all went fine, with
> speed=0.25 and starting angle=340 degrees, at frame 219 the script
> starts to behave bizarrely. As you can see in the attached video
> clip, the ball bounces off a non-existing "horizontal" wall and
> then moves through the eastern wall...
> 
> This is the collision detecting routine:
> 
> #declare rows=0; // check for collision with any stone #while (rows
> < LevelLength) #declare cols=0; #while (cols < LevelWidth) //
> #warning concat("row: ", str(rows, 1, 0), ", col: ", str (cols, 1,
> 0)) #if (layer2_array[rows][cols] = 1 | layer3_array[rows][cols] >=
> 20) #declare xmin=cols-0.35; #declare xmax=cols+1+0.35; #declare
> zmin=rows-0.35; #declare zmax=rows+1+0.35; // horizontal obstacles 
> #if (ballpos_next.x >= xmin & ballpos_next.x <= xmax & 
> ballpos_next.z >= zmin & ballpos_next.z <= zmax & (ballpos.z < zmin
> | ballpos.z > zmax)) #declare dir = 180-dir; #declare hit=1; 
> #break #end // vertical obstacles #if (ballpos_next.x >= xmin &
> ballpos_next.x <= xmax & ballpos_next.z >= zmin & ballpos_next.z <=
> zmax & (ballpos.x < xmin | ballpos.x > xmax)) #declare dir = -dir; 
> #declare hit=1; #break #end #end #declare cols=cols+1; #end #if
> (hit) #break #end #declare rows=rows+1; #end
> 
> These are the values at frame 219:
> 
> xmin = 18.65 xmax = 20.35 zmin = 3.65 zmax = 5.35
> 
> ballpos = <18.6344,0,4.38568> ballpos_next = <18.7199,0,4.15076>
> 
> Now let's check both #if conditions:
> 
> Horizontal ("west-east") obstacles: #if (ballpos_next.x >= xmin &
> ballpos_next.x <= xmax & ballpos_next.z >= zmin & ballpos_next.z <=
> zmax & (ballpos.z < zmin | ballpos.z > zmax))
> 
> ballpos_next.x >= xmin TRUE ballpos_next.x <= xmax TRUE 
> ballpos_next.z >= zmin TRUE ballpos_next.z <= zmax TRUE ballpos.z <
> zmin FALSE ballpos.z > zmax FALSE
> 
> ...so the following block should NOT be executed! But in fact it
> does! Why? WHY?? WHY??? Am I too feeble-minded to understand
> this?!?
> 

Rewrite the loop to avoid #break, using #else instead... might help.

> See you in Khyberspace!
> 
> Yadgar

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlXh7C4ACgkQhKAm8mTpkW3rLQQArvsbl6tEbbwHuUmAkSYFiZKH
eSDZ6jSnFX78/0bQATUr4TYfxyFVDzzxNtQnBKwPtGAVZJI+sxYDTvvdex/uHJcg
vFsGGY04Cd7A5amvzISQrVvZW3BkraXi0ajwciUPXtSEJC1twTqrkDvE05dcdDE7
GziC13EJRVXzCusPRBs=
=GBOg
-----END PGP SIGNATURE-----


Post a reply to this message

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