Ejemplo n.º 1
0
  void DrawMatches(
      const std::string& title,
      const cv::Mat image,
      const cv::Mat points1,
      const cv::Mat points2,
      const cv::Scalar& color1,
      const cv::Scalar& color2,
      bool draw_image_borders)
  {
    cv::Mat draw_image;
    if (image.type() == CV_8U)
    {
      cvtColor(image, draw_image, CV_GRAY2BGR);
    }
    else
    {
      draw_image = image.clone();
    }

    for (int i = 0; i < points1.rows; i++)
    {
      cv::Point2f center1(
        cvRound(points1.at<cv::Vec2f>(0, i)[0] * 16.0),
        cvRound(points1.at<cv::Vec2f>(0, i)[1] * 16.0));
      cv::Point2f center2(cvRound(
        points2.at<cv::Vec2f>(0, i)[0] * 16.0),
        cvRound(points2.at<cv::Vec2f>(0, i)[1] * 16.0));
      circle(draw_image, center1, 48, color1, 1, CV_AA, 4);
      line(draw_image, center1, center2, color2, 1, CV_AA, 4);
    }

    opencv_util::ShowScaled(title, draw_image);
  }
Ejemplo n.º 2
0
void BaseVH::buildMostOrthogonalCameras()
{
    int numSilhouetteCams = mSilhouetteCameras.size();

    int numCams = mCalibration->get_cam_count();

    mMostOrthogonalCamera.clear();

    mMostOrthogonalCamera.resize( numCams , -1 );
    
    mIsCameraUsed.clear();
    
    mIsCameraUsed.resize( numCams , 0 );

    for( int cc = 0; cc < numCams; cc++ )
    {
        int camId1 = cc;

        Vector3d cameraRay1;

        double width1 = mCalibration->get_image_width( camId1 );
        double height1 = mCalibration->get_image_height( camId1 );

        Eigen::Vector2d center1( width1 / 2 , height1 / 2 );

        mCalibration->getRay( camId1 , center1 , cameraRay1 );

        double prevVal = 1;

        int mostOrthogonalCam = -1;

        for( int sc = 0; sc < numSilhouetteCams; sc++ )
        {
            int camId2 = mSilhouetteCameras[ sc ];

            double width2 = mCalibration->get_image_width( camId2 );
            double height2 = mCalibration->get_image_height( camId2 );

            Eigen::Vector2d center2( width2 / 2 , height2 / 2 );

            Vector3d cameraRay2;

            mCalibration->getRay( camId2 , center2 , cameraRay2 );

            double dot = cameraRay1.dot( cameraRay2 );


            if( abs( dot ) < prevVal )
            {
              prevVal = abs( dot );

              mostOrthogonalCam = camId2;
            }

        }

        mMostOrthogonalCamera[ camId1 ] = mostOrthogonalCam;
    }
}
Ejemplo n.º 3
0
//This function sets up the two shapes we need for this example.
void setup()
{
	int NumberOfDivisions = 20;

	line.point1 = glm::vec3(-0.5f, 0.5f, 0.0f);
	line.point2 = glm::vec3(-0.5f, -0.5f, 0.0f);

	float radius = 0.25f;
	cylinder.radius = radius;
	cylinder.point1 = glm::vec3(0.0f, 0.5f, 0.0f);
	cylinder.point2 = glm::vec3(0.0f, -0.5f, 0.0f);

	VertexFormat center1(cylinder.point1, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
	VertexFormat center2(cylinder.point2, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
	
	std::vector<VertexFormat> vertices;
	float height = glm::distance(cylinder.point1, cylinder.point2);
	float theta = 360.0f / NumberOfDivisions;
	VertexFormat A, B, C, D;
	//Circle vertex generation
	//In this example we are not implementing the proper the code for indices. We are just going to produce redundant information in the buffer.
	//since we are only having a small number of objects on the screen currently, this redundancy should not matter.
	for (int i = 0; i < NumberOfDivisions; i++)
	{
		A = VertexFormat(glm::vec3(radius * cos(glm::radians(i*theta)),0.5f, radius * sin(glm::radians(i*theta))), glm::vec4(0.7f, 0.20f, 0.0f, 1.0f));
		B = VertexFormat(glm::vec3(radius * cos(glm::radians((i + 1)*theta)), 0.5f, radius * sin(glm::radians((i + 1)*theta))), glm::vec4(0.7f, 0.20f, 0.0f, 1.0f));
		C = VertexFormat(glm::vec3(radius * cos(glm::radians(i*theta)), -0.5f, radius * sin(glm::radians(i*theta))), glm::vec4(0.0f, 0.20f, 0.7f, 1.0f));
		D = VertexFormat(glm::vec3(radius * cos(glm::radians((i + 1)*theta)), -0.5f, radius * sin(glm::radians((i + 1)*theta))), glm::vec4(0.0f, 0.20f, 0.7f, 1.0f));

		//In every iteration, the center, the point at angle theta and at angle (theta+delta) are fed into the buffer.
		vertices.push_back(center1);
		vertices.push_back(A);
		vertices.push_back(B);

		vertices.push_back(center2);
		vertices.push_back(C);
		vertices.push_back(D);

		vertices.push_back(A);
		vertices.push_back(C);
		vertices.push_back(B);

		vertices.push_back(C);
		vertices.push_back(D);
		vertices.push_back(B);

	}

	cylinder.base.initBuffer(12 * NumberOfDivisions, &vertices[0]);
}
Ejemplo n.º 4
0
int BaseVH::getMostOrthogonalUnusedCamera(int camId)
{  
    Vector3d cameraRay1;

    double width1 = mCalibration->get_image_width( camId );
    double height1 = mCalibration->get_image_height( camId );

    cv::Point2f center1( width1 / 2 , height1 / 2 );

    mCalibration->getRay( camId , center1 , cameraRay1 );

    double prevVal = 1;

    int mostOrthogonalCam = -1;
    
    int numSilhouetteCams = mSilhouetteCameras.size();

    for( int sc = 0; sc < numSilhouetteCams; sc++ )
    {
        int camId2 = mSilhouetteCameras[ sc ];
	
	if( camId2 == camId )
	  continue;

        double width2 = mCalibration->get_image_width( camId2 );
        double height2 = mCalibration->get_image_height( camId2 );

        cv::Point2f center2( width2 / 2 , height2 / 2 );

        Vector3d cameraRay2;

        mCalibration->getRay( camId2 , center2 , cameraRay2 );

        double dot = cameraRay1.dot( cameraRay2 );


        if( abs( dot ) < prevVal && !mIsCameraUsed[ camId2 ] )
        {
            prevVal = dot;

            mostOrthogonalCam = camId2;
        }

    }
    
    return mostOrthogonalCam;


}
Ejemplo n.º 5
0
b2Body* PhysicsWorld::createIdol(int x, int y,char* name)
{
    float width = 5 * meterPerPixel;
    float height = 20 * meterPerPixel;
    b2Vec2 center1(0,-height);
    float angle = 3.14 / 4;

    b2BodyDef bodyDef;
    b2PolygonShape polygonShape;
    b2FixtureDef fixtureDef;

    bodyDef.position.Set(x*meterPerPixel,y*meterPerPixel);
    bodyDef.type = b2BodyType::b2_dynamicBody;
    b2Body* body = world->CreateBody(&bodyDef);
    fixtureDef.shape = &polygonShape;

    body->SetUserData(new BodyUserData(name));

    fixtureDef.density = 1;
    fixtureDef.restitution = 0.4;
    fixtureDef.friction = 0.5;

    polygonShape.SetAsBox(width, height);
    body->CreateFixture(&fixtureDef);

    polygonShape.SetAsBox(width, height, center1, -angle);
    body->CreateFixture(&fixtureDef);

    polygonShape.SetAsBox(width, height, center1, angle);
    body->CreateFixture(&fixtureDef);

    b2Vec2 vector[4];
    vector[0].Set(0*meterPerPixel,10*meterPerPixel);
    vector[1].Set(15*meterPerPixel,25*meterPerPixel);
    vector[2].Set(0*meterPerPixel,40*meterPerPixel);
    vector[3].Set(-15*meterPerPixel,25*meterPerPixel);
    polygonShape.Set(vector,4);
    body->CreateFixture(&fixtureDef);

    return body;
}
void TectonicPlateSimulation::Cut(b2Vec2 from, b2Vec2 to)
{
    bool pointsAreEqual = from.x == to.x && from.y == to.y;
    if(pointsAreEqual) return;
    std::vector<b2Body*> affectedBodies;
    std::vector<b2PolygonShape*> affectedPolygonShapes;
    std::vector<b2Vec2> points;
    MyRayCastCallback callback1;
    world.RayCast(&callback1, from, to);
    for(int i = 0; i < callback1.m_count; i++) {
        points.push_back(callback1.m_points[i]);
        //m_debugDraw.DrawPoint(points.back(), 5.0f, b2Color(0.9f, 0.4f, 0.4f));
        if(std::find(affectedBodies.begin(), affectedBodies.end(), callback1.m_bodies[i]) == affectedBodies.end()) { // does not contain
            affectedBodies.push_back(callback1.m_bodies[i]);
            affectedPolygonShapes.push_back(callback1.m_polygonShapes[i]);
        }
    }
    MyRayCastCallback callback2;
    world.RayCast(&callback2, to, from);
    for(int i = 0; i < callback2.m_count; i++) {
        int index = (int)(find(affectedBodies.begin(), affectedBodies.end(), callback2.m_bodies[i]) - affectedBodies.begin());
        if(index < affectedBodies.size()) { // does contain
            points.push_back(callback2.m_points[i]);
            //m_debugDraw.DrawPoint(points.back(), 5.0f, b2Color(0.4f, 0.4f, 0.9f));
            b2Vec2 rayCenter((points.back().x + points[index].x) / 2.0f, (points.back().y + points[index].y) / 2.0f);
            //m_debugDraw.DrawPoint(rayCenter, 5.0f, b2Color(0.4f, 0.9f, 0.4f));
            float rayAngle = atan2f(points[index].y - points.back().y, points[index].x - points.back().x);
            std::vector<b2Vec2> vertices1;
            std::vector<b2Vec2> vertices2;
            for(int j = 0; j < affectedPolygonShapes[index]->GetVertexCount(); j++) {
                b2Vec2 polygonVertex = affectedBodies[index]->GetWorldPoint(affectedPolygonShapes[index]->GetVertex(j));
                float cutAngle = atan2f(polygonVertex.y - rayCenter.y, polygonVertex.x - rayCenter.x) - rayAngle;
                if(cutAngle < M_PI*-1.0f) {
                    cutAngle += 2.0f * M_PI;
                }
                if(cutAngle > 0.0f && cutAngle <= M_PI) {
                    vertices1.push_back(polygonVertex);
                    //m_debugDraw.DrawPoint(polygonVertex, 5.0f, b2Color(0.4f, 0.9f, 0.9f));
                } else {
                    vertices2.push_back(polygonVertex);
                    //m_debugDraw.DrawPoint(polygonVertex, 5.0f, b2Color(0.9f, 0.9f, 0.4f));
                }
            }
            vertices1.push_back(points[index]);
            vertices1.push_back(points.back());
            
            vertices2.push_back(points.back());
            vertices2.push_back(points[index]);
            
            bool cutLegitimate = true;
            for(int j = 0; j < vertices1.size() && cutLegitimate; j++) {
                b2Vec2 edge = vertices1[(j + 1) % vertices1.size()] - vertices1[j];
                if(edge.Length() <= 0.1f) cutLegitimate = false;
            }
            
            for(int j = 0; j < vertices2.size() && cutLegitimate; j++) {
                b2Vec2 edge = vertices2[(j + 1) % vertices2.size()] - vertices2[j];
                if(edge.Length() <= 0.1f) cutLegitimate = false;
            }
            
            bool polygonDegenerate = false;
            float epsilon = 0.1f;
            for(int j = 0; j < vertices1.size() && !polygonDegenerate; j++) {
                b2Vec2 v1 = vertices1[j];
                for(int k = 0; k < vertices1.size() && !polygonDegenerate; k++) {
                    if(k == j) continue;
                    b2Vec2 v2 = vertices1[k];
                    if(fabs(v1.x - v2.x) < epsilon && fabs(v1.y - v2.y) < epsilon) polygonDegenerate = true;
                }
            }
            
            for(int j = 0; j < vertices2.size() && !polygonDegenerate; j++) {
                b2Vec2 v1 = vertices2[j];
                for(int k = 0; k < vertices2.size() && !polygonDegenerate; k++) {
                    if(k == j) continue;
                    b2Vec2 v2 = vertices2[k];
                    if(fabs(v1.x - v2.x) < epsilon && fabs(v1.y - v2.y) < epsilon) polygonDegenerate = true;
                }
            }
            
            if(vertices1.size() < 3 || vertices1.size() > 8 || vertices2.size() < 3 || vertices2.size() > 8 || polygonDegenerate) {
                if(i < callback2.m_count - 1) to = callback2.m_points[i+1];
                else to = from;
                continue;
            }
            
            b2Vec2 center1(0,0);
            b2Vec2 center2(0,0);
            for(int i = 0; i < vertices1.size(); i++) {
                center1 += vertices1[i];
            }
            center1 *= 1.0f / vertices1.size();
            for(int i = 0; i < vertices1.size(); i++) {
                vertices1[i] -= center1;
            }
            
            for(int i = 0; i < vertices2.size(); i++) {
                center2 += vertices2[i];
            }
            center2 *= 1.0f / vertices2.size();
            for(int i = 0; i < vertices2.size(); i++) {
                vertices2[i] -= center2;
            }
            
            //body definition
            b2BodyDef myBodyDef;
            myBodyDef.type = b2_dynamicBody;
            
            //shape definition
            b2PolygonShape polygonShape;
            
            //fixture definition
            b2FixtureDef myFixtureDef;
            myFixtureDef.shape = &polygonShape;
            myFixtureDef.density = 1;
            myFixtureDef.restitution = 0.5;
            
            myBodyDef.position.Set(center1.x, center1.y);
            polygonShape.Set(&vertices1[0], (int)vertices1.size());
            b2Body* body1 = world.CreateBody(&myBodyDef);
            body1->CreateFixture(&myFixtureDef);
            body1->SetLinearVelocity(affectedBodies[index]->GetLinearVelocity());
            body1->SetAngularVelocity(affectedBodies[index]->GetAngularVelocity());
            
            myBodyDef.position.Set(center2.x, center2.y);
            polygonShape.Set(&vertices2[0], (int)vertices2.size());
            b2Body* body2 = world.CreateBody(&myBodyDef);
            body2->CreateFixture(&myFixtureDef);
            body2->SetLinearVelocity(affectedBodies[index]->GetLinearVelocity());
            body2->SetAngularVelocity(affectedBodies[index]->GetAngularVelocity());
            
            if(i < callback2.m_count - 1) to = callback2.m_points[i+1];
            else to = from;
            world.DestroyBody(affectedBodies[index]);
        }
    }
    //m_debugDraw.DrawSegment(from, to, b2Color(0.8f, 0.8f, 0.8f));
}
Ejemplo n.º 7
0
  void DrawMatches(
      cv::Mat& image_out,
      const cv::Mat image1,
      const cv::Mat image2,
      const cv::Mat points1,
      const cv::Mat points2,
      const cv::Scalar& color,
      bool draw_image_borders,
      const cv::Scalar& point_color)
  {
    cv::Size size(image1.cols + image2.cols, std::max(image1.rows, image2.rows));
    image_out.create(size, CV_MAKETYPE(image1.depth(), 3));
    cv::Mat draw_image1 = image_out(cv::Rect(0, 0, image1.cols, image1.rows));
    cv::Mat draw_image2 = image_out(cv::Rect(image1.cols, 0, image2.cols, image2.rows));

    if (image1.type() == CV_8U)
    {
      cvtColor(image1, draw_image1, CV_GRAY2BGR);
    }
    else
    {
      image1.copyTo(draw_image1);
    }

    if (image2.type() == CV_8U)
    {
      cvtColor(image2, draw_image2, CV_GRAY2BGR);
    }
    else
    {
      image2.copyTo(draw_image2);
    }

    if (draw_image_borders)
    {
      cv::rectangle(draw_image1,
                    cv::Point(0, 0),
                    cv::Point(image1.cols, image1.rows),
                    cv::Scalar(0, 0, 0),
                    2);

      cv::rectangle(draw_image2,
                    cv::Point(0, 0),
                    cv::Point(image2.cols, image2.rows),
                    cv::Scalar(0, 0, 0),
                    2);
    }

    cv::RNG rng = cv::theRNG();
    bool rand_color = color == cv::Scalar::all(-1);
    bool has_point_color = point_color != cv::Scalar::all(-1);

    for (int i = 0; i < points1.rows; i++)
    {
      cv::Scalar match_color = rand_color ? cv::Scalar(rng(256), rng(256), rng(256)) : color;
      cv::Scalar match_color2 = has_point_color ? point_color : match_color;
      cv::Point2f center1(
        cvRound(points1.at<cv::Vec2f>(0, i)[0] * 16.0),
        cvRound(points1.at<cv::Vec2f>(0, i)[1] * 16.0));
      cv::Point2f center2(
        cvRound(points2.at<cv::Vec2f>(0, i)[0] * 16.0),
        cvRound(points2.at<cv::Vec2f>(0, i)[1] * 16.0));
      cv::Point2f dcenter2(
        std::min(center2.x + draw_image1.cols * 16.0, (image_out.cols - 1) * 16.0), 
        center2.y);
      circle(draw_image1, center1, 48, match_color2, 1, CV_AA, 4);
      circle(draw_image2, center2, 48, match_color2, 1, CV_AA, 4);
      line(image_out, center1, dcenter2, match_color, 1, CV_AA, 4);
    }
  }
Ejemplo n.º 8
0
void Colisionable::FixColision(sf::Vector2f pos1, sf::Vector2f size1, sf::Vector2f pos2, sf::Vector2f size2){
    Map* map = Scene::getScene()->getMap();
    //std::cout << "1x " << pos1.x << " 1y "<< pos1.y << " 2x" << pos2.x << " 2y " << pos2.y  << std::endl;
    sf::Vector2f center1((pos1.x*2 + size1.x)/2, (pos1.y*2 + size1.y)/2);
    sf::Vector2f center2((pos2.x*2 + size2.x)/2, (pos2.y*2 + size2.y)/2);
    //std::cout << "cx " << center1.x << " cy "<< center1.y << " c2x" << center2.x << " c2y " << center2.y  << std::endl;
    float top1 = pos1.y;
    float bottom1 = pos1.y+size1.y;
    float left1 = pos1.x;
    float right1 = pos1.x+ size1.x;

    float top2 = pos2.y;
    float bottom2 = pos2.y+size2.y;
    float left2 = pos2.x;
    float right2 = pos2.x+ size2.x;

    //primer quadrant



    if(center1.x > center2.x && center1.y <= center2.y){
        //std::cout << "primer quadrant " << std::endl;
        float dist_left = right2-left1;
        float dist_bottom = bottom1 - top2;
        //std::cout << right2 << " "<< left1 << " " << dist_bottom << " " << dist_left << std::endl;
        //std::cout << "top " << size2.x << " bottom "<< bottom2 << " left" << left2 << " right " << right2 << std::endl;
        if(dist_left <= dist_bottom){
            //Chunk* c = map->getChunk(center2.x + Settings::TILE_SIZE, center2.y);
            Tile* t = map->getTile(center2.x + Settings::TILE_SIZE, center2.y, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x, center2.y - Settings::TILE_SIZE);
                Tile* t2 = map->getTile(center2.x, center2.y - Settings::TILE_SIZE, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_bottom;
                    ++col_left;
                }
                else{
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_bottom;
                }
            }else{
                if(col_left_dist < dist_left) col_left_dist = dist_left;
                ++col_left;
            }

        }
        else {
            //Chunk* c = map->getChunk(center2.x, center2.y - Settings::TILE_SIZE);
            Tile* t = map->getTile(center2.x, center2.y - Settings::TILE_SIZE, 1);
            if(t->id !="0"){
                //Chunk* c2 =  map->getChunk(center2.x + Settings::TILE_SIZE, center2.y);
                Tile* t2 = map->getTile(center2.x + Settings::TILE_SIZE, center2.y, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_left;
                    ++col_bottom;
                }
                else{
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    ++col_left;
                }
            }
            else{
                if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                ++col_bottom;
            }

        }

    }


        //segon quadrant
    else if(center1.x <= center2.x && center1.y < center2.y){
        //std::cout << "segon quadrant " << std::endl;
        float dist_right = right1 - left2;
        float dist_bottom = bottom1 - top2;

        if(dist_right <= dist_bottom){
            //Chunk* c = map->getChunk(center2.x - Settings::TILE_SIZE, center2.y);
            Tile* t = map->getTile(center2.x - Settings::TILE_SIZE, center2.y, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x, center2.y - Settings::TILE_SIZE);
                Tile* t2 = map->getTile(center2.x, center2.y - Settings::TILE_SIZE, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_bottom;
                    ++col_right;
                }
                else{
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_bottom;
                }
            }
            else{
                if(col_right_dist < dist_right) col_right_dist = dist_right;
                ++col_right;
            }
        }
        else {
            //Chunk* c = map->getChunk(center2.x, center2.y - Settings::TILE_SIZE);
            Tile* t = map->getTile(center2.x, center2.y - Settings::TILE_SIZE, 1);
            if(t->id !="0"){
                //Chunk* c2 =  map->getChunk(center2.x - Settings::TILE_SIZE, center2.y);
                Tile* t2 = map->getTile(center2.x - Settings::TILE_SIZE, center2.y, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                    ++col_right;
                    ++col_bottom;
                }
                else{
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    ++col_right;
                }
            }
            else{
                if(col_bottom_dist < dist_bottom) col_bottom_dist = dist_bottom;
                ++col_bottom;
            }
        }

    }
        //tercer quadrant
    else if(center1.x < center2.x && center1.y >= center2.y){
        //std::cout << "tercer quadrant " << std::endl;
        float dist_right = right1 - left2;
        float dist_top = bottom2 - top1;

        if(dist_right <= dist_top){
            //Chunk* c = map->getChunk(center2.x - Settings::TILE_SIZE, center2.y);
            Tile* t = map->getTile(center2.x - Settings::TILE_SIZE, center2.y, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x, center2.y + Settings::TILE_SIZE);
                Tile* t2 = map->getTile(center2.x, center2.y + Settings::TILE_SIZE, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_top;
                    ++col_right;
                }
                else{
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_top;
                }
            }
            else{
                if(col_right_dist < dist_right) col_right_dist = dist_right;
                ++col_right;
            }

        }
        else {

            //Chunk* c = map->getChunk(center2.x, center2.y + Settings::TILE_SIZE);
            Tile* t = map->getTile(center2.x, center2.y + Settings::TILE_SIZE, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x - Settings::TILE_SIZE, center2.y);
                Tile* t2 = map->getTile(center2.x - Settings::TILE_SIZE, center2.y, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_right;
                    ++col_top;
                }
                else{
                    if(col_right_dist < dist_right) col_right_dist = dist_right;
                    ++col_right;
                }
            }
            else{
                if(col_top_dist < dist_top) col_top_dist = dist_top;
                ++col_top;
            }
        }
    }
        //quart quadrant
    else if(center1.x >= center2.x && center1.y > center2.y){
        //std::cout << "quart quadrant " << std::endl;
        float dist_left = right2-left1;
        float dist_top = bottom2 - top1;
        if(dist_left <= dist_top){
            //Chunk* c = map->getChunk(center2.x + Settings::TILE_SIZE, center2.y);
            Tile* t = map->getTile(center2.x + Settings::TILE_SIZE, center2.y, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x, center2.y + Settings::TILE_SIZE);
                Tile* t2 = map->getTile(center2.x, center2.y + Settings::TILE_SIZE, 1);
                if(t2 == nullptr || t2->id !="0"){
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_top;
                    ++col_left;
                }
                else{
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_top;
                }
            }else{
                if(col_left_dist < dist_left) col_left_dist = dist_left;
                ++col_left;
            }
        }
        else {
            //Chunk* c = map->getChunk(center2.x, center2.y + Settings::TILE_SIZE);
            Tile* t = map->getTile(center2.x, center2.y + Settings::TILE_SIZE, 1);
            if(t->id !="0"){
                //Chunk* c2 = map->getChunk(center2.x + Settings::TILE_SIZE, center2.y);
                Tile* t2 = map->getTile(center2.x + Settings::TILE_SIZE, center2.y, 1);

                if(t2 == nullptr || t2->id !="0"){
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    if(col_top_dist < dist_top) col_top_dist = dist_top;
                    ++col_left;
                    ++col_top;
                }
                else{
                    if(col_left_dist < dist_left) col_left_dist = dist_left;
                    ++col_left;
                }
            }else{
                if(col_top_dist < dist_top) col_top_dist = dist_top;
                ++col_top;

            }
        }
    }
}