5 [Edit removed during grace period]; added 403 characters in body edited Mar 31 '19 at 13:32 Num Lock 544 bronze badges I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have fisheye effect, if i use depth directly  if (l == 0) { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; h_seen = dist_c * wall_h / depth; y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); }  // Direction of each ray inside the while loop if ((hit = intersection(w, l, &dir))) w->cam->rays[i].endpoint = w->cam->intersection; else { w->cam->rays[i].endpoint.x = w->cam->position.x + w->cam->raylength * tcos((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit))); w->cam->rays[i].endpoint.y = w->cam->position.y + w->cam->raylength * tsin((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit))); // limit is just the screen width }  I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have fisheye effect, if i use depth directly  if (l == 0) { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; h_seen = dist_c * wall_h / depth; y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); }  I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have fisheye effect, if i use depth directly  if (l == 0) { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; h_seen = dist_c * wall_h / depth; y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); }  // Direction of each ray inside the while loop if ((hit = intersection(w, l, &dir))) w->cam->rays[i].endpoint = w->cam->intersection; else { w->cam->rays[i].endpoint.x = w->cam->position.x + w->cam->raylength * tcos((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit))); w->cam->rays[i].endpoint.y = w->cam->position.y + w->cam->raylength * tsin((w->cam->angle + w->cam->fov / 2) - (i * (w->cam->fov / limit))); // limit is just the screen width }  4 deleted 283 characters in body edited Mar 31 '19 at 12:13 Num Lock 544 bronze badges I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have fisheye effect, if i use depth directly  if (l == 0) // some check for projecting in the minimap or the 2.5D version { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; // // dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = depth * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); // if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); // to check what was the diff of heightsdepth; y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); // fill my image of the corresponding pixels }  I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem  if (l == 0) // some check for projecting in the minimap or the 2.5D version { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; // // dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = depth * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); // if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); // to check what was the diff of heights y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); // fill my image of the corresponding pixels }  I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have fisheye effect, if i use depth directly  if (l == 0) { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; h_seen = dist_c * wall_h / depth; y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); }  3 added 850 characters in body edited Mar 30 '19 at 20:04 Num Lock 544 bronze badges I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem  if (l == 0) // some check for projecting in the minimap or the 2.5D version { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; // // dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = depth * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); // if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); // to check what was the diff of heights y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); // fill my image of the corresponding pixels }  I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = dist_w * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); y = cam_h - (h_seen / 2) - 1;  This is a screenshot of the problem  if (l == 0) // some check for projecting in the minimap or the 2.5D version { raytravel.y = w->cam->rays[i].endPoint.y - w->cam->position.y; raytravel.x = w->cam->rays[i].endPoint.x - w->cam->position.x; depth = raytravel.x * dir.x + raytravel.y * dir.y; // // dist_w = sqrt(pow((w->cam->position.x - w->cam->rays[i].endPoint.x), 2) + pow((w->cam->position.y - w->cam->rays[i].endPoint.y), 2)); distortion = depth * tCos(w->cam->fov / 2 - (i * w->cam->fov / WIN_W)); // if (distortion) h_seen = dist_c * wall_h / distortion; //printf("h_seen = %f\n", h_seen); // to check what was the diff of heights y = cam_h - (h_seen / 2) - 1; if (hit == 1) while (++y < (cam_h + (h_seen / 2))) put_pixel_img(w, WIN_W - i + WIDTH_MM, y + 150, 0xff0000); // fill my image of the corresponding pixels }  2 Formatting & spelling edited Mar 30 '19 at 19:16 DMGregory♦ 76.6k1616 gold badges143143 silver badges214214 bronze badges 1 asked Mar 30 '19 at 19:03 Num Lock 544 bronze badges