Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Train carriage with 2 bogies following a path
#1
Wink 
Hi

For a train simulation, I'd like the carriages to follow a spline path.

Train carriages generally have two bogies upon which the carriage pivots, which are a fixed distance from one another.

However if the train is not on straight track the arc length between the bogies on the curve will be variable, so simply traversing the curve twice with an offset won't work

   

I can't find any trivial solutions to this problem. Any suggestions welcome!
Reply
#2
Hi
The black arc is called Arc Length, and the green line is called Cord Length.

The relationship between these two values is probably defined mathematically for all the spline types supported by Curvy Splines. I personally never looked at this subject. As an example here is an example of this relationship for a simple circle:
https://www.omnicalculator.com/math/arc-length

The rigourous way would be to to compute the arc length based on the cord length and the used spline type, then set the second bogie's position as: first bogie position + arc length

The easy way to do, that I would recommend for most cases, is to first set the bogie's position as if the arc length is equal to the desired cord length, and the compute the actual cord length. If it varies too much from the desired cord length, then increase/decrease the bogie's position a bit an then repeat until you get close enough to the desired cord length.

I hope this helped.
Have a nice day
I never looked for the relationship between these two for all the types of splines supported by Curvy Splines. Probably such relationship exists,
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Once both are connected just move first one while second Absolut position if first one plus some distance? If moving along spline direction +distance if against then -distance or vice versa not sure about that. You can make distance random in range or depending on speed to achieve more realistic train like movement. Do this in Update or FixedUpdate depending on movement type (transform or rigidbody).
Reply
#4
Another thought I had - I'm already subdividing the spline to draw it with a polyline from another library. I could just drive the first bogie, check the straight line segments from the subdivision for intersections with a circle of radius equal to the cord length, and use that position.

Or even just generate straight line segments from the points cache and check those.
Reply
#5
Isn't difference of Absolute positions of two objects on spline equal to distance between those two?
Or use Relative position combined with spline length?  Do not use Relative position look at few posts bellow.
Reply
#6
(08-24-2023, 10:40 AM)velikizlivuk Wrote: Isn't difference of Absolute positions of two objects on spline equal to distance between those two?
Or use Relative position combined with spline length?

The problem is that in this case you need to calculate the arc length from the chord length in order to know where on the spline in terms of TF the bogeys will fall, which isn't a simple thing to calculate for a spline.
Reply
#7
That difference is equal to the arc length* between the two. Do not use the Relative position for that use. If you wonder why, check this video: https://www.youtube.com/watch?v=rP0zuAEoVJw&list=PLatR0iPtXq-xxul-Ys-vQSLMaLXQnaU65&index=4
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#8
(08-24-2023, 05:28 PM)arcadeperfect Wrote: "That difference is equal to the arc length between the two" is false. The chord length does not always equal the arc length.

By "That difference" I mean the different between "Absolute positions" as stated in the question. Absolute Position is a float typed property of the controller. It defines the arc distance between a point and the spline's start.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#9
(08-24-2023, 05:28 PM)arcadeperfect Wrote: This is why _AKA_ suggested an iterative approach whereby I increase the arc length and check the resulting chord length, until it is within some tolerance. I'll probably go with that.

If you end up choosing another way, it would be much appreciated if you let us know.
Don't hesitate to ask questions if needed.
Have a nice day.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#10
Please disregard my previous post, I got confused
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rasterized Path Range issue proton 3 13 2 hours ago
Last Post: proton
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Generator does not exactly follow the path F.A.L. 3 4 04-24-2023, 03:49 PM
Last Post: _Aka_
  How to expand/contract path? Ferdinand 5 24 10-12-2022, 02:31 PM
Last Post: _Aka_

Forum Jump: