quantum simulation (collision)

         Quantum-Scheduler

A. Second Edition
This is purely for fun. You see, whenever there is an exam and I feel nervous the best way for me to do is just
write some free-lance program such that my brain is fully occupied and forget anything at all. And this is just
an extension of the first edition. Assuming there are some quantum inside a "room" and what will they do? I made 
a slightly change after my second edition in order to prove my argument with my classmates of Mr. Zheng and Mr. Li.
Mr. Zheng thought the angle after collision of two quantum must always be 90 degree. And Mr. Li also made a wrong 
proof about this claim. I spent one half night to prove they are wrong. Also I made a slightly change on the 
initialization of both quantum's speed and coord so that they can be float number instead of integer. And I allow
some quantum to be of speed of zero.
And I also made a quite detailed explanation of my major functions of collision, if you understand Chinese.
After I re-think, I realized that I made a stupid mistake and Mr. Li is correct with his proof. If one ball has 
speed of zero, then their angle after collision will be definitely 90 degree. 
B.The problem
The starts long time ago. Once I noticed in Dr. Grogono's web page that these is fancy "snooker" game. And in my
boring "chem 205" course, the professor mentioned so much about collision of molecular. So, they become inspiration
for me to write this simple program to simulate the collision of quantum, assuming both moment and energy are
conserved. In other words, it is the ideal collision.
To implement quantum, I went such a long way to override various operators of Vector class. The only thing worth
mentioning is the "*" operator between two vectors. It is weird and I just do it by instinct to reduce my code.
The physical meaning is not very justified: V(x1,y1)*U(x2,y2) = x1*x2+y1*y2 ==>a number!
 
There are two kinds of actions happened inside the "room": collision and bouncing. Quantum can collide with each
other and they can bounce one the wall of room. Both actions are "ideal" one which means no energy losses. 
How to schedule the CHAOES?
I think about it for several days and have to come back to the simple old way: whenever there is an event, we have
to reschedule everything. You see, originally I thought it is low efficient to reschedule everything all the time.
But you cannot predict and every event is like chain reaction that will affect other quantum, possibly.
 
To sketch the activity is difficult with text mode. This is one motivation for me to learn more about graphics.  
 
C.The idea of program

I didn't expect myself to stick to this seemingly simple little game for more than eight hours long. I am really starving to death now.

Am I becoming more and more slow in programming? I began to worry about this.

D.The major functions
The only complicated function is the "collide" which first check if there is possibility of collision by calling
function of "collisionTime" which returns the time to be collided, -1 indicating impossible to collide.
Then two colliding quantum "flyto" the position of colliding site where they exchange energy, moment. After that
collision, both speeds are changed while energy and moment conserves.
The collisionTime function tries to find the time when distance between two quantum is the sum of their radius.
(Here I made an interesting mistake. At first, among the two square roots, I choose the positive one and the 
result confused me for quite a long time since the two quantum collides from impossible angle. Then I realized
that I should choose the smaller root. However, does it matter if I change the original beginning coordinates?)
I only made a simple test since I am starving now after eight hours' struggle.
E.Further improvement
 
F.File listing
1. vector.h
2. vector.cpp
3. quantum.h
4. quantum.cpp
5. scheduler.h
6. scheduler.cpp
7. main.cpp
 
file name: vector.h
#ifndef VECTOR_H
#define VECTOR_H

struct Vector
{
	double x;
	double y;
	void set(double theX, double theY){x=theX; y=theY;}
	Vector operator -(Vector& other);
	Vector& decrement(Vector& other);
	Vector operator +(Vector& other);
	Vector& increment(Vector& other);
	Vector& operator =(Vector& other);
	Vector& multiply(double scalor);
	bool operator ==(Vector& other);
	Vector(double theX=0, double theY=0);
	double length();
	double sqrLength();
	Vector operator *(double scalor);
	double operator *(Vector& other);
	void display();
};

#endif
 


file name: vector.cpp
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "quantum.h"

Vector& Vector::decrement(Vector& other)
{
	x-=other.x;
	y-=other.y;
	return *this;
}

Vector& Vector::increment(Vector& other)
{
	x+=other.x;
	y+=other.y;
	return *this;
}

Vector& Vector::multiply(double scalor)
{
	x*=scalor;
	y*=scalor;
	return *this;
}

Vector::Vector(double theX, double theY)
{
	x=theX;
	y=theY;
}

Vector Vector::operator +(Vector& other)
{
	Vector result;
	result.x= x+other.x;
	result.y= y+other.y;
	return result;
}

Vector Vector::operator -(Vector& other)
{
	Vector result;
	result.x= x-other.x;
	result.y= y-other.y;
	return result;
}

Vector& Vector::operator =(Vector& other)
{
	x= other.x;
	y= other.y;
	return *this;
}

double Vector::operator *(Vector& other)
{
	return x*other.x+y*other.y;
}

Vector Vector::operator *(double scalor)
{
	Vector result;
	result.x = x*scalor;
	result.y = y*scalor;
	return result;
}

bool Vector::operator ==(Vector& other)
{
	return x==other.x && y==other.y;
}

double Vector::sqrLength()
{
	return (x*x+y*y);
}

double Vector::length()
{
	return sqrt(x*x+y*y);
}

void Vector::display()
{
	printf("(%f, %f)", x, y);
}
 

file name: quantum.h
#ifndef QUANTUM_H
#define QUANTUM_H

#include "vector.h"

#define INFINITE 1000
#define ABS(x)  (x>=0?x:x)

enum Direction
{
	Right, Up, Left, Down
};

const double DefaultStartMoment=0;
const double DefaultRadius=1;
const double DefaultSpeed=5;
const double DefaultStartPos=0;

//forward declaration
class Scheduler;

struct Room
{
	Vector upperLeft;
	Vector downRight;
};

//assume the quantum always has same mass, it is much simple
class Quantum 
{
	friend class Scheduler;
protected:
	Vector coord;
	Vector speed;
	double elapsed;
	double radius;
	void initialize();
public:
	Quantum(Vector& position, Vector& theSpeed, double theMoment, double theRadius);
	Quantum();
	double distance(Quantum& other);
	void setRadius(double newRadius){radius=newRadius;}
	void setSpeed(double vx, double vy){speed.set(vx, vy);}
	void setSpeed(Vector& speedVector){speed=speedVector;}
	void setPos(double px, double py){coord.set(px, py);}
	void setPos(Vector& posVector){ coord=posVector;}
	void setMoment(double now){elapsed=now;}
	double collisionTime(Quantum& other);//return the time
	Vector fly(double elapse);//the pos vector quantum will fly to
	void flyto(double elapse);
	void collide(Quantum& other);
	double bounceTime(Room& wall);
	void display();
	void bounce(Room& wall);
	double speedAngle();
};

#endif
 
		
file name: quantum.cpp
#include "scheduler.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

Scheduler::Scheduler(int number)
{
	qNumber=number;
	initialize();
}

void Scheduler::setRandom(double& target, double base, double shift)
{	
	double percent;
	percent=(double)(rand()%100)/100.0;
	target=base+shift*percent;
}

void Scheduler::uninitialize()
{
	int i;
	for (i=0; i<qNumber; i++)
	{
		free(grid[i]);
		//free(displayMem[i]);
	}
	for (i=0; i<height; i++)
	{
		free(displayMem[i]);
	}
	free(grid);
	free(quantums);
	free(collisionList);
	free(bounceList);
	free(displayMem);
}


void Scheduler::initialize()
{
	int i;
	bool badPos;
	double xbase, ybase, xshift, yshift;
	room.upperLeft.x=DefaultUpLeft_x;
	room.upperLeft.y=DefaultUpLeft_y;
	room.downRight.x=DefaultDownRight_x;
	room.downRight.y=DefaultDownRight_y;

	//must guarantee quantum is not "within" wall.
	xbase=room.upperLeft.x+DefaultRadius;
	xshift=room.downRight.x-room.upperLeft.x-2*DefaultRadius;
	ybase=room.downRight.y+DefaultRadius;
	yshift=room.upperLeft.y-room.downRight.y - 2*DefaultRadius;

	quantums=(Quantum*)malloc(qNumber*sizeof(Quantum));
	collisionList=(int*)malloc(qNumber*sizeof(int));
	bounceList=(int*)malloc(qNumber*sizeof(int));

	
	grid=(double**)malloc(qNumber*sizeof(double*));

	height=(int)(room.upperLeft.y-room.downRight.y);
	width=(int)(room.downRight.x-room.upperLeft.x);
	displayMem=(char**)malloc(height*sizeof(char*));
	for (i=0; i<height; i++)
	{
		//allow extra one for NULL
		displayMem[i]=(char*)malloc((width+1)*sizeof(char));
	}
	
	for (i=0; i<qNumber; i++)
	{
		grid[i]=(double*)malloc(qNumber*sizeof(double));
		
		//must guarantee no two quantum is sticky together 
		//or worth, one inside another
		quantums[i].radius=DefaultRadius;
		quantums[i].elapsed=DefaultStartMoment;
		do
		{
			badPos=false;
			setRandom(quantums[i].coord.x, xbase, xshift);
			setRandom(quantums[i].coord.y, ybase, yshift);
			if (allowZero&&(rand()%ZeroSpeedRate==0))
			{
				quantums[i].speed.x=quantums[i].speed.y=0;
			}
			else
			{
				setRandom(quantums[i].speed.x, 1.0, DefaultSpeed);
				setRandom(quantums[i].speed.y, 1.0, DefaultSpeed);
			}
			for (int j=0; j<i; j++)
			{
				if (quantums[i].distance(quantums[j])<=quantums[i].radius+quantums[j].radius)
				{
					badPos=true;					
				}
			}
		}while (badPos);	
	}
	elapse=INFINITE;
	collisionNumber=0;
	bounceNumber=0;
}

void Scheduler::addCollision(int index)
{
	for (int i=0; i<collisionNumber; i++)
	{
		if (collisionList[i]==index)
		{
			return;//already added;
		}
	}
	collisionList[collisionNumber]=index;
	collisionNumber++;
}

void Scheduler::doSchedule()
{
	int i,j;
	double bounceWall=INFINITE;
	elapse=INFINITE;
	collisionNumber=0;
	bounceNumber=0;
	//first make sure the next soonest collision moment
	for (i=0; i<qNumber; i++)
	{
		bounceWall=quantums[i].bounceTime(room);
		if (bounceWall>0)
		{
			if (bounceWall<elapse)
			{
				collisionNumber=0;//cancel collision
				bounceNumber=0;//refresh bounce list
				elapse=bounceWall;			
				bounceList[bounceNumber]=i;
				bounceNumber=1;
			}
			else
			{
				if (bounceWall==elapse)
				{
					bounceList[bounceNumber]=i;
					bounceNumber++;
				}
			}
		}

		for (j=i+1; j<qNumber; j++)
		{
			if ((grid[i][j]=quantums[i].collisionTime(quantums[j]))>0)
			{
				if (grid[i][j]<elapse)
				{
					//refresh list
					elapse=grid[i][j];
					collisionNumber=bounceNumber=0;
					addCollision(i);
					addCollision(j);
				}
				else
				{
					//it is possible that more than two quantum collide at same moment
					if (grid[i][j]==elapse)
					{
						addCollision(i);
						addCollision(j);
					}
				}
			}
		}
	}
	for (i=0; i<qNumber; i++)
	{
		if (!willCollision(i)&&!willBounce(i))
		{
			quantums[i].flyto(elapse);//just fly
		}
	}
	//doCollision();
}

//if collision happens among more than 2 quantum,
//you need to let any TWO quantum collide 
void Scheduler::doCollision()
{
	int i, j;
	double angle;
	for (i=0; i<collisionNumber; i++)
	{
		for (j=i+1; j<collisionNumber; j++)
		{
			if (showAngle)
			{
				if (quantums[collisionList[i]].speed.length()==0
					||quantums[collisionList[j]].speed.length()==0)
				{
					printf("one quantum speed is zero\n");
				}
				else
				{
					angle=fabs(quantums[collisionList[i]].speedAngle()
						-quantums[collisionList[j]].speedAngle());
					angle*=360.0/PI/2.0;
					printf("Angle before collision:%f degree\n", angle);
				}
			}
			quantums[collisionList[i]].collide(quantums[collisionList[j]]);
			if (showAngle)
			{
				if (quantums[collisionList[i]].speed.length()==0
					||quantums[collisionList[j]].speed.length()==0)
				{
					printf("one quantum speed is zero\n");
				}
				else
				{
					angle=fabs(quantums[collisionList[i]].speedAngle()
						-quantums[collisionList[j]].speedAngle());
					if (angle>PI)
					{
						angle=2*PI-angle;
					}
					angle*=360.0/PI/2.0;
					printf("Angle after collision:%f degree\n", angle);
				}
			}

		}
	}
	for (i=0; i<bounceNumber; i++)
	{
		quantums[bounceList[i]].bounce(room);
	}
}

bool Scheduler::willBounce(int index)
{
	for (int i=0; i<bounceNumber; i++)
	{
		if (index==bounceList[i])
		{
			return true;
		}
	}
	return false;
}

bool Scheduler::willCollision(int index)
{
	for (int i=0; i<collisionNumber; i++)
	{
		if (index==collisionList[i])
		{
			return true;
		}
	}
	return false;
}

Scheduler::~Scheduler()
{
	uninitialize();
}

void Scheduler::schedule(double stopMoment, bool toDisplay)
{
	double startTime=0;
	if (toDisplay)
	{
		display();
	}
	while (startTime<stopMoment)
	{
		doSchedule();
		startTime+=elapse;
		doCollision();
		if (toDisplay)
		{
			display();
		}
	}
}

void Scheduler::display()
{
	int i, row, col;
	double intPortion;
	//clear all
	for (i=0; i<height; i++)
	{
		memset(displayMem[i], '*', width);
		//the total char is width+1
		displayMem[i][width]='\0';//write NULL
	}
	for (i=0; i<qNumber; i++)
	{
		//col=(int)(quantums[i].coord.x-room.upperLeft.x);
		//row=(int)(quantums[i].coord.y-room.downRight.y);
		modf(quantums[i].coord.x-room.upperLeft.x, &intPortion);
		col=(int)intPortion;
		modf(quantums[i].coord.y-room.downRight.y, &intPortion);
		row=(int)intPortion;
		if (displayMem[row][col]=='*')
		{
			displayMem[row][col]='1';
		}
		else
		{
			displayMem[row][col]++;
		}
	}

	printf("\nelapsed=%f,", quantums[0].elapsed);
	for (i=0; i<bounceNumber; i++)
	{
		printf("bounce{%f, %f}", quantums[bounceList[i]].coord.x, 
			quantums[bounceList[i]].coord.y);
	}
	for (i=0; i<collisionNumber; i++)
	{
		printf("collision{%f,%f}", quantums[collisionList[i]].coord.x,
			quantums[collisionList[i]].coord.y);
	}
	printf("\n");
	for (i=0; i<height; i++)
	{
		printf("%s\n", displayMem[i]);
	}
}



file name: main.cpp
#include "quantum.h"
#include "scheduler.h"
#include <stdlib.h>
#include <stdio.h>

int main()
{
	Scheduler S(10);
	S.setShowAngle(true);
	S.schedule(10, true);

/*
	Quantum Q, P;
	//double moment;
	Q.setPos(1,2);
	Q.setSpeed(1,0);
	P.setPos(4,1);
	P.setSpeed(-2,1);
	printf("before collision:\n");
	printf("now Q is:");
	Q.display();
	printf("now P is:");
	P.display();

	if ((moment=Q.collisionTime(P))>0)
	{
		printf("Q and P will collide at %f\n", moment);
	}
	P.flyto(moment);
	Q.flyto(moment);

	Q.collide(P);

	printf("after collision:\n");
	printf("now Q is:");
	Q.display();
	printf("now P is:");
	P.display();
*/
	return 0;
}
 

running result: (This is the running results of 10 seconds. The position of each quantum is

just approximation since I am trying to use integer to map double.)




elapsed=0.000000,
****************************************
**1*************************************
****************************************
****************************************
*******1********************************
****************************************
****************************************
***********1***************1************
****************************************
****************************************
****************************************
***********1****************************
************************1***************
*****1**********1***********************
****************************************
**********1************************1****
****************************************
****************************************
****************************************
****************************************
one quantum speed is zero
Angle after collision:90.002654 degree

elapsed=0.812902,collision{11.260000,7.480000}collision{9.803221,6.109674}
****************************************
**1*************************************
****************************************
****************************************
****************************************
****************************************
*********1******************************
***********1***************1************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
***************1************************
**********1************************1****
*****************1*********1************
*******1********************************
****************************************
****************************************

elapsed=1.042105,bounce{8.425789, 19.000000}
****************************************
**1*************************************
****************************************
****************************************
****************************************
****************************************
*********1******************************
***************************1************
***********1****************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
**********1******1*****************1****
****************************************
*****************1*********1************
****************************************
********1*******************************

elapsed=1.283168,bounce{28.730297, 19.000000}
****************************************
**1*************************************
****************************************
****************************************
****************************************
**********1*****************************
****************************************
***************************1************
************1***************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
**********1*******1****************1****
****************************************
*********1******************************
*****************1**********************
****************************1***********

elapsed=1.334831,bounce{17.914831, 19.000000}
****************************************
**1*************************************
****************************************
****************************************
****************************************
**********1*****************************
****************************************
***************************1************
************1***************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
**********1************************1****
******************1*********************
*********1******************************
****************************1***********
*****************1**********************
one quantum speed is zero
Angle after collision:90.002654 degree

elapsed=1.407472,collision{10.120000,15.040000}collision{9.430549,16.917407}
****************************************
**1*************************************
****************************************
****************************************
****************************************
**********1*****************************
****************************************
***************************1************
****************************************
************1***************************
****************************************
****************************************
****************************************
****************************************
****************************************
**********1************************1****
*********1*********1********************
****************************************
*****************1***********1**********
****************************************

elapsed=2.264516,bounce{24.280968, 19.000000}
****************************************
**1*************************************
****************************************
****************************************
****************************************
**********1*****************************
****************************************
***************************1************
****************************************
***********1****************************
****************************************
***************1************************
****************************************
****************************************
******************1************1********
***********************************1****
****************************************
*********1******************************
****************************************
************************1***************

elapsed=3.782093,bounce{15.275988, 1.000000}
****************************************
**1************1************************
****************************************
****************************************
***********1****************************
****************************************
************************************1***
***************************1************
********************1*******************
****************************************
****************************************
****************************************
****************************************
****************************************
*********************************1******
*******************1***************1****
****************************************
**********1*****************************
****************************************
****************************************

elapsed=4.443077,bounce{39.000000, 3.042462}
****************************************
**1*************************************
****************************************
***************************************1
***********1****1***********************
*********************1******************
****************************************
***************************1************
****************************************
****************************************
****************************************
****************************************
************************************1***
****************************************
****************************************
***********************************1****
****************************************
***********1*********1******************
****************************************
****************************************

elapsed=4.824348,bounce{39.000000, 11.064522}
****************************************
**1**********************************1**
****************************************
*********************1******************
***********1****************************
****************************************
****************************************
*****************1*********1************
****************************************
****************************************
****************************************
***************************************1
****************************************
****************************************
****************************************
***********************************1****
****************************************
***********1****************************
**********************1*****************
****************************************

elapsed=4.847525,bounce{37.685545, 1.000000}
****************************************
**1**********************************1**
****************************************
*********************1******************
***********1****************************
****************************************
****************************************
*****************1*********1************
****************************************
****************************************
**************************************1*
****************************************
****************************************
****************************************
****************************************
***********************************1****
****************************************
***********1****************************
***********************1****************
****************************************

elapsed=4.999554,bounce{23.506791, 19.000000}
****************************************
**1**********************************1**
*********************1******************
****************************************
***********1****************************
****************************************
****************************************
***************************1************
*****************1**********************
****************************************
*************************************1**
****************************************
****************************************
****************************************
****************************************
***********************************1****
****************************************
***********1****************************
****************************************
***********************1****************

elapsed=5.379775,bounce{21.959775, 1.000000}
****************************************
**1******************1******************
****************************************
***********************************1****
***********1****************************
****************************************
****************************************
***************************1************
****************************************
***********************************1****
******************1*********************
****************************************
****************************************
****************************************
****************************************
***********************************1****
****************************************
***********1************1***************
****************************************
****************************************
Angle before collision:274.441524 degree
Angle after collision:82.054012 degree

elapsed=5.906837,collision{34.242780,6.349526}collision{32.775688,7.708806}
****************************************
**1*************************************
****************************************
***********1**********1*****************
****************************************
****************************************
**********************************1*****
***************************1****1*******
****************************************
****************************************
****************************************
****************************************
****************************************
*******************1********************
****************************************
***********************************1****
**************************1*************
************1***************************
****************************************
****************************************
one quantum speed is zero
Angle after collision:89.992037 degree

elapsed=6.240128,collision{29.953400,7.514897}collision{27.980000,7.840000}
****************************************
**1*************************************
****************************************
************1***************************
**********************1*****************
****************************************
****************************************
***************************1*1****1*****
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
********************1******1*******1****
****************************************
************1***************************
****************************************
****************************************
Angle before collision:273.312783 degree
Angle after collision:93.699242 degree

elapsed=6.679754,collision{23.259754,6.784903}collision{24.396670,8.430327}
****************************************
**1*************************************
****************************************
************1***************************
****************************************
****************************************
***********************1*****1**********
****************************************
************************1********1******
****************************************
****************************************
****************************************
****************************************
****************************************
****************************1***********
***********************************1****
****************************************
****************************************
************1********1******************
****************************************

elapsed=6.826479,bounce{21.886230, 19.000000}
****************************************
**1*************************************
****************************************
************1***************************
****************************************
****************************************
**********************1******1**********
****************************************
*********************************1******
***********************1****************
****************************************
****************************************
****************************************
****************************1***********
****************************************
***********************************1****
****************************************
****************************************
************1***************************
*********************1******************
Angle before collision:5.676226 degree
Angle after collision:2.434235 degree

elapsed=7.432483,collision{23.202040,15.416987}collision{21.580977,14.245597}
****************************************
**1*************************************
****************************************
************1***************************
****************************************
********************1********1**********
****************************************
****************************************
****************************************
****************************************
*********************************1******
****************************************
******************************1*********
****************************************
*********************1******************
***********************1***********1****
****************************************
****************************************
************1***************************
****************************************
Angle before collision:34.879093 degree
Angle after collision:18.731812 degree

elapsed=7.700319,collision{33.288529,10.890265}collision{31.407066,11.568571}
****************************************
**1*************************************
************1***************************
****************************************
*******************1*********1**********
****************************************
****************************************
****************************************
****************************************
****************************************
*********************************1******
*******************************1********
****************************************
****************************************
************************1***************
*******************1***************1****
****************************************
****************************************
*************1**************************
****************************************

elapsed=8.244684,bounce{16.438874, 19.000000}
****************************************
**1*************************************
************1***************************
*****************1***********1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
******************************1****1****
***************************1************
****************************************
****************************************
***********************************1****
****************************************
****************************************
*************1**************************
****************1***********************
Angle before collision:22.586885 degree
Angle after collision:97.764464 degree

elapsed=8.400496,collision{15.452419,18.087920}collision{13.477487,18.403587}
****************************************
**1*************************************
*************1**************************
*****************1***********1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
******************************1*********
***************************1********1***
****************************************
****************************************
****************************************
***********************************1****
****************************************
****************************************
*************1*1************************
****************************************
Angle before collision:289.922483 degree
Angle after collision:75.775825 degree

elapsed=8.458620,collision{28.088211,11.270706}collision{30.026903,10.779306}
****************************************
**1*************************************
*************1**************************
*****************1***********1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
******************************1*********
****************************1*******1***
****************************************
****************************************
****************************************
***********************************1****
****************************************
***************1************************
*************1**************************
****************************************

elapsed=8.924433,bounce{10.745949, 19.000000}
****************************************
**1*************************************
*************1*1*************1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
********************************1*******
***************************1************
**************************************1*
****************************************
****************************************
***************1************************
***********************************1****
****************************************
****************************************
****************************************
**********1*****************************
Angle before collision:283.708612 degree
Angle after collision:85.467110 degree

elapsed=9.018499,collision{15.284104,2.264615}collision{13.288968,2.404013}
****************************************
**1*************************************
*************1*1*************1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
**************************1*****1*******
****************************************
**************************************1*
****************************************
***************1************************
****************************************
***********************************1****
****************************************
****************************************
**********1*****************************
****************************************

elapsed=9.055931,bounce{39.000000, 12.003266}
****************************************
**1*************************************
*************1*1*************1**********
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
**************************1******1******
****************************************
****************************************
***************************************1
***************1************************
****************************************
***********************************1****
****************************************
****************************************
**********1*****************************
****************************************

elapsed=9.595360,bounce{15.458999, 1.000000}
****************************************
**1************1************1***********
***********1****************************
****************************************
****************************************
****************************************
****************************************
***********************************1****
*************************1**************
**************1*************************
****************************************
****************************************
************************************1***
****************************************
****************************************
***********************************1****
****************************************
****************************************
*******1********************************
****************************************

elapsed=9.625199,bounce{28.880118, 1.000000}
****************************1***********
**1************1************************
***********1****************************
****************************************
****************************************
****************************************
****************************************
***********************************1****
*************************1**************
**************1*************************
****************************************
****************************************
************************************1***
****************************************
****************************************
***********************************1****
****************************************
****************************************
*******1********************************
****************************************

elapsed=10.225379,bounce{39.000000, 5.850923}
****************************************
**1*************************************
*********1*****1************1***********
****************************************
****************************************
**************1************************1
****************************************
************************1***************
****************************************
****************************************
****************************************
****************************************
**********************************1*****
****************************************
****************************************
***********************************1****
****************************************
***1************************************
****************************************
****************************************

 







                                 back.gif (341 bytes)       up.gif (335 bytes)         next.gif (337 bytes)