Subversion Repositories svnkaklik

Compare Revisions

Regard whitespace Rev 648 → Rev 649

/programy/C/ix86/echo/SW/sonar/src/sonar.c/sonar.c
20,7 → 20,8
 
#define SOUND_SPEED 340.0 // sound speed in air in metrs per second
#define MAX_RANGE 10.0 // maximal working radius in meters
#define APERTURE 0.2 // distance between microphones
#define Xl -0.1 // microphones position
#define Xr 0.1
 
static char *device = "plughw:0,0"; /* playback device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
278,7 → 279,8
echo_map = malloc(3*period_size*period_size * sizeof(float)); // Array to store two dimensional image of echos
if (echo_map == NULL) printf("Can't allocate enought memory");
 
k = SOUND_SPEED/rate;
k = SOUND_SPEED/rate; // normalising constant
 
// generate ping pattern
chirp_size = linear_windowed_chirp(chirp);
 
374,8 → 376,8
for(j=0;j < period_size; j+=10)
{
b=k*j;
echo_map[m]=(a*a-b*b+APERTURE*APERTURE)/(2*APERTURE);
echo_map[m+1]=sqrt((a-b-APERTURE)*(a+b-APERTURE)*(a-b+APERTURE)*(a+b+APERTURE))/(2*r);
echo_map[m]=(-a*a+b*b+Xl*Xl+Xr*Xr)/(2*Xl-2*Xr);
echo_map[m+1]=sqrt((a-b-Xl-Xr)*(a+b+Xl+Xr)*(a-b-Xl+Xr)*(a-b-Xl+Xr)*(a+b-Xl+Xr))/(-2*(Xl-Xr));
echo_map[m+2]=correlationl[i]*correlationr[j];
m+=3;
}
418,7 → 420,7
 
j=0;
out=fopen("/tmp/plane_cut.txt","w"); // writes plane cut - e.g. density map to file
for (i=0;i < period_size*period_size; i++)
for (i=0;i < period_size*period_size/100; i++)
{
fprintf(out,"%3.3f %3.3f %3.3f\n", echo_map[j], echo_map[j+1], echo_map[j+2]);
j+=3;