Immersive Railroading

Immersive Railroading

3M Downloads

Catenary Implementation Specifics

andrewlalis opened this issue ยท 0 comments

commented

Describe the suggestion
I know that it's been requested for a while that this mod provide a solution to electric locomotives/overhead wires, and so I did some thinking as to how that can be implemented in a somewhat decent way. So here are my thoughts about how one might go about adding catenary wires and poles.

Poles

The poles holding up the catenary wires should ideally be placeable as a multi-block structure (or perhaps an item that when placed, constructs the multiple-block pole in-situ), whose orientation is not initially relevant. Using the wrench, one would be able to interact with the pole structure, and the pole would be modified at that time to show a mounting bracket oriented in the vector direction equivalent to the vector from the player to the pole. So, each pole essentially has the following state information:

private Vec2 mountingBracketOrientation; // null indicates no orientation has been chosen.

Wires

Catenary wires generally always follow a hyperbolic cosine curve, as shown here: https://en.wikipedia.org/wiki/Catenary#Mathematical_description

Since railroad catenary consists of both the actual catenary support wire and the smaller electrical wire, I think it would be feasible to simply define a suitable value for a in the catenary equation through experimentation, as well as the height difference between the support and power wire attachment points on the pole mounting bracket. Then, you can easily derive the maximum allowable distance between two mounting brackets as the distance at which the minimum of the catenary equation equals the height of the power wire.

To actually store and keep track of the state of the wires' existence, it should be rather straightforward to store additional information at the pole:

private BlockPos leftWirePoleConnection; // null indicates no wire connection.
private BlockPos rightWirePoleConnection; // null indicates no wire connection.

Suppose you have the following scenario:

---+-------------------------------------+--
Pole A                                                 Pole B

Here, A.rightWirePoleConnection would be set to the block position of the base of Pole B, and B.leftWirePoleConnection would be set to the block position of the base of Pole A. With this design, all information needed to render wires that are within render distance is present, and the redundant information shouldn't impose a significant burden. The actual attachment points for the wires can be derived, given a pole's base block position, its mounting bracket orientation, and possibly other factors such as height or mounting bracket overhang distance.

Supplying power to the rails is something I'm still not sure about, since I don't know enough about how minecraft mods use energy.

Applications of the suggestion
Building electrified rail lines.