I've been working on a small train simulation program, just for fun, and as of right now it uses a rather annoyingly complex system (Bezier curves) to create the tracks. I would like a simpler form. What I was thinking is something like the path building in the game Planet Coaster. As far as I can tell the game uses just the initial point of the path, the direction of said initial point (in my case the tangent vector in my 3D space).
I've been researching this for the past couple of days and I feel after working with splines for a while now that I keep over thinking it. I tried drawing it out on pencil and paper to find a way of solving it but I'm getting a tad burnt out, and would like another perspective. If anyone would have any suggestions or ways to draw said curve the help would be greatly appreciated.
Some more technical details/ another wording, given a point A and a tangent vector at a, solving for a curve that would reach a point B with a constant radius.
A link to a drawing similar to what I'm thinking of:
Sorry if my formatting is strange, I'm new to posting on the exchange! Thanks for the help! (I didn't quite know where to post this, math or overflow, but I figured the application fit more with overflow)
Constant radius curve is circle arc.
Given: Points A
, B
, tangent vector T
(Ua
at your picture)
Radius-vector P
(a-o at the picture) is perpendicular to tangent (circle property).
Perpendicular to the middle of arc chord (c-Md) goes through circle center.
So we can find circle center as intersection of lines (a-o) and (c-Md).
But is is simpler to find such point C
at (a-o) that provides perpendicular to chord at Md
- it is circle center.
Make difference vector D = B - A
Make middle point M = (B + A) / 2
Make vector perpendicular to tangent vector P = (T.Y, -T.X)
Circle center is C = A + t * P
where t parameter is unknown yet
Vectors CM
and D
should be perpendicular, so their dot product is zero:
(M - C).dot.D = 0
Solve this equation for t
and get point C
and arc radius