ruler-combinedMeasurements

Type-Safe Measurements Calculations

In One Line

Measure with confidence: Type-safe units, zero confusion!

Overview

Metric is a lightweight, type-safe library for handling length, area and weight measurements in different units. It prevents common unit conversion errors and provides a fluent API for calculations.


Package Info

display name

AceLand Measurements

package name

latest version

1.0.2

namespace

dependencies


Quick Start

using AceLand.Measurements;

// Create lengths using extension methods
Length height = 1.8.Meters();
Length width = 42.Inches();
Weight playerWeight = 180.Pounds();
Weight itemWeight = 500.Grams();

// Easy unit conversion - no calculations needed
double heightInFeet = height.Feet;        // 5.905512 ft
double widthInMeters = width.Meters;      // 1.0668 m
double kg = playerWeight.Kilograms;       // ~81.64 kg
double oz = itemWeight.Ounces;            // ~17.63 oz

// Create area from length multiplication
Area room = width * height;
double areaInSquareMeters = room.SquareMeters;    // 1.92024 m²
double areaInSquareFeet = room.SquareFeet;        // 20.67 ft²

// Other Calculations
Length h = 3.78.Meters();
Length w = 4.2.Feet();
Length l = 53.45.Inches();
Volume v = h * w * l;

Features

  • Type-safe measurements

  • Automatic unit conversion

  • Support for SI units and Imperial/US units

  • Clean, fluent API

  • Zero-allocation operations


Supported Units

Unit Type
Base Unit
Conversion
Calculator

Weight

Kilograms (kg)

-

-

Length

Meters (m)

Area (multiply) Volume (multiply) Pressue (extension)

-

Area

Square Meters (m2)

Volume (multiply)

-

Volume

Cubic Meters (m3)

-

-

Speed

Meters Per Second (m/s)

-

-

Angle

Degrees (°)

-

-

Pressure

Pascals (Pa)

-

Hydrostatics

Frequency

Hertz (Hz)

-

-

Data Volume

Bytes (B)

-

-


Calculators

Measurement Units are containing base unit value and conversion calculation only. Calculators contain specified measurement methods for units.

For example water depth to pressure, water depth is using Length as unit but we don't call it as length but depth, and the calculation is Hydrostatics. In this case we will create a tools for it. Of course we will also create extension to Length for same calculation.

Please see the page of Calculators for more.


Common Usage

Length Units

Area Units


Real-World Examples

Room Dimensions

Land Measurements


Best Practices

  • Use the most appropriate unit for your input data

  • Let the library handle all conversions

  • Use type inference with the fluent API

  • Take advantage of the built-in ToString() methods for debugging


Notes

  • All calculations maintain double precision

  • Internal storage uses meters and square meters

  • Conversions use standard SI definitions

  • Zero allocation for basic operations


Last updated