21 public enum LengthUnit
24 [Tooltip(
"A smoot is the height of Oliver R. Smoot, equivalent to 5ft 7in or 1.702m.")]
27 [Tooltip(
"An attoparsec is one quintillionth of a parsec, or slightly more than 3cm.")]
30 [Tooltip(
"A mega beard-second is one million beard-seconds (the distance a typical beard grows in one second, about 5nm), or about 5mm.")]
34 [Tooltip(
"A furlong is 220 yards.")]
106 #endregion Public Fields
109 #region Private Fields
111 private float _meters;
112 private const float METERS_TO_INCHES = 39.3701f,
113 METERS_TO_FEET = 3.28084f,
114 METERS_TO_YARDS = 1.0936f,
115 METERS_TO_FURLONGS = 0.004971f,
116 METERS_TO_MILLIMETERS = 1000f,
117 METERS_TO_MEGABEARDSECONDS = 200f,
118 METERS_TO_CENTIMETERS = 100f,
119 METERS_TO_ATTOPARSECS = 32.4078f,
120 METERS_TO_SMOOTS = 0.587613f,
121 METERS_TO_KILOMETERS = 0.001f,
122 MILES_TO_METERS = 1609.34f;
124 #endregion Public Fields
127 #region Public Functions
129 public Length(
float value, LengthUnit unit)
170 case LengthUnit.Kilometers:
171 meters = length / METERS_TO_KILOMETERS;
173 case LengthUnit.Smoots:
174 meters = length / METERS_TO_SMOOTS;
176 case LengthUnit.Attoparsecs:
177 meters = length / METERS_TO_ATTOPARSECS;
179 case LengthUnit.Centimeters:
180 meters = length / METERS_TO_CENTIMETERS;
182 case LengthUnit.MegaBeardSeconds:
183 meters = length / METERS_TO_MEGABEARDSECONDS;
185 case LengthUnit.Millimeters:
186 meters = length / METERS_TO_MILLIMETERS;
188 case LengthUnit.Miles:
189 meters = length * MILES_TO_METERS;
191 case LengthUnit.Furlongs:
192 meters = length / METERS_TO_FURLONGS;
194 case LengthUnit.Yards:
195 meters = length / METERS_TO_YARDS;
197 case LengthUnit.Feet:
198 meters = length / METERS_TO_FEET;
200 case LengthUnit.Inches:
201 meters = length / METERS_TO_INCHES;
221 case LengthUnit.Kilometers:
222 return meters * METERS_TO_KILOMETERS;
223 case LengthUnit.Smoots:
224 return meters * METERS_TO_SMOOTS;
225 case LengthUnit.Attoparsecs:
226 return meters * METERS_TO_ATTOPARSECS;
227 case LengthUnit.Centimeters:
228 return meters * METERS_TO_CENTIMETERS;
229 case LengthUnit.MegaBeardSeconds:
230 return meters * METERS_TO_MEGABEARDSECONDS;
231 case LengthUnit.Millimeters:
232 return meters * METERS_TO_MILLIMETERS;
233 case LengthUnit.Miles:
234 return meters / MILES_TO_METERS;
235 case LengthUnit.Furlongs:
236 return meters * METERS_TO_FURLONGS;
237 case LengthUnit.Yards:
238 return meters * METERS_TO_YARDS;
239 case LengthUnit.Feet:
240 return meters * METERS_TO_FEET;
241 case LengthUnit.Inches:
242 return meters * METERS_TO_INCHES;
262 case LengthUnit.Kilometers:
263 return meters * METERS_TO_KILOMETERS;
264 case LengthUnit.Smoots:
265 return meters * METERS_TO_SMOOTS;
266 case LengthUnit.Attoparsecs:
267 return meters * METERS_TO_ATTOPARSECS;
268 case LengthUnit.Centimeters:
269 return meters * METERS_TO_CENTIMETERS;
270 case LengthUnit.MegaBeardSeconds:
271 return meters * METERS_TO_MEGABEARDSECONDS;
272 case LengthUnit.Millimeters:
273 return meters * METERS_TO_MILLIMETERS;
274 case LengthUnit.Miles:
275 return meters / MILES_TO_METERS;
276 case LengthUnit.Furlongs:
277 return meters * METERS_TO_FURLONGS;
278 case LengthUnit.Yards:
279 return meters * METERS_TO_YARDS;
280 case LengthUnit.Feet:
281 return meters * METERS_TO_FEET;
282 case LengthUnit.Inches:
283 return meters * METERS_TO_INCHES;
296 =>
new Length(a.ToMeters * scalar, LengthUnit.Meters);
305 =>
new Length(a.ToMeters + b.ToMeters, LengthUnit.Meters);
314 =>
new Length(a.ToMeters - b.ToMeters, LengthUnit.Meters);
316 #endregion Public Functions
float ToFurlongs
The Length, converted to furlongs.
float ToKilometers
The Length, converted to kilometers.
float ToCentimeters
The Length, converted to centimeters.
static float ConvertMetersTo(float meters, LengthUnit unit)
Converts the provided meter value to a value in the provided units.
float ToYards
The Length, converted to yards.
float ToMiles
The Length, converted to miles.
double PreciselyConvertTo(LengthUnit unit)
Converts the length to a double value in the provided units.
static Length operator*(Length a, float scalar)
Multiplies a Length by some scalar value.
float ConvertTo(LengthUnit unit)
Converts the length to a value in the provided units.
float ToSmoots
The Length, converted to smoots.
static double PreciselyConvertMetersTo(double meters, LengthUnit unit)
Converts the provided meter value to a double value in the provided units.
float ToFeet
The Length, converted to feet.
float ToMillimeters
The Length, converted to millimeters.
static float ConvertToMeters(float length, LengthUnit unit)
Converts the provided length value to a value in meters.
static Length operator+(Length a, Length b)
Adds two Length values together.
static Length operator-(Length a, Length b)
Subtracts one Length value from another Length value.
float ToInches
The Length, converted to inches.
float ToMeters
The Length, converted to meters.
float ToAttoparsecs
The Length, converted to attoparsecs.
float ToMegaBeardSeconds
The Length, converted to mega-beard-seconds.