Mail Archives: djgpp/1999/11/17/01:14:13
Dear all,
My system is  386SX-40, no math co-processor, 4 MB SIMM RAM, 
and 16 MB Flash Disk (the controller for vehicle navigation system).
I used GCC ver 2.6.3 (gcc263bn.zip) since the latest one doesn't work
on my system. 
I've put "set GO32=emu c:\bin\emu387" in my autoexec.bat for 387 emulation.
I compiled the next source code on my system using the next command:
    gcc model.c -o model -lm
and no errors.
However, I got a wrong result when I run it.
For example:
Inputs:  Current latitude & longitude: 1 1
            Angle between centerline of vehicle and X axis: 0
            Next latitude & longitude: 1 5
Outputs: Distance: 4   (OK)
            Angle between centerline of vehicle and X axis (before): 0 (OK)
	   Steering angle: 87.616783   (wrong result, it should be 90)
            Angle between centerline of vehicle and X axis (after): 87.61676 
               (wrong result, it should be 90)
	        
What could be wrong?
Anyway, I am still hoping to use the latest GCC on my system.
However, every time I run it, my system reboot automatically.
I've followed the advice in section 3.9 of the FAQ for the memory-starved 
systems.
----------------------------------------------------------------------------
-----------------------------------------------
/* Vehicle modeling */
#include <stdio.h>
#include <math.h>
main()
{
	float x_curn, y_curn;
	float x_next, y_next;
	float alpha, distance;
	float beta, beta_next;
	
	printf( "Current latitude & longitude\n" );
	scanf( "%f %f", &x_curn, &y_curn);
	
	printf( "Angle between centerline of vehicle and X axis\n" );
	scanf( "%f", &beta);
	printf( "Next latitude & longitude\n" );
	scanf( "%f %f", &x_next, &y_next );
	
	distance = sqrt ( (x_next-x_curn)*(x_next-x_curn) + 
	                  (y_next-y_curn)*(y_next-y_curn) );
	
	alpha = 180/PI * acos ( (x_next-x_curn) / distance ) - beta;
	
	beta_next = beta + alpha;
	printf( "\nDistance between (%8.6f,%8.6f) and (%8.6f,%8.6f): %8.6f 
	         \nAngle between centerline of vehicle and X axis (before): %8.6f
	          \nSteering angle: %8.6f
	          \nAngle between centerline of vehicle and X axis (after): %8.6f",
	         x_curn, y_curn, x_next, y_next, 
	         distance, beta, alpha, beta_next );
			  
	return 0;
}
----------------------------------------------------------------------------
----------------------------------------------
- Raw text -