Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
397 B
6
Indexable
// 1.04719755 is 60 deg in rad - FOV
// 0.523598776 half fov

// ray angle relative to world
const rayDirection = 1.04719755 * (Math.floor(0.5 * RES_X) - i) / (RES_X - 1);

// a value between 0.5 and -0.5
const rayProjectionPos =
    (0.5 * Math.tan(rayDirection)) / Math.tan(0.523598776);

//actual ray column in projection
ray.col = Math.round(RES_X * (0.5 - rayProjectionPos)) + 1;
Leave a Comment