Tilt Five™ Unity API  1.3.0
 
Loading...
Searching...
No Matches
TiltFive.Length Struct Reference

Public Member Functions

 Length (float value, LengthUnit unit)
 
float ConvertTo (LengthUnit unit)
 Converts the length to a value in the provided units.
 
double PreciselyConvertTo (LengthUnit unit)
 Converts the length to a double value in the provided units.
 

Static Public Member Functions

static float ConvertToMeters (float length, LengthUnit unit)
 Converts the provided length value to a value in meters.
 
static float ConvertMetersTo (float meters, LengthUnit unit)
 Converts the provided meter value to a value in the provided units.
 
static double PreciselyConvertMetersTo (double meters, LengthUnit unit)
 Converts the provided meter value to a double value in the provided units.
 
static Length operator* (Length a, float scalar)
 Multiplies a Length by some scalar value.
 
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.
 

Properties

float ToInches [get]
 The Length, converted to inches.
 
float ToFeet [get]
 The Length, converted to feet.
 
float ToYards [get]
 The Length, converted to yards.
 
float ToFurlongs [get]
 The Length, converted to furlongs.
 
float ToMiles [get]
 The Length, converted to miles.
 
float ToMillimeters [get]
 The Length, converted to millimeters.
 
float ToMegaBeardSeconds [get]
 The Length, converted to mega-beard-seconds.
 
float ToCentimeters [get]
 The Length, converted to centimeters.
 
float ToAttoparsecs [get]
 The Length, converted to attoparsecs.
 
float ToMeters [get]
 The Length, converted to meters.
 
float ToSmoots [get]
 The Length, converted to smoots.
 
float ToKilometers [get]
 The Length, converted to kilometers.
 

Private Attributes

float _meters
 

Static Private Attributes

const float METERS_TO_INCHES = 39.3701f
 
const float METERS_TO_FEET = 3.28084f
 
const float METERS_TO_YARDS = 1.0936f
 
const float METERS_TO_FURLONGS = 0.004971f
 
const float METERS_TO_MILLIMETERS = 1000f
 
const float METERS_TO_MEGABEARDSECONDS = 200f
 
const float METERS_TO_CENTIMETERS = 100f
 
const float METERS_TO_ATTOPARSECS = 32.4078f
 
const float METERS_TO_SMOOTS = 0.587613f
 
const float METERS_TO_KILOMETERS = 0.001f
 
const float MILES_TO_METERS = 1609.34f
 

Detailed Description

Definition at line 41 of file Length.cs.

Constructor & Destructor Documentation

◆ Length()

TiltFive.Length.Length ( float  value,
LengthUnit  unit 
)

Definition at line 129 of file Length.cs.

130 {
131 _meters = ConvertToMeters(value, unit);
132 }
static float ConvertToMeters(float length, LengthUnit unit)
Converts the provided length value to a value in meters.
Definition: Length.cs:164
float _meters
Definition: Length.cs:111

References TiltFive.Length._meters, and TiltFive.Length.ConvertToMeters().

Member Function Documentation

◆ ConvertMetersTo()

static float TiltFive.Length.ConvertMetersTo ( float  meters,
LengthUnit  unit 
)
static

Converts the provided meter value to a value in the provided units.

Parameters
metersThe provided length in meters.
unitThe provided length units.
Returns
The length, in the provided units.

Definition at line 217 of file Length.cs.

218 {
219 switch (unit)
220 {
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;
243 default: // Meters
244 return meters;
245 }
246 }
LengthUnit
Definition: Length.cs:22
const float METERS_TO_KILOMETERS
Definition: Length.cs:121
const float METERS_TO_FEET
Definition: Length.cs:113
const float MILES_TO_METERS
Definition: Length.cs:122
const float METERS_TO_MEGABEARDSECONDS
Definition: Length.cs:117
const float METERS_TO_FURLONGS
Definition: Length.cs:115
const float METERS_TO_INCHES
Definition: Length.cs:112
const float METERS_TO_SMOOTS
Definition: Length.cs:120
const float METERS_TO_CENTIMETERS
Definition: Length.cs:118
const float METERS_TO_YARDS
Definition: Length.cs:114
const float METERS_TO_MILLIMETERS
Definition: Length.cs:116
const float METERS_TO_ATTOPARSECS
Definition: Length.cs:119

References TiltFive.Length.METERS_TO_ATTOPARSECS, TiltFive.Length.METERS_TO_CENTIMETERS, TiltFive.Length.METERS_TO_FEET, TiltFive.Length.METERS_TO_FURLONGS, TiltFive.Length.METERS_TO_INCHES, TiltFive.Length.METERS_TO_KILOMETERS, TiltFive.Length.METERS_TO_MEGABEARDSECONDS, TiltFive.Length.METERS_TO_MILLIMETERS, TiltFive.Length.METERS_TO_SMOOTS, TiltFive.Length.METERS_TO_YARDS, and TiltFive.Length.MILES_TO_METERS.

Referenced by TiltFive.Length.ConvertTo().

◆ ConvertTo()

float TiltFive.Length.ConvertTo ( LengthUnit  unit)

Converts the length to a value in the provided units.

Parameters
unitThe provided length units.
Returns
The length, in the provided units.

Definition at line 139 of file Length.cs.

140 {
141 return ConvertMetersTo(_meters, unit);
142 }
static float ConvertMetersTo(float meters, LengthUnit unit)
Converts the provided meter value to a value in the provided units.
Definition: Length.cs:217

References TiltFive.Length._meters, and TiltFive.Length.ConvertMetersTo().

◆ ConvertToMeters()

static float TiltFive.Length.ConvertToMeters ( float  length,
LengthUnit  unit 
)
static

Converts the provided length value to a value in meters.

Parameters
lengthThe provided length.
unitThe provided length units.
Returns
The length, in meters.

Definition at line 164 of file Length.cs.

165 {
166 float meters = 0f;
167
168 switch (unit)
169 {
170 case LengthUnit.Kilometers:
171 meters = length / METERS_TO_KILOMETERS;
172 break;
173 case LengthUnit.Smoots:
174 meters = length / METERS_TO_SMOOTS;
175 break;
176 case LengthUnit.Attoparsecs:
177 meters = length / METERS_TO_ATTOPARSECS;
178 break;
179 case LengthUnit.Centimeters:
180 meters = length / METERS_TO_CENTIMETERS;
181 break;
182 case LengthUnit.MegaBeardSeconds:
183 meters = length / METERS_TO_MEGABEARDSECONDS;
184 break;
185 case LengthUnit.Millimeters:
186 meters = length / METERS_TO_MILLIMETERS;
187 break;
188 case LengthUnit.Miles:
189 meters = length * MILES_TO_METERS;
190 break;
191 case LengthUnit.Furlongs:
192 meters = length / METERS_TO_FURLONGS;
193 break;
194 case LengthUnit.Yards:
195 meters = length / METERS_TO_YARDS;
196 break;
197 case LengthUnit.Feet:
198 meters = length / METERS_TO_FEET;
199 break;
200 case LengthUnit.Inches:
201 meters = length / METERS_TO_INCHES;
202 break;
203 default: // Meters
204 meters = length;
205 break;
206 }
207
208 return meters;
209 }

References TiltFive.Length.METERS_TO_ATTOPARSECS, TiltFive.Length.METERS_TO_CENTIMETERS, TiltFive.Length.METERS_TO_FEET, TiltFive.Length.METERS_TO_FURLONGS, TiltFive.Length.METERS_TO_INCHES, TiltFive.Length.METERS_TO_KILOMETERS, TiltFive.Length.METERS_TO_MEGABEARDSECONDS, TiltFive.Length.METERS_TO_MILLIMETERS, TiltFive.Length.METERS_TO_SMOOTS, TiltFive.Length.METERS_TO_YARDS, and TiltFive.Length.MILES_TO_METERS.

Referenced by TiltFive.Length.Length().

◆ operator*()

static Length TiltFive.Length.operator* ( Length  a,
float  scalar 
)
static

Multiplies a Length by some scalar value.

Parameters
a
scalar
Returns

◆ operator+()

static Length TiltFive.Length.operator+ ( Length  a,
Length  b 
)
static

Adds two Length values together.

Parameters
a
b
Returns

◆ operator-()

static Length TiltFive.Length.operator- ( Length  a,
Length  b 
)
static

Subtracts one Length value from another Length value.

Parameters
a
b
Returns

◆ PreciselyConvertMetersTo()

static double TiltFive.Length.PreciselyConvertMetersTo ( double  meters,
LengthUnit  unit 
)
static

Converts the provided meter value to a double value in the provided units.

Parameters
metersThe provided length in meters.
unitThe provided length units.
Returns
The length, in the provided units.

Performs the conversion calculation using double arithmetic to reduce floating-point rounding errors. This may be less performant, so Drink Responsibly™. /remarks>

Definition at line 258 of file Length.cs.

259 {
260 switch (unit)
261 {
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;
284 default: // Meters
285 return meters;
286 }
287 }

References TiltFive.Length.METERS_TO_ATTOPARSECS, TiltFive.Length.METERS_TO_CENTIMETERS, TiltFive.Length.METERS_TO_FEET, TiltFive.Length.METERS_TO_FURLONGS, TiltFive.Length.METERS_TO_INCHES, TiltFive.Length.METERS_TO_KILOMETERS, TiltFive.Length.METERS_TO_MEGABEARDSECONDS, TiltFive.Length.METERS_TO_MILLIMETERS, TiltFive.Length.METERS_TO_SMOOTS, TiltFive.Length.METERS_TO_YARDS, and TiltFive.Length.MILES_TO_METERS.

Referenced by TiltFive.Length.PreciselyConvertTo().

◆ PreciselyConvertTo()

double TiltFive.Length.PreciselyConvertTo ( LengthUnit  unit)

Converts the length to a double value in the provided units.

Parameters
unitThe provided length units.
Returns
The length, in the provided units.

Performs the conversion calculation using double arithmetic to reduce floating-point rounding errors. This may be less performant, so Drink Responsibly™. /remarks>

Definition at line 153 of file Length.cs.

154 {
155 return PreciselyConvertMetersTo(_meters, unit);
156 }
static double PreciselyConvertMetersTo(double meters, LengthUnit unit)
Converts the provided meter value to a double value in the provided units.
Definition: Length.cs:258

References TiltFive.Length._meters, and TiltFive.Length.PreciselyConvertMetersTo().

Member Data Documentation

◆ _meters

float TiltFive.Length._meters
private

◆ METERS_TO_ATTOPARSECS

const float TiltFive.Length.METERS_TO_ATTOPARSECS = 32.4078f
staticprivate

◆ METERS_TO_CENTIMETERS

const float TiltFive.Length.METERS_TO_CENTIMETERS = 100f
staticprivate

◆ METERS_TO_FEET

const float TiltFive.Length.METERS_TO_FEET = 3.28084f
staticprivate

◆ METERS_TO_FURLONGS

const float TiltFive.Length.METERS_TO_FURLONGS = 0.004971f
staticprivate

◆ METERS_TO_INCHES

const float TiltFive.Length.METERS_TO_INCHES = 39.3701f
staticprivate

◆ METERS_TO_KILOMETERS

const float TiltFive.Length.METERS_TO_KILOMETERS = 0.001f
staticprivate

◆ METERS_TO_MEGABEARDSECONDS

const float TiltFive.Length.METERS_TO_MEGABEARDSECONDS = 200f
staticprivate

◆ METERS_TO_MILLIMETERS

const float TiltFive.Length.METERS_TO_MILLIMETERS = 1000f
staticprivate

◆ METERS_TO_SMOOTS

const float TiltFive.Length.METERS_TO_SMOOTS = 0.587613f
staticprivate

◆ METERS_TO_YARDS

const float TiltFive.Length.METERS_TO_YARDS = 1.0936f
staticprivate

◆ MILES_TO_METERS

const float TiltFive.Length.MILES_TO_METERS = 1609.34f
staticprivate

Property Documentation

◆ ToAttoparsecs

float TiltFive.Length.ToAttoparsecs
get

The Length, converted to attoparsecs.

Definition at line 89 of file Length.cs.

◆ ToCentimeters

float TiltFive.Length.ToCentimeters
get

The Length, converted to centimeters.

Definition at line 84 of file Length.cs.

◆ ToFeet

float TiltFive.Length.ToFeet
get

The Length, converted to feet.


Definition at line 54 of file Length.cs.

◆ ToFurlongs

float TiltFive.Length.ToFurlongs
get

The Length, converted to furlongs.

Definition at line 64 of file Length.cs.

◆ ToInches

float TiltFive.Length.ToInches
get

The Length, converted to inches.


Definition at line 49 of file Length.cs.

◆ ToKilometers

float TiltFive.Length.ToKilometers
get

The Length, converted to kilometers.

Definition at line 104 of file Length.cs.

◆ ToMegaBeardSeconds

float TiltFive.Length.ToMegaBeardSeconds
get

The Length, converted to mega-beard-seconds.

Definition at line 79 of file Length.cs.

◆ ToMeters

float TiltFive.Length.ToMeters
get

The Length, converted to meters.

Definition at line 94 of file Length.cs.

◆ ToMiles

float TiltFive.Length.ToMiles
get

The Length, converted to miles.

Definition at line 69 of file Length.cs.

◆ ToMillimeters

float TiltFive.Length.ToMillimeters
get

The Length, converted to millimeters.

Definition at line 74 of file Length.cs.

◆ ToSmoots

float TiltFive.Length.ToSmoots
get

The Length, converted to smoots.


Definition at line 99 of file Length.cs.

◆ ToYards

float TiltFive.Length.ToYards
get

The Length, converted to yards.

Definition at line 59 of file Length.cs.


The documentation for this struct was generated from the following file: