StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
4 years ago
|
module.exports = perspectiveFromFieldOfView;
|
||
|
|
||
|
/**
|
||
|
* Generates a perspective projection matrix with the given field of view.
|
||
|
* This is primarily useful for generating projection matrices to be used
|
||
|
* with the still experiemental WebVR API.
|
||
|
*
|
||
|
* @param {mat4} out mat4 frustum matrix will be written into
|
||
|
* @param {number} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
|
||
|
* @param {number} near Near bound of the frustum
|
||
|
* @param {number} far Far bound of the frustum
|
||
|
* @returns {mat4} out
|
||
|
*/
|
||
|
function perspectiveFromFieldOfView(out, fov, near, far) {
|
||
|
var upTan = Math.tan(fov.upDegrees * Math.PI/180.0),
|
||
|
downTan = Math.tan(fov.downDegrees * Math.PI/180.0),
|
||
|
leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0),
|
||
|
rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0),
|
||
|
xScale = 2.0 / (leftTan + rightTan),
|
||
|
yScale = 2.0 / (upTan + downTan);
|
||
|
|
||
|
out[0] = xScale;
|
||
|
out[1] = 0.0;
|
||
|
out[2] = 0.0;
|
||
|
out[3] = 0.0;
|
||
|
out[4] = 0.0;
|
||
|
out[5] = yScale;
|
||
|
out[6] = 0.0;
|
||
|
out[7] = 0.0;
|
||
|
out[8] = -((leftTan - rightTan) * xScale * 0.5);
|
||
|
out[9] = ((upTan - downTan) * yScale * 0.5);
|
||
|
out[10] = far / (near - far);
|
||
|
out[11] = -1.0;
|
||
|
out[12] = 0.0;
|
||
|
out[13] = 0.0;
|
||
|
out[14] = (far * near) / (near - far);
|
||
|
out[15] = 0.0;
|
||
|
return out;
|
||
|
}
|
||
|
|