SomeCatCode / open_table_top_pathing

Little Script for SVG Maps with Pathing
GNU General Public License v3.0
2 stars 0 forks source link

Include planet circumflex in route calculation #2

Closed ChaoticEvilDM closed 3 months ago

ChaoticEvilDM commented 3 months ago

Situation:

Currently, we are calculating the distance between two points P₀(X,Y) and P₁(X,Y) by applying a simple pythagorean theorem. This works for any given map size.

Issue:

Planets are round. If you take trips past 50km, the circumflex of the planet will sooner or later play a role in lengthening the travel time. This is neither represented, since we are using a simple 2D projection, nor calculated. Since presentation is considered a secondary issue, calculation should be addressed.

Suggestion:

Include a global variable that, when activated, adds the following parameter: d=Diameter of the planet

Reasoning:

Any straight line traveled on a sphere can be reduced by one dimension, so that P₀(X,Y) and P₁(X,Y) are points on a circles rim. We know from an applied pythagorean theorem, that a straight line c connects them. We know the value of c.

Applying this knowledge, we now can apply the following formula for r=5000 and c 250.

To find the distance between points P₀ and P₁ along the circumference of the circle, we need to calculate the length of the arc formed by the segment of the circle that intersects the line c connecting P₀ and P₁.

Given:

To find the distance along the circle's circumference between points P₀ and P₁​, we need to find the angle subtended by the arc at the center of the circle.

Using the formula for the length of an arc of a circle: Arc Length=θ×r

Where:

First, we find the angle θ using trigonometry. Since the line c is a chord of the circle, we can find θ using the formula for the central angle subtended by a chord: θ=2×arcsin⁡(d/2r)

Substituting the given values: θ=2×arcsin⁡(250/2×5000)

θ=2×arcsin⁡(1/40)

θ≈0.0504 radians

Now, we can find the arc length between P₀ and P₁​​: Arc Length=θ×r Arc Length≈0.0504×5000 Arc Length≈252 km

So, the distance along the circle's circumference between points P₀ and P₁​ is approximately 252 km.

This will correct long range travel by a non-negligible factor, without forcing the projection to change.

ChaoticEvilDM commented 3 months ago

@SomeCatCode Would you prefere me commiting just the function for the calculations with an optional flag for planetary scaling or should I just commit the math and let you handle the rest?

Soll ich direkt die Funktion einbauen oder willst du nur die Mathe haben und das selbst implementieren? Das zahlt auch auf einen anderen Teil dieses Milestones ein.

ChaoticEvilDM commented 3 months ago

Issue is closed following commit in the local milestone branch.