#include <fcntl.h>#include <unistd.h>#include <signal.h>#include <iostream>#include <fstream>#include <math.h>#include <time.h>#include <sys/resource.h>#include <sys/stat.h>#include <stdarg.h>#include <stdio.h>#include "Robot.h"#include "String.h"#include "ArenaController.h"#include "ArenaRealTime.h"#include "ArenaReplay.h"#include "Various.h"#include "Options.h"#include "Wall.h"#include "Shot.h"#include "Extras.h"#include "ArenaWindow.h"#include "ScoreWindow.h"Include dependency graph for Robot.cc:

Go to the source code of this file.
Functions | |
| void | bounce_on_robot (Robot &robot1, Robot &robot2, const Vector2D &normal) |
|
||||||||||||||||
|
Definition at line 801 of file Robot.cc. References angle2vec(), Circle::center, Robot::change_energy(), COLLISION, dot(), Options::get_d(), lengthsqr(), OPTION_ROBOT_BOUNCE_COEFF, OPTION_ROBOT_FRONT_BOUNCE_COEFF, OPTION_ROBOT_FRONT_HARDNESS, OPTION_ROBOT_FRONT_PROTECTION, OPTION_ROBOT_FRONTSIZE, OPTION_ROBOT_HARDNESS, OPTION_ROBOT_MASS, OPTION_ROBOT_PROTECTION, rotation_t::pos, ROBOT, Robot::robot_angle, Robot::send_message(), the_opts, unit(), vec2angle(), and MovingObject::velocity. 00802 {
00803 double h1, h2, p1, p2, b1, b2;
00804 Vector2D dir1_2 = unit(robot2.center - robot1.center);
00805
00806 if( dot(dir1_2, angle2vec(robot1.robot_angle.pos)) > cos(the_opts.get_d(OPTION_ROBOT_FRONTSIZE)*0.5) )
00807 {
00808 h1 = the_opts.get_d(OPTION_ROBOT_FRONT_HARDNESS);
00809 b1 = the_opts.get_d(OPTION_ROBOT_FRONT_BOUNCE_COEFF);
00810 p1 = the_opts.get_d(OPTION_ROBOT_FRONT_PROTECTION);
00811 }
00812 else
00813 {
00814 h1 = the_opts.get_d(OPTION_ROBOT_HARDNESS);
00815 b1 = the_opts.get_d(OPTION_ROBOT_BOUNCE_COEFF);
00816 p1 = the_opts.get_d(OPTION_ROBOT_PROTECTION);
00817 }
00818
00819 if( -dot(dir1_2, angle2vec(robot2.robot_angle.pos)) > cos(the_opts.get_d(OPTION_ROBOT_FRONTSIZE)*0.5) )
00820 {
00821 h2 = the_opts.get_d(OPTION_ROBOT_FRONT_HARDNESS);
00822 b2 = the_opts.get_d(OPTION_ROBOT_FRONT_BOUNCE_COEFF);
00823 p2 = the_opts.get_d(OPTION_ROBOT_FRONT_PROTECTION);
00824 }
00825 else
00826 {
00827 h2 = the_opts.get_d(OPTION_ROBOT_HARDNESS);
00828 b2 = the_opts.get_d(OPTION_ROBOT_BOUNCE_COEFF);
00829 p2 = the_opts.get_d(OPTION_ROBOT_PROTECTION);
00830 }
00831
00832 double e = b1*b2;
00833 Vector2D start_vel1 = robot1.velocity;
00834 Vector2D start_vel2 = robot2.velocity;
00835 double mass = the_opts.get_d(OPTION_ROBOT_MASS);
00836 Vector2D tmp = ((1.0 + e) / 2.0) * dot(robot2.velocity - robot1.velocity, normal) * normal;
00837 robot1.velocity += tmp;
00838 robot2.velocity -= tmp;
00839
00840 double an = vec2angle(-normal);
00841 double en_diff = 0.5 * mass * lengthsqr(start_vel1 - robot1.velocity);
00842 double injury = en_diff * 0.5 * (h1 + h2) * (1.0-e) * (1.0-p1);
00843 robot1.change_energy(-injury);
00844 robot1.send_message(COLLISION, ROBOT, an-robot1.robot_angle.pos);
00845
00846 an = vec2angle(normal);
00847 en_diff = 0.5 * mass * lengthsqr(start_vel2 - robot2.velocity);
00848 injury = en_diff * 0.5 * (h1 + h2) * (1.0-e) * (1.0-p2);
00849 robot2.change_energy(-injury);
00850 robot2.send_message(COLLISION, ROBOT, an-robot2.robot_angle.pos);
00851 }
|
Here is the call graph for this function:

1.3.9.1