#Train track spline madness & MVC

1 messages · Page 1 of 1 (latest)

thick current
#

@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?

vagrant timber
#

instead of implementing your own, you may be able to just use libspiro now that i think of it

thick current
#

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

thick current
#

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)

thick current
#

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.

vagrant timber
#

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

thick current
#

As for first derivative, its direction is obviously in teh direction of travel

#

Magnitudes are what makes this complicated...

vagrant timber
#

yes, but you can and should change the parametric speed of the quintic to make it more fair

thick current
#

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

vagrant timber
#

the aim of MVC is not to minimize variation of parametric speed

#

rather we want to minimize the accumulated vatiation of curvature

thick current
#

Ah, I see

vagrant timber
#

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

thick current
#

I see... Well, in my case it would really be great to have the possibility to also minimize variation of magnitude of velocity

vagrant timber
#

with velocity = paramertic speed of the curve?

thick current
#

yes

vagrant timber
#

why tho?

#

the geometric object doesn't care about its parametrization

#

nobody will see or feel the parametrization

thick current
#

Because then:

  1. it would be much easier to traverse nearly even amounts of arc length with same distance in the tiem parameter
#
  1. Using acceleration (second derivative) for track cant will be much easier too
vagrant timber
#

fair, if that's higher priority for you than a nice curve, go for it

thick current
#

Well, why do you say like it's mutually exclusive?

vagrant timber
#

they are if you stick with quintics, since theres not enough free variables to achieve both optimization goals

thick current
#

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...

vagrant timber
#

but the car's velocity has nothing to do with the parametric speed of the opaque function that was used to design the road

thick current
#

Curvature is defined in terms of resulting arc length, not parametric velocity/acceleration, correct?

vagrant timber
#

curvature is a purely geometric property of any given point along a curve

thick current
#

I feel like I'm repeating the same thing over and over

vagrant timber
#

it is independent of the representation of the curve

#

in fact, its just the reciprocal radius

thick current
#

Yes, I'm familiar

thick current
#

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

vagrant timber
#

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

thick current
#

Well, yeah, I am quite amateur in such fields

vagrant timber
vagrant timber
thick current
#

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

thick current
#

And the arrows overlay over each other (fixed by scaling them down)

thick current
#

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

thick current
#

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)

thick current
#

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)

vagrant timber
#

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

thick current
#

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

thick current
#

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.

vagrant timber
#

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

thick current
#

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:

  1. velocity0 and velocity1 set to same magnitude
  2. 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