{"action":"created","issue":{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/777","labels_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/777/labels{/name}","comments_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/777/comments","events_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/777/events","html_url":"https://github.com/matlab2tikz/matlab2tikz/issues/777","id":107737024,"number":777,"title":"simplify 3D plots","user":{"login":"miscco","id":3017120,"avatar_url":"https://avatars.githubusercontent.com/u/3017120?v=3","gravatar_id":"","url":"https://api.github.com/users/miscco","html_url":"https://github.com/miscco","followers_url":"https://api.github.com/users/miscco/followers","following_url":"https://api.github.com/users/miscco/following{/other_user}","gists_url":"https://api.github.com/users/miscco/gists{/gist_id}","starred_url":"https://api.github.com/users/miscco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miscco/subscriptions","organizations_url":"https://api.github.com/users/miscco/orgs","repos_url":"https://api.github.com/users/miscco/repos","events_url":"https://api.github.com/users/miscco/events{/privacy}","received_events_url":"https://api.github.com/users/miscco/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/labels/+0.1.0","name":"+0.1.0","color":"d3d7cf"},{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/labels/cleanfigure","name":"cleanfigure","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-22T15:17:08Z","updated_at":"2015-09-22T17:14:21Z","closed_at":null,"body":"Hi,\r\n\r\nI have currently a problem with a 3D plot with a large amount of data points. Sadly most of those are clustered at some position, whereas at some parts of the plot there are only few points. Therefore a simple decimate or downsample doesn't cut it. \r\n\r\nLong story short i thought about whether we could use the simplifyLine function also for 3D plot. The problem with that approach is obvious but theoretically solvable.\r\n\r\nMy idea is to take the view that we get and utilize it to projekt the 3D coordinates onto the 2D view plane. Then we would run our 2D simplifyLine and get the mask for those points we would ommit (note that we do not need the back transformation as we simple omit points)\r\n\r\nSo I thought about something along those lines (see https://en.wikipedia.org/wiki/Camera_matrix)\r\n\r\n```matlab\r\n% 3D data in 4D view\r\ndata = [xData(:), yData(:), zData(:), ones(size(xData(:)))];\r\n\r\n% Get the current view\r\nC = view;\r\n\r\n% remove the unneeded 4th column\r\nC = C(1:3,:);\r\n\r\n% Project the data\r\ndata_transformed = (view*data')';\r\n\r\n% scale the data\r\ndata_transformed =[data_transformed(:,1)./data_transformed(:,3),...\r\n                                data_transformed(:,2)./data_transformed(:,3)];\r\n\r\nmask = opheimSimplify(data_transformed(:,1), data_transformed(:,2) , tol);\r\n```\r\n\r\nHowever, if I then plot(data_transformed(:,1), data_transformed(:,2)) I get something slightly different then what i would expect. So i am unsure where i am doing things wrong\r\n\r\nThe 3D figure\r\n![3d_plot](https://cloud.githubusercontent.com/assets/3017120/10022692/6c51b83e-614e-11e5-9a83-770c75cba035.png)\r\n\r\nThe corresponding 2D projection\r\n![2d_projection_plot](https://cloud.githubusercontent.com/assets/3017120/10022699/773cad62-614e-11e5-9364-47a2e97a21d3.png)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/comments/142353002","html_url":"https://github.com/matlab2tikz/matlab2tikz/issues/777#issuecomment-142353002","issue_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/777","id":142353002,"user":{"login":"egeerardyn","id":177360,"avatar_url":"https://avatars.githubusercontent.com/u/177360?v=3","gravatar_id":"","url":"https://api.github.com/users/egeerardyn","html_url":"https://github.com/egeerardyn","followers_url":"https://api.github.com/users/egeerardyn/followers","following_url":"https://api.github.com/users/egeerardyn/following{/other_user}","gists_url":"https://api.github.com/users/egeerardyn/gists{/gist_id}","starred_url":"https://api.github.com/users/egeerardyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egeerardyn/subscriptions","organizations_url":"https://api.github.com/users/egeerardyn/orgs","repos_url":"https://api.github.com/users/egeerardyn/repos","events_url":"https://api.github.com/users/egeerardyn/events{/privacy}","received_events_url":"https://api.github.com/users/egeerardyn/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T17:14:21Z","updated_at":"2015-09-22T17:14:21Z","body":"@missco I'm by no means experienced with 3D stuff, but I have 2 remarks:\r\n\r\n1. the 4th coordinate in those quaternions does matter (it allows for translations in the same manner as a rotation)\r\n2. I don't see your logic in dividing the X and Y coordinates by the Z coordinates in the transformed data. Maybe that is the problem?\r\n\r\nAlso, for testing you might want to overlay (or subplot) the 2 axes (the original 3D one and a 2D one with your calculations) to visually compare your results more easily.\r\n\r\nIn any case: thank you for looking into this. The idea seems nice, so let's hope we can implement it in a reliable way as well :+1: "}}