// Abstract Interface for Distance Sensors // Copyright (C)2026, Philip Munts dba Munts Technologies. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. namespace IO.Interfaces.Distance { /// /// Abstract interface for distance sensors. /// public interface Sensor { /// /// Read-only property returning the distance to an object in /// meters. /// double meters { get; } /// /// Read-only property returning the distance to an object in /// centimeters. /// double centimeters { get; } /// /// Read-only property returning the distance to an object in /// inches. /// double inches { get; } } /// /// Distance conversion functions. /// /// /// Conversion factors for meters to Standard aka English units /// were extracted from the CRC Handbook of Chemistry and Physics 60th /// Edition, page F-321. /// public class Conversions { /// /// Convert meters to milliimeters /// /// Distance in meters. /// Distance in milliimeters. public static double MetersToMillimeters(double meters) { return meters*1000.0; } /// /// Convert meters to centimeters /// /// Distance in meters. /// Distance in centimeters. public static double MetersToCentimeters(double meters) { return meters*100.0; } /// /// Convert meters to kilometers /// /// Distance in meters. /// Distance in kilometers. public static double MetersToKilometers(double meters) { return meters/1000.0; } /// /// Convert meters to inches /// /// Distance in meters. /// Distance in inches. public static double MetersToInches(double meters) { return meters*39.370079; } /// /// Convert meters to feet /// /// Distance in meters. /// Distance in feet. public static double MetersToFeet(double meters) { return meters*3.2808399; } /// /// Convert meters to yards /// /// Distance in meters. /// Distance in yarts. public static double MetersToYards(double meters) { return meters*1.0936133; } /// /// Convert meters to statute miles /// /// Distance in meters. /// Distance in statute miles. public static double MetersToMiles(double meters) { return meters*0.00062137119; } } }