Commit b957f354 authored by Fabien Grzeskowiak's avatar Fabien Grzeskowiak

First commit : Populating the master

parents
cmake_minimum_required( VERSION 2.8 )
project( CrowdSimulator )
set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
include_directories( ./include )
link_directories( ./lib/${CMAKE_BUILD_TYPE} )
file( GLOB_RECURSE source_files src/* include/* )
add_executable( my_app ${source_files} )
#include <agent/agent.h>
Agent::Agent(){
position = new Vector2D(0.0,0.0);
velocity = new Vector2D(0.0,0.0);
goal = new Vector2D(0.0,0.0);
}
Agent::~Agent(){
delete position;
delete velocity;
delete goal;
}
void Agent::printPosition(){
position->set(10,100);
std::cout << position->x << " " << position->y << std::endl;
Vector2D *v = new Vector2D(position);
v->normalize();
std::cout << v->x << " " << v->y << std::endl;
std::cout << position->dot(v) << std::endl;
position->set(0,0);
}
#ifndef LIB_AGENT_H
#define LIB_AGENT_H
#include <iostream>
#include <tools/vector2D.h>
class Agent
{
public:
Agent();
~Agent();
Vector2D *position;
Vector2D *velocity;
Vector2D *goal;
float radius;
float preferedSpeed;
float maxSpeed;
void printPosition();
};
#endif //LIB_AGENT_H
#include <costFunction/costFunction.h>
CostFunction::CostFunction(){
agentId = 0;
sigMovementCost = 1.0;
lambdaMovementCost = 1.0;
}
float CostFunction::goalCost(){
return 0.0;
}
float CostFunction::avoidanceCost(){
return 0.0;
}
float CostFunction::totalCost(){
return 0.0;
}
#ifndef LIB_COST_FUNCTION_H
#define LIB_COST_FUNCTION_H
#include <tools/vector2D.h>
#include <agent/agent.h>
class CostFunction
{
public :
CostFunction();
unsigned int agentId;
float sigMovementCost;
float lambdaMovementCost;
float goalCost();
float avoidanceCost();
float totalCost();
};
#endif //LIB_COST_FUNCTION_H
#ifndef LIB_SOLVER_H
#define LIB_SOLVER_H
class Solver
{
public :
};
#endif //LIB_SOLVER_H
#ifndef LIB_VECTOR2D_H
#define LIB_VECTOR2D_H
#include <math.h>
class Vector2D
{
public :
float x;
float y;
Vector2D(){
x = 0.0;
y = 0.0;
}
Vector2D(float xx, float yy){
x = xx;
y = yy;
}
Vector2D(Vector2D * v){
this->x = v->x;
this->y = v->y;
}
float magnitude(){ return sqrt(x * x + y * y); }
float sqrMagnitude(){ return x * x + y * y; }
void normalize(){
float mag = magnitude();
x /= mag;
y /= mag;
}
float dot(Vector2D * v){ return this->x * v->x + this->y * v->y;}
void set(float x, float y){
this->x = x;
this->y = y;
}
};
#endif
#include <world/world.h>
World world01;
World::World(){
isToric = true;
size = new Vector2D(100, 100);
}
#ifndef LIB_WORLD_H
#define LIB_WORLD_H
#include <tools/vector2D.h>
class World
{
public :
World();
Vector2D * size;
bool isToric;
};
extern World world01;
#endif //LIB_WORLD_H
#include <vector>
#include <iostream>
#include <agent/agent.h>
#include <costFunction/costFunction.h>
#include <solver/solver.h>
#include <world/world.h>
#include <tools/vector2D.h>
#define MAX_AGENTS 100
int main( int argc, char * argv[] ){
Agent *a = new Agent();
a->printPosition();
std::cout << "---------------" << std::endl;
std::cout << world01.size->x << std::endl;
std::cout << "---------------" << std::endl;
std::vector<Agent*> agents;
for(int i = 0; i < MAX_AGENTS; i++){
agents.push_back(new Agent());
}
agents[20]->printPosition();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment