Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the quality of surface objects to better follow the data by using LCM or highly composite numbers #3281

Merged
merged 70 commits into from
Dec 18, 2018

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Nov 22, 2018

Fixes #2713 by increasing the resolution of surface objects.
With previous set up resolution (128x128) surfaces with any remarkable changes in z-axis were not displayed well.
Also to mention: the issue #2208 and #3262 would be fixed in this PR as well.
@etpinard
@alexcjohnson

@archmoj archmoj added bug something broken status: reviewable labels Nov 22, 2018
@@ -66,7 +66,7 @@ describe('Test gl3d plots', function() {
gd = createGraphDiv();
ptData = {};

jasmine.DEFAULT_TIMEOUT_INTERVAL = 4000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 8000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I was about to ask if you noticed any performance deterioration on your branch. I guess this here answers my question. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... would there be a way to increase the resolution just for traces that need it? In other words, is a way to determine if a given z 2D array requires extra resolution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea could be to allow resetting this resolution via the api.
I can imagine of auto-detect solutions; but considering animations I suggest we keep this constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard Rather than using 1024, now by simply using 120 instead of `128' the performance is untouched; while the quality of the graphs are remarkably improved. If we want to go further than that the next magic values that could be applied are 180, 240, 360, 720 and 840.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Could you explain briefly why 120 is better than 128?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

128 = 27 so it is divisible by (1 + 7) numbers {1, 2, 4, 8, 16, 32, 64, 128}
120 = 23x31x51 therefore divisible by (1+3)x(1+1)x(1+1) = 16 numbers {1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 60, 120}.
So it is more likely that the refined grid match actual data points in this case.
https://en.wikipedia.org/wiki/Highly_composite_number
Base on this investigation I am now thinking to rewriting the function that refines scale.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow @archmoj is the man! Thanks!

@archmoj archmoj changed the title Improving the quality of surface objects to better follow the data Improving the quality of surface objects to better follow the data by using highly composite numbers Nov 23, 2018
@archmoj archmoj changed the title Improving the quality of surface objects to better follow the data by using highly composite numbers Improving the quality of surface objects to better follow the data by using LCM or highly composite numbers Nov 24, 2018
package.json Outdated Show resolved Hide resolved
@etpinard
Copy link
Contributor

Impressive work @archmoj this PR is looking very strong 🍾

The new logic looks good to me. Now, would you mind doing some performance testing on ~5 surface mocks, just to make sure we're not slowing things down too much? Using something like

console.time('surface')
Plotly.newPlot(gd, [/* */])
console.timeEnd('surface')

in the browser console would suffice. Thanks in advance!

@archmoj
Copy link
Contributor Author

archmoj commented Dec 6, 2018

Thank you @alexcjohnson for the review. This is pretty much fixed for parametric cases. I was able to create two mocks related to parametric surface and contour precision. Regarding our discussion concerning computing the ranges twice and possibility of using bounds instead of [mid|max]Values, after searching for computeTraceBounds function I noticed that the bounds are computed after the glplot.update in scene.js. However for the case of surface traces we need these values before drawing the object. So I thought we may keep those the way are. I could still try using Lib.aggnums there.
What do you think?

@alexcjohnson
Copy link
Collaborator

Regarding our discussion concerning computing the ranges twice ... I could still try using Lib.aggnums there.

There are two separate issues here: DRY 🌴 and performance 🐎.

🌴 we could investigate replacing both of these implementations with aggNums but if it's at all complicated don't worry about it.

🐎 I would just imagine keeping both copies, but short-circuiting the one in scene if it has already been done (and stashed on the trace) in convert.

@archmoj
Copy link
Contributor Author

archmoj commented Dec 7, 2018

@alexcjohnson after investigation of using aggNums and while user raw text data in not passed in rawData, I thought we could keep convert code as it is. On the other hand I did removed the changes previously made to gl3d/scene.js. So this may be ready to merge?

package.json Outdated Show resolved Hide resolved
@alexcjohnson
Copy link
Collaborator

Looks good to me! 💃 after merging gl-surface3d and updating its ref, and making an issue for #3281 (comment)

@etpinard
Copy link
Contributor

🎉 this will be part of 1.43.0!

@archmoj archmoj merged commit 83fd651 into master Dec 18, 2018
@archmoj archmoj deleted the issue-2713 branch December 18, 2018 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface plots do not quite follow the data
3 participants