🛠️ToolsShed

Convertitore di velocità del vento

Converti la velocità del vento tra m/s, km/h, mph, nodi e scala Beaufort.

Conversions

m/s2.78
km/h10.0
mph6.2
knots5.4
Beaufort2

Beaufort Scale

2

Light breeze

Beaufort scale

Domande Frequenti

Implementazione del Codice

import math

# Wind speed conversion functions (base unit: m/s)
def to_ms(value, unit):
    conversions = {"ms": 1, "kmh": 1/3.6, "mph": 1/2.23694, "knots": 1/1.94384}
    if unit == "beaufort":
        b = max(0, min(12, round(value)))
        return 0.836 * (b ** 1.5)
    return value * conversions[unit]

def from_ms(ms, unit):
    if unit == "beaufort":
        return (ms / 0.836) ** (2/3) if ms > 0 else 0
    conversions = {"ms": 1, "kmh": 3.6, "mph": 2.23694, "knots": 1.94384}
    return ms * conversions[unit]

# Convert 10 m/s to all units
ms = 10
print(f"10 m/s =")
print(f"  {from_ms(ms, 'kmh'):.1f} km/h")
print(f"  {from_ms(ms, 'mph'):.1f} mph")
print(f"  {from_ms(ms, 'knots'):.1f} knots")
print(f"  {from_ms(ms, 'beaufort'):.1f} Beaufort")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.