POV-Ray : Newsgroups : povray.binaries.images : Ripple Tank Sim : Re: Ripple Tank Sim Server Time
31 Jul 2024 16:22:18 EDT (-0400)
  Re: Ripple Tank Sim  
From: triple r
Date: 11 Aug 2009 19:55:00
Message: <web.4a8203d5f3b84fbd805d39df0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> As an interesting side note, although performing bulk mathematical
> simulation, the SDL script doesn't use a single function (except for
> auxiliary purposes), not a single array, no file #write or #read, and
> only a single control statement (an #if, for special treatment of the
> very first frame). Virtually all it does is render frame after frame of
> the animation.

Sometimes you have to do things the fun way.  That got me thinking.  It's not
POV-Ray, but here's what I came up with.  It should compile on any kind of x11
system.  It's about as short as I could get it with a gui and an interesting
setup.  Not written for clarity (although it's really pretty straightforward).
;-)

 - Ricky

Compile with: 'cc main.c -O3 -L/usr/X11R6/lib -lX11'
Run with: ./a.out

#include <X11/Xlib.h>
#include <math.h>
int main(){int i,j,y=200,p,v;float*a,*b,
*c,*t,f[6*y*y];Display*d=XOpenDisplay(0)
;Window w=RootWindow(d,0);GC g=XCreateGC
(d,w,0,0);w=XCreateSimpleWindow(d,w,0,0,
y*2,y,0,0,0);XMapWindow(d,w);a=f;b=f+2*y
*y;c=f+y*y*4;for(i=0;i<y*y*6;f[i++]=0){}
for(;;++*f){for(i=1;i<y*2-1;i++)for(j=1;
j<y-1;j++){if((fabs(i-y)>1)|(fabs(fabs(j
-y/2)-y/10)<8)){p=i*y+j;p[a]=(b[p-1]+b[p
+1]+b[p-y]+b[p+y])/2-p[c];v=fmin(fmax(a[
p]*500+127,0),255);XSetForeground(d,g,v|
v<<8|v<<16|v<<24);XDrawPoint(d,w,g,i,j);
}}a[y*(1+y)/2]=sin(*f*.4);t=c,c=b,b=a,a=
t;}return 0;}


Post a reply to this message

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