Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion between units #4408

Closed
DorpsGek opened this issue Jan 14, 2011 · 8 comments
Closed

Conversion between units #4408

DorpsGek opened this issue Jan 14, 2011 · 8 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

mb opened the ticket and wrote:

Display of power values in OTTD is still a mess. Whatever the internal unit may be, conversion between unit systems should be as correct as possible.

Since years, there´s no difference made between "PS" and "hp", although these are two different unit systems (both no longer statutory, BTW). And, moreover, there are two different units for "hp":

- imperial horsepower = 0.7457 kW
- metric horsepower = 0.735499 kW

See http://en.wikipedia.org/wiki/Horsepower

In "game options", there´s a menu for "measuring units" which handles conversion between different unit systems, depending on the language.

For German, units given are "US-Maße" (whatever this is), "metric", and "SI". For English (UK) we find "imperial", "metric", and "SI".

Now, when converting PS or hp to kW, a value for "3000" (hp or PS, whatever) is converted to 2238 kW.

Now, given the two definitions of "hp" from above, OTTD´s internal conversion seems to be carried out with "imperial hp" -> 2238 kW / 0.7457 kW/hpi -> 3001.2 hp, not with "metric hp" -> 2238 / 0.735499 kW/hpm -> 3042.83 hp.

So, now we know the base unit ("imperial hp"), there are still two things wrong:

  1. 1 PS (German) = 0.73549875 kW. From the above, this is "metric hp", i.e. 3000 PS should result to 2206 kW, but OTTD displays "2238 kW" which is wrong (because the internal unit used for "hp" is really "imperial hp", it´s not "metric hp").

  2. under English (UK) language, the "measuring units" menu is showing "3000 hp" when set to "imperial", "3000hp" when set to "metric" and "2238 kW" when set to "SI". Obviously, values for "imperial" and "metric" should be different, simply because "imperial hp" and "metric hp" are different. After all, that´s why there are two different entries in the menu! (+SI, o/c).

To get things right, a small modification should be sufficient, it´s only the display in the various windows, no internal calculations are affected.

I´d like to add that this is not nit-picking because the reason is not a rounding error. It´s simply a bug.

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/4408
@DorpsGek
Copy link
Member Author

peter1138 wrote:

Attached patch changes the code to use simple division instead of binary shifts, allow much greater freedom in the conversion factors.

After this it should be fairly simple to make the conversions accurate and use correct units, although for maybe keep the hybrid ones for "historical" sake...

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9454

@DorpsGek
Copy link
Member Author

peter1138 wrote:

Regarding both metric and imperial power units being PS in German, this is a translation error, though kind of understandable given the value doesn't change between them...

STR_UNITS_POWER_IMPERIAL :{COMMA}PS
STR_UNITS_POWER_METRIC :{COMMA}PS


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9456

@DorpsGek
Copy link
Member Author

mb wrote:

Regarding both metric and imperial power units being PS in German [...]

How could it?

1 imperial horsepower = 745.7 W
1 metric horsepower = 735.49 W
1 PS = 735.49 W

And, as shown above, OTTD´s "internal unit" seems to be based on "imperial hp", i.e. 745.7 W.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9457

@DorpsGek
Copy link
Member Author

peter1138 wrote:

Hehe, what I meant was the strings allow for metric and imperial HP, even if the code doesn't.

By the way, what if the the vehicle's motors are electric, in which case "one horsepower for rating electric motors is equal to 746 watts."

In fact the conversion factor is already 746, not 745.7, because that's a bit simpler when dealing with integers.
This is the number used for acceleration calculations too.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9459

@DorpsGek
Copy link
Member Author

mb wrote:

Hehe, what I meant was the strings allow for metric and imperial HP, even if the code doesn't.

I thought it could be meant that way, but I wasn´t sure. ;)

By the way, what if the the vehicle's motors are electric, in which case "one horsepower for
rating electric motors is equal to 746 watts."

In fact the conversion factor is already 746, not 745.7, because that's a bit simpler when
dealing with integers.

746 instead of 745.7 is fine, hehe. But o/c that´s just the base for my proposed modifications (as well as your nice patch):

- make 1 PS = 735 / 745 units (resp. imperial | "electric motors" hp)
- allow display of both imperial horsepower and metric horsepower in the appropriate entries in the "measuring units" menu, as different values.

There might be "problems" with US units too, but I´ve not taken any look into this.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9461

@DorpsGek
Copy link
Member Author

Rubidium wrote:

What are the exact intentions of you?

I'm using the premise here that the internal unit isn't changed, so that stays at ~746W or 1 imperial HP, and 1 metric HP would become 735W.

But you're also talking about electric horsepower which is 746W. Should that be used as conversion for the electric trains/trams when using metric units? Doing so would cause major problems when a vehicle has both electric and diesel/steam engines; in that case part of the HPs are metric and part electric.

So is just using 1 metric HP = 735W as conversion factor okay? Or rather: 10.000 imperial HP = 7457 kW = 10.139 metric HP regardless of the engine type, just the conversion settings. Right?


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9662

@DorpsGek
Copy link
Member Author

mb wrote:

But you're also talking about electric horsepower which is 746W. [...]

That was Peter.

So is just using 1 metric HP = 735W as conversion factor okay? Or rather: 10.000 imperial HP =
7457 kW = 10.139 metric HP regardless of the engine type, just the conversion settings. Right?

Yes, I think so.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408#comment9665

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r22056


This comment was imported from FlySpray: https://bugs.openttd.org/task/4408

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant