I have a strange distortion in my raycasting program.
I have already multiplied the lengths of the vector with its cosine to correct the normal fish eye effect
This is the whole code https://editor.p5js.org/BlackPhoenix/sketches/FgTRwH2WF
This is the calculation of the distance to the wall.
if(closest){
let dis = p5.Vector.dist(this.pos, pt)
if(dis < record){
closest = pt
record = dis * cos(radians(r - 45))
}
}