@vagrant timber So, I've found a paper on MVC. In ends up using quintic Hermite. It does describe why Cubic curves are not suitable, but I'm actually fine with it. Implementing a quintic curve wouldn't be a problem in my use case. Found a matrix for the quintic hermite functions, printed using a label printer to not forget lol.
As this is a scientific paper, it is quite verbose and broad at times. Can you help me understand it and get an understanding on how to apply the quintic hermites in my use case?
#Train track spline madness & MVC
1 messages · Page 1 of 1 (latest)
instead of implementing your own, you may be able to just use libspiro now that i think of it
I would prefer to have a clean implementation in pure rust rather than depending on a foreign language lib
After all, I need just a small part of it
I can quickly implement a quintic hermite, I just don't know how to apply it in my use case
I guess having an additional second derivative constraint is a part of what makes it so flexible
The paper mentions some kind of fitting and an iterative process, I don't know whether I need that in my use case
Hmm, I think since the control point spacing is arbitrary, it might make sense to in some cases scale the interpolation parameter and control points
And that is discussed in the article, I think
Because of interpolation parameter getting arbitrarily scaled (from [0, X] to [0, 1]) and input derivatives/tangents getting scaled by the same factor X, it would essentially keep the velocity magnitude at aroudn teh same, which is what minimum variation is I think
For a cubic hermite implementation, I can simply copy bevy_math, on which I also worked a bit (or make a PR for quintic curves? Order-generic curves?)
The implementation in bevy_math is quite generic, thanks to using characteristic matrices
Alright gotta fuel up with liquid courage (espresso coffee)
Ugh, all of this high abstraction stuff, "functionals", makes me a bit confused. I see there's some talk about SI-MVC (Scale-Independent MVC), which is probably what I need, but I dail to find and understand how a transition from MVC (which I assume to be a Quintic Hermite Spline) to SI-MVC is made.
quintic hermite splines != MVC, moreton just chose to approximate the latter with the former, and used some gradient descend method to compute said approximation using the degrees of freedom that quintic polynomials have with regard to G2 hermite interpolation constraints
as you noted, the degrees of freedom are the length of the first derivative and the parts of the second derivative thats colinear to the first derivative at both endpoints
Well, shouldn't the second derivative, for relatively constant speed, be perpendicular to the first derivative? Influencing only the curvature, but not magnitude of the velocity.
As for first derivative, its direction is obviously in teh direction of travel
Magnitudes are what makes this complicated...
yes, but you can and should change the parametric speed of the quintic to make it more fair
I also have an assumption that if the function was changed (wrapped) so that the parameter t lies in [0, 4] insteadof [0, 1] by scaling, the resulting velocity magnitude would shrink by a factor of 4, if the derivative is taken of the wrapper function
And with increased arc length but interpolation parameter t staying in range [0,1], the velocity magnitude would stay minimum variation only if the velocities at the end points were increased, proportionately
Which is what my understanding of "scale" is
the aim of MVC is not to minimize variation of parametric speed
rather we want to minimize the accumulated vatiation of curvature
Ah, I see
imagine a perfect road going from a to b
you'd want minimal adjustment of the steering wheel while traversing said road
in the least squares sense
adjustment of the steering wheel == variation of curvature
I see... Well, in my case it would really be great to have the possibility to also minimize variation of magnitude of velocity
with velocity = paramertic speed of the curve?
yes
why tho?
the geometric object doesn't care about its parametrization
nobody will see or feel the parametrization
Because then:
- it would be much easier to traverse nearly even amounts of arc length with same distance in the tiem parameter
- Using acceleration (second derivative) for track cant will be much easier too
fair, if that's higher priority for you than a nice curve, go for it
Well, why do you say like it's mutually exclusive?
they are if you stick with quintics, since theres not enough free variables to achieve both optimization goals
For your car metaphor, smoothness is also when the velocity magnitude changes the least. As a person who gets motion sickness in transport very easily, I understand that concept quite well...
but the car's velocity has nothing to do with the parametric speed of the opaque function that was used to design the road
Curvature is defined in terms of resulting arc length, not parametric velocity/acceleration, correct?
curvature is a purely geometric property of any given point along a curve
I feel like I'm repeating the same thing over and over
it is independent of the representation of the curve
in fact, its just the reciprocal radius
Yes, I'm familiar
I want to clarify, here you mean the magnitude of the input parametric velocity at both points, and a portion of the input parametric acceleration that that is parallel to teh velocity (dot product?), is that correct?
Damn, I really need some kind of a live playground for this
Maybe I can build one using bevy and run in the web browser
To visualize and see what I have in mind
i think so yes, you're using vocabulary that's unusual in this area, and being precise with wording is quite important... i dont want to be rude
Well, yeah, I am quite amateur in such fields
this is super important, always viszalize
you can derive that for yourself... since you only want specific tangents and curvatures at the endpoints, you can choose your first two derivatives (wrt your curve parameter) to some extent, just have a look at the definition of tangent vector and curvature and think about which combinations will result in the same tangent and curvature
Hmm, so what I was thinking of is making parametric acceleration match curvature as much as possible. The full vector, not just component perpendicular to teh tangent
Well, now I just need to make it draggable I guess
Or I could add a comb, a parameter to show values at a specific point, ability to change that point... etc
Tried to make a circle arc with this but clearly it is not a circle
And the arrows overlay over each other (fixed by scaling them down)
But yeah I did this stuff a lot previously so I quickly sketched it up, I just need to find out how to drag those gizmos
So, I finally built a small playground for myself
The result already looks pretty good, but the velocity and acceleration are all manual... Now I just want to make them procedural.
I still want minimum velocity variation. I want to "synchronize" the geometric and parametric properties.
I want to have a near-linear proportion between change of interpolation parameter and arc length (from start of the curve)
I built it into wasm and uploaded to my webserver: https://jtcf.ru/quintic_hermite_playground/
Yellow is the velocity, blue is acceleration
have fun
(and preferrably use browser page scaling instead of CameraZoom because it is very much hacked together)
i can have a look tomorrow
but from first sight it seems like you'd need to work the steering wheel quite a bit
going from relatively tight to relaxed back to tight back to relaxed curvature
Well, yeah, it's not a perfect MVC, just a quintic hermite
And the control points are all over the place
In my use case, ideally the acceleration would be perpendicular to velocity at all times, although I am aware that in case of an MVC that is not the case, and that degree fo freedom is used to get the shape right
The MVC works in terms of the arc length, I want to work in terms of parametric length. Velocity, first derivative.
And I am likely disregarding the use of second derivative input for getting the right shape...
Although it could be nicely set up automatically based on neighboring segments
I can update the app quite easily with a set of additional metrics, visualized using color
Have experience doing that
Curvature, velocity/acceleration magnitude, length of segments produced by regular intervals of the interpolation parameter
Updated the playground with some info and a mode to show the difference of parametric segments in gradient, along with actual min-max-diff values
It's... A cool thing, that I can build a web app using a game framework and it just works
Sure, some of the code might be a mess (because this is a prototype), but it still much simpler than I would've expected. Some simple initial setup and then it's just the sifference between which command you use to build.
here's what i would consider the best transition given the position and tangent constraints
let me see if i can do a similar thing including the curvature constraints
Hmm
I think I can try and make a kind of algo for tweaking these parameters
With my goal of minimum variation of magnitude of the first derivative
(least squares)
And curvature, probably
So the first thing I would do is optimize for the somewhat-semi-circle (U-turn, not S-turn) case, and I would impose the following restrictions:
- velocity0 and velocity1 set to same magnitude
- acceleration0 and acceleration1 set to same magnitude, perpendicular to the velocity vector
And then give myself some input to tweak the magnitudes
Which could then be probably optimized automatically using either an iteratvie process (less preferrable for me) or using geometric data