Function: getMatrixImpact()
getMatrixImpact(
matrix
,cameraState
,viewportDimensions
):number
All these transformations we apply on the matrix to get it rescale the graph as we want make it very hard to get pixel-perfect distances in WebGL. This function returns a factor that properly cancels the matrix effect on lengths.
[jacomyal] To be fully honest, I can't really explain happens here... I notice that the following ratio works (i.e. it correctly compensates the matrix impact on all camera states I could try):
R = size(V) / size(M * V) / W
as long asM * V
is in the direction of W (ie. parallel to (Ox)). It works as well with H and a vector that transforms into something parallel to (Oy).
Also, note that we use angle
and not -angle
(that would seem logical,
since we want to anticipate the rotation), because the image is vertically
swapped in WebGL.
Parameters
• matrix: Float32Array
• cameraState: CameraState
• viewportDimensions: Dimensions
Returns
number