Skip to content

RayCasting

Vinicius Reif Biavatti edited this page Oct 4, 2019 · 23 revisions

Starting

To create the RayCasting logic we will use some trigonometry functions like Math.sin and Math.cos. These functions works with radian values, not degrees. We are using degree values in the attributes. So, the first thing to do is to create a function that converts the degree value to radian value. We can use the formule below for this:

Formule: degree * π / 180

With the formule as base, we will create the function:

/**
 * Cast degree to radian
 * @param {degree} degree 
 */
function degreeToRadians(degree) {
    let pi = Math.PI;
    return degree * pi / 180;
}

Clone this wiki locally