Crash when interpolating to a shorter path
See original GitHub issueHi !
When interpolating from a longer path to a shorter one I have the following crash:
const longer = parse('M50,10 L100 100 L200 200 L500 500');
const shorter = parse('M50,10 L200 200 L400 400');
const pathAnimatedProps = useAnimatedProps(() => ({
d: interpolatePath(transition.value, [0, 1], [longer, shorter])
}));
When going to other way around (from shorter to longer) i have the same problem as in issue https://github.com/wcandillon/react-native-redash/issues/415
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
INTERPOLATE does not work - InkscapeForum.com
I have a problem with EXTENSIONS/INTERPOLATE what did I do: - I start inkscape - circle tool, draw circle, object to path
Read more >Keyframe interpolation instability - Blender Stack Exchange
For interpolation to take the shortest path one has to choose the quaternion closest one to the previous frame (either q or -q)....
Read more >Bug #1018338 “Crash when interpolating two paths
Does this crash also occur if you redo the tutorial in a new document based on the default template? If the crash only...
Read more >Fast-Paced Multiplayer (Part III): Entity Interpolation
In the second article, we proposed client-side prediction as a way to overcome these limitations. The net result of these two articles is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello everyone. I was able to get it to work quite nicely using a pretty simple trick.
Note that my values are scaled uniformly along the x-axis using their index, and not their value. Your use case may differ.
So the idea is we need to interpolate between paths of varying lengths. Instead of re-implementing the
interpolatePath
function to support that use case - I chose to “prepare” the paths beforehand and simply provide them with equal lengths tointerpolatePaths
.The big question was: how do you add or remove points to a path without changing the way it looks?
Easy. Re-scale the values along the x-axis using the same number of data points as our output path, and then for every x, get the corresponding y value from the original path.
Here’s the code snippet for the helper function I created, it returns a new path that has the same amount of data points as specified with the
precision
param:This solution works pretty well, but it is not perfect. The normalized path will lose some detail when removing data points (especially noticeable on points that have a high delta value compared to their surrounding neighbours, i.e. big spike on the path). It will do for now, but any input to help improve this would be much appreciated!
Now the next question is: how can we remove points in a less arbitrary way? i.e. preserve the points with the highest deltas, and ditch those with smaller ones?
It woule be great to have more support on
interpolatePath
function.+1