{"action":"created","issue":{"url":"https://api.github.com/repos/bjz/cgmath-rs/issues/210","labels_url":"https://api.github.com/repos/bjz/cgmath-rs/issues/210/labels{/name}","comments_url":"https://api.github.com/repos/bjz/cgmath-rs/issues/210/comments","events_url":"https://api.github.com/repos/bjz/cgmath-rs/issues/210/events","html_url":"https://github.com/bjz/cgmath-rs/issues/210","id":70771710,"number":210,"title":"Matrix4::invert breaks because of low precision in approx_eq","user":{"login":"jarrett","id":16208,"avatar_url":"https://avatars.githubusercontent.com/u/16208?v=3","gravatar_id":"","url":"https://api.github.com/users/jarrett","html_url":"https://github.com/jarrett","followers_url":"https://api.github.com/users/jarrett/followers","following_url":"https://api.github.com/users/jarrett/following{/other_user}","gists_url":"https://api.github.com/users/jarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrett/subscriptions","organizations_url":"https://api.github.com/users/jarrett/orgs","repos_url":"https://api.github.com/users/jarrett/repos","events_url":"https://api.github.com/users/jarrett/events{/privacy}","received_events_url":"https://api.github.com/users/jarrett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-24T19:16:28Z","updated_at":"2015-04-24T19:30:25Z","closed_at":null,"body":"When inverting a matrix, we check that the determinant is non-zero [using `approx_eq`](https://github.com/bjz/cgmath-rs/blob/master/src/matrix.rs#L400). If the determinant is approximately zero, the inversion fails.\r\n\r\nBut [`approx_eq`](https://github.com/bjz/cgmath-rs/blob/182f7b41dcdff2b21fbeacd6f3329d98ea72f462/src/approx.rs#L21) only goes to a precision of 10^-5.\r\n\r\nThat's problematic, because projection matrices often have very small determinants. This is especially true when the camera is zoomed out very far. In that case, we're transforming a large volume of world space to the clip space volume. Which means that the determinant tends to be very small. (This is because the determinant is the ratio of the two volumes.)"},"comment":{"url":"https://api.github.com/repos/bjz/cgmath-rs/issues/comments/96042457","html_url":"https://github.com/bjz/cgmath-rs/issues/210#issuecomment-96042457","issue_url":"https://api.github.com/repos/bjz/cgmath-rs/issues/210","id":96042457,"user":{"login":"jarrett","id":16208,"avatar_url":"https://avatars.githubusercontent.com/u/16208?v=3","gravatar_id":"","url":"https://api.github.com/users/jarrett","html_url":"https://github.com/jarrett","followers_url":"https://api.github.com/users/jarrett/followers","following_url":"https://api.github.com/users/jarrett/following{/other_user}","gists_url":"https://api.github.com/users/jarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrett/subscriptions","organizations_url":"https://api.github.com/users/jarrett/orgs","repos_url":"https://api.github.com/users/jarrett/repos","events_url":"https://api.github.com/users/jarrett/events{/privacy}","received_events_url":"https://api.github.com/users/jarrett/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T19:30:25Z","updated_at":"2015-04-24T19:30:25Z","body":"Admittedly, this can be worked around by building a separate ortho projection with very small near and far planes. This keeps the viewing volume small, resulting in a larger determinant. This works just fine for unprojecting a point in screen space. But it does mean we need two different versions of the projection matrix: one for projecting, and one for inverting. So the workaround is less than ideal."}}