24 minutes ago, C3D_ said:
@ZakwaydaThe issue here is: Me. Because i have no idea what iam doing, haha!
?♂️
Haha, no worries
That's what discussion forums like this one are for.
Quote
I didnt even mention the pen pressure value that is also part of the struct and needs to be interpolated as well.
That's an additional consideration, but any solution that properly interpolates the original time values should be able to handle the pressure values as well, so I don't think it complicates things much.
Quote
And something about intersections. But why should there be intersections when the vector is anyway just a list?
When I say 'intersections' I'm talking about geometric intersections - that is, the path 'crossing' itself. An example of this in the video you posted is where the path crosses itself after you draw the first rectangular shape. It also crosses, connects with, and backtracks on itself multiple times after that. (As I mentioned earlier I do wonder if the smoothing algorithms you're using are robust and reliable with respect to arbitrary complex paths like the one in the video, but for the sake of discussion we'll assume they are.)
Quote
Why do you think that its necessary to include the time into the smoothing process versus processing the time after the smoothing process?
I've tried to think of a post-processing solution that could handle arbitrary, possibly self-intersecting paths, but I haven't been able to think of one. We're pretty deep into the thread, so there may not be many other eyes on this at this point, but maybe someone else can suggest a post-processing solution. But it seems like a difficult problem to me. I think my original solution would probably work for paths that don't self-intersect or pass very close to themselves, but without modification it would be vulnerable to failure given a path like that in your video.
Also, given that you're interested in performance and optimization, doing this via post-processing will almost certainly be considerably more expensive than doing it as part of the smoothing process, because the necessary information is already available during the smoothing process, but a separate post-processing process would have to reconstruct that information somehow.
So I think I can sum up why doing this as part of the smoothing is preferable as follows:
- It's not obvious (to me at least) how to do the interpolation robustly and reliably via post-processing.
- Even if such a solution were available, it would likely be more expensive than doing it as part of the path smoothing.
- Based on what I know of the algorithms you're using, doing the interpolation as part of the path smoothing should be relatively straightforward, so I don't see any reason to shy away from it. I understand though that if you're not particularly comfortable with C++ and/or the algorithms in question, even making fairly simple changes might be daunting.
Quote
Okay. However. I will concentrate now to get my struct into this function.
If by this you mean modifying the smoothing code to work directly with your own data structures rather than with e.g. std::pair, then in essence, yes, that's exactly what I'm recommending. Basically, everywhere the original code copies/moves/creates position values, you want to instead copy/move/create instances of your data structure (the one that includes time, pressure, etc.), and everywhere the original code interpolates positions, you also want to interpolate time and pressure values as well.
The last thing I'll say for the moment is that earlier I see this code:
struct Pencil
{
sf::VertexArray vertices;
std::vector<int> pressure;
std::vector<sf::Int32> timeAbslt;
std::vector<sf::Int32> timeDelta;
};
Which is an 'SoA' ('structure of arrays'). Although your smoothing code could be modified to work with this, it would probably be easier to use an array of structures instead, so that the smoothing code has to deal with fewer arrays and can deal with pencil point instances as single units. (You can read more about SoA vs AoS here.)
Quote
The problem of this thread is that i need to transfer time deltas or absolute time from an handdrawn curve which holds all the data (xy,time) to a smoothed version of this curve which holds only xy data and has a different point count/size().
You posted this while I was writing the above, but just to be clear, it seems to me that the goal is for the smoothed curve to include more information than just xy data - it should include interpolated time and pressure as well. If that assumption is wrong, it might be worth clarifying that.