Jump to content

Cant / superelevation and Path3D normals on a helix/spiral road/rail


QuintusHegie
 Share

Recommended Posts

Hi all,

This may be an easy question but I cannot seem to solve it myself after several attempts.

For my Model Train Simulator in BabylonJS I'm creating a helix/spiral track, allowing trains on a lower section to quickly gain altitude within a short area (e.g. climbing a mountain). This is often used in 'hidden' sections on model train displays to have a train pass a valley track and next pass a mountain bridge which is position much higher (Y position) in the scene.

When I construct the points of a helix/spiral using the formula from the docs

https://doc.babylonjs.com/babylon101/parametric_shapes
https://www.babylonjs-playground.com/#165IV6#61

And then use Path3D on these points to get the normals see the docs

https://doc.babylonjs.com/how_to/how_to_use_path3d
https://www.babylonjs-playground.com/#2DLXYB#1
https://www.babylonjs-playground.com/#8ICWNU

Then I get an ever increasing cant/superelevation of my track, see the blue arrows in the picture which indicate the 'up' vectors. The result is that the track at the top has a cant. I use the Tangent, Normal and Binormal from the Path3D of the line/points to set the track rail and bed geometry, and position the train always perpendicular to the track (that is: up). But I want to have the Up vector always Vector3.Up(), or at least that there is no cant/superelevation and I can continue placing 'flat' track with it's normal Vector3.Up() on the top.

The big blue arrow indicates Vector3.Up().

Current 'vector up' results from Path3D in my game:

helixtrack.thumb.png.da89e87fb280f71ba47d78f8d87969bc.png

Blue = up vector (from Path3D).
Large blue with _ = helix direction (Y axis)
Yellow line through track = Line through the spiral center points (radius * cos t, radius * sin t, ascentfactor * t)

Desired 'vector up' on the spiral/helix:

2%20helix.jpg

(image found at http://www.easyhelix.com)

  • Hope someone knows how to 'alter' the results from Path3D so I get the helix point orientation but without the cant/superelevation.
    So that I can 'lay the track' properly without trains 'falling off the track' because of cant/superelevation.

Bonus questions:
- the yellow marked area in the skybox marks another bug that is caused with a reflection texture intersection with the skybox. the default background color comes through on the waves.
- the red box marks a mesh (air balloon) with a physics impostor that is already moving, but I want the physics computation to be paused until the user presses some 'start to play'-button, instead of physics computation right from the moment the scene is loading

Happy coding,

Q

Link to comment
Share on other sites

Not sure to get exactly what you mean .... 

The Path3D is just a maths tool to design a 3D path and its triplets (tangent, normal, binormal) whatever the direction in the space. If a direction matters for you (say, the UP for every point), you could, for instance :

- build your path3D

- get all the tangents from its triplets

- compute, with a simple cross product, for each point your own normals and binormals from each tangent 

Link to comment
Share on other sites

1 hour ago, Pryme8 said:

So are  you talking about how the track tilting a whole bunch tword the top?

I’m on my phone right now but if I get to a pc I’ll take a look.

Yes, the tilting of the track from the bottom to the top of the helix is the problem.

I use the BABYLON.Curve.continue() function to connect the ground track (flat) with the helix and then with the upper track (should be flat). The result is that the upper track is also tilted, namely with the final tilt of the upmost helix point. Would be great if the solutions works with continue() function as well so I can use the library functions over custom code.

5 hours ago, jerome said:

Not sure to get exactly what you mean .... 

The Path3D is just a maths tool to design a 3D path and its triplets (tangent, normal, binormal) whatever the direction in the space. If a direction matters for you (say, the UP for every point), you could, for instance :

- build your path3D

- get all the tangents from its triplets

- compute, with a simple cross product, for each point your own normals and binormals from each tangent 

Thanks I'll try that too but please know that I use the continue() function so I hope this solution works with continue as well... (e.g. the computed normal is 'continued' at the next glued track).

Q

Link to comment
Share on other sites

9 hours ago, JohnK said:

Yes this shows the desired ribbon (track support) for the helix/spiral.
However the normals/binormals/tangets still seem to be computed with tilt.
See the updated playground:

https://www.babylonjs-playground.com/#165IV6#432

Perhaps I need to create my own copy of Path3D... with the functions like Jerome suggested.
E.g. change the formula

	var tgts = path3d.getTangents();
	var norms = path3d.getNormals();
	var binorms = path3d.getBinormals();

in

showPath3D

so that it computes the way I want for "rail track".

When I take a close look at the starting vectors (point 0, at the bottom of the helix) you see a slightly off orientation from the white helix track support.

difference.png.2034ea639d7d65492506666bfc35cc3a.png

Hint: The green line is slightly off the edge of the white ribbon start.
The formula for Path3D takes the shortest line from point 0 to point 1, which is not desired for my purpose.
You see the red line of the first point 0 intersecting point 1, while all other points are not connected this way.
Hence I need to write some extension of Path3D that takes into account starting orientation and that is constrained by rail track limits (e.g. no cumulative inward tilt on a spiral point array; a rail track elevation is limited to a certain max angle).
Let's call the new class RailPath3D :-)

I use the Axis system from the Path3D to orient the train/vehicle rotate while driving on the helix.
That's why I look for tangent/normal/binormal arrays :-)
It also helps me set the width of the helix ribbon (compute the inner and outer points like you do, but then based on the center line color Purple), the track rail (one on each side) etc.

Q

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...