libs-base/Source/NSUnit.m

1600 lines
46 KiB
Mathematica
Raw Permalink Normal View History

/** Implementation of class NSUnit
2019-09-30 19:59:50 +00:00
Copyright (C) 2019 Free Software Foundation, Inc.
2019-10-08 05:31:24 +00:00
By: Gregory John Casamento <greg.casamento@gmail.com>
2019-09-30 19:59:50 +00:00
Date: Mon Sep 30 15:58:21 EDT 2019
This file is part of the GNUstep Library.
2019-09-30 19:59:50 +00:00
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
2019-09-30 19:59:50 +00:00
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
2019-09-30 19:59:50 +00:00
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
2019-09-30 19:59:50 +00:00
*/
#import "Foundation/NSArchiver.h"
#import "Foundation/NSKeyedArchiver.h"
#import "Foundation/NSUnit.h"
2019-09-30 19:59:50 +00:00
2019-10-07 02:33:23 +00:00
// Private methods...
@interface NSDimension (Private)
- (instancetype) initWithSymbol: (NSString *)symbol
coefficient: (double)coefficient
constant: (double)constant;
@end
2019-10-02 09:47:03 +00:00
// Abstract conversion...
@implementation NSUnitConverter
- (double) baseUnitValueFromValue: (double)value
{
return 0.0;
}
- (double) valueFromBaseUnitValue: (double)baseUnitValue
{
return 0.0;
}
@end
2019-09-30 19:59:50 +00:00
2019-10-02 09:47:03 +00:00
// Linear conversion...
@implementation NSUnitConverterLinear
2019-10-02 06:05:18 +00:00
- (instancetype) initWithCoefficient: (double)coefficient
{
return [self initWithCoefficient: coefficient constant: 0.0];
2019-10-02 06:05:18 +00:00
}
- (instancetype) initWithCoefficient: (double)coefficient
constant: (double)constant
{
self = [super init];
if (self != nil)
2019-10-02 06:05:18 +00:00
{
_coefficient = coefficient;
_constant = constant;
}
return self;
}
- (id) initWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
2019-10-02 09:08:37 +00:00
{
_coefficient = [coder decodeDoubleForKey: @"NS.coefficient"];
_constant = [coder decodeDoubleForKey: @"NS.constant"];
2019-10-02 09:08:37 +00:00
}
else
{
[coder decodeValueOfObjCType: @encode(double) at: &_coefficient];
[coder decodeValueOfObjCType: @encode(double) at: &_constant];
}
return self;
2019-10-02 06:05:18 +00:00
}
- (void) encodeWithCoder: (NSCoder *)coder
{
2019-10-02 09:08:37 +00:00
if([coder allowsKeyedCoding])
{
[coder encodeDouble: _coefficient forKey: @"NS.coefficient"];
[coder encodeDouble: _constant forKey: @"NS.constant"];
2019-10-02 09:08:37 +00:00
}
else
{
2019-10-02 09:12:07 +00:00
[coder encodeValueOfObjCType: @encode(double) at: &_coefficient];
[coder encodeValueOfObjCType: @encode(double) at: &_constant];
2019-10-02 09:08:37 +00:00
}
2019-10-02 06:05:18 +00:00
}
- (double) coefficient
{
return _coefficient;
}
- (double) constant
{
return _constant;
}
2019-10-08 09:05:39 +00:00
- (double) baseUnitValueFromValue: (double)value
2019-10-08 09:05:39 +00:00
{
return (_coefficient * value) + _constant;
2019-10-08 09:05:39 +00:00
}
- (double) valueFromBaseUnitValue: (double)baseUnitValue
2019-10-08 09:05:39 +00:00
{
return (baseUnitValue - _constant) / _coefficient;
2019-10-08 09:05:39 +00:00
}
2019-10-02 06:05:18 +00:00
@end
2019-10-02 09:47:03 +00:00
// Abstract unit...
@implementation NSUnit
- (instancetype) init
{
return [self initWithSymbol: @""];
}
- (instancetype) initWithSymbol: (NSString *)symbol
{
self = [super init];
if (self != nil)
{
ASSIGNCOPY(_symbol, symbol);
}
return self;
}
- (id) initWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
_symbol = [coder decodeObjectForKey: @"NS.symbol"];
}
else
{
_symbol = [coder decodeObject];
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
[coder encodeObject: _symbol forKey: @"NS.symbol"];
}
else
{
[coder encodeObject: _symbol];
}
}
- (instancetype) copyWithZone: (NSZone *)zone
{
return [[NSUnit allocWithZone: zone] initWithSymbol: [self symbol]];
}
- (NSString *) symbol
{
return _symbol;
}
2019-09-30 19:59:50 +00:00
@end
2019-10-02 09:08:37 +00:00
// Dimension using units....
@implementation NSDimension
- (NSUnitConverter *) converter
{
return _converter;
}
- (instancetype) initWithSymbol: (NSString *)symbol converter: (NSUnitConverter *) converter
{
2019-10-04 08:05:34 +00:00
self = [super initWithSymbol: symbol];
if (self != nil)
2019-10-04 08:05:34 +00:00
{
ASSIGN(_converter, converter);
}
return self;
2019-10-02 09:08:37 +00:00
}
2019-10-07 02:33:23 +00:00
- (instancetype) initWithSymbol: (NSString *)symbol
coefficient: (double)coefficient
constant: (double)constant
{
NSUnitConverterLinear *converter = [[NSUnitConverterLinear alloc] initWithCoefficient: coefficient
constant: constant];
self = [self initWithSymbol: symbol
converter: converter];
RELEASE(converter);
return self;
2019-10-07 02:33:23 +00:00
}
2019-10-02 09:08:37 +00:00
+ (instancetype) baseUnit
{
return nil;
}
- (id) initWithCoder: (NSCoder *)coder
{
self = [super initWithCoder: coder];
if ([coder allowsKeyedCoding])
{
_converter = [coder decodeObjectForKey: @"NS.converter"];
}
else
{
_symbol = [coder decodeObject];
}
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder
{
[super encodeWithCoder: coder];
if ([coder allowsKeyedCoding])
{
[coder encodeObject: _converter forKey: @"NS.converter"];
}
else
{
[coder encodeObject: _symbol];
}
}
2019-10-02 09:08:37 +00:00
@end
2019-10-04 02:29:00 +00:00
// Predefined....
2019-10-06 04:37:30 +00:00
@implementation NSUnitAcceleration
2019-10-06 03:09:12 +00:00
2019-10-06 15:48:21 +00:00
+ (instancetype) baseUnit
{
return [self metersPerSecondSquared];
}
2019-10-06 04:37:30 +00:00
// Base unit - metersPerSecondSquared
2019-10-06 15:48:21 +00:00
+ (NSUnitAcceleration *) metersPerSecondSquared
{
return AUTORELEASE([[NSUnitAcceleration alloc] initWithSymbol: @"m/s^2"
coefficient: 1.0
constant: 0.0]);
2019-10-06 15:48:21 +00:00
}
+ (NSUnitAcceleration *) gravity
{
return AUTORELEASE([[NSUnitAcceleration alloc] initWithSymbol: @"g"
coefficient: 9.81
constant: 0]);
2019-10-06 15:48:21 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitAngle
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self degrees];
}
// Base unit - degrees
2019-10-07 02:33:23 +00:00
+ (NSUnitAngle *) degrees
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"deg"
coefficient: 1.0
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
+ (NSUnitAngle *) arcMinutes
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"'"
coefficient: 0.016667
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
+ (NSUnitAngle *) arcSeconds
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"\""
coefficient: 0.00027778
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
+ (NSUnitAngle *) radians
2019-10-07 02:33:23 +00:00
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"rad"
coefficient: 57.2958
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
+ (NSUnitAngle *) gradians
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"grad"
coefficient: 0.9
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
+ (NSUnitAngle *) revolutions
{
return AUTORELEASE([[NSUnitAngle alloc] initWithSymbol: @"rev"
coefficient: 360.0
constant: 0.0]);
2019-10-07 02:33:23 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitArea
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self squareMeters];
}
2019-10-06 04:37:30 +00:00
// Base unit - squareMeters
+ (NSUnitArea *) squareMegameters
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"Mm^2"
coefficient: 1e12
constant: 0.0]);
}
+ (NSUnitArea *) squareKilometers
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"km^2"
coefficient: 1000000.0
constant: 0.0]);
}
+ (NSUnitArea *) squareMeters
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"m^2"
coefficient: 1.0
constant: 0.0]);
}
+ (NSUnitArea *) squareCentimeters
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"cm^2"
coefficient: 0.0001
constant: 0.0]);
}
+ (NSUnitArea *) squareMillimeters
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"mm^2"
coefficient: 0.000001
constant: 0.0]);
}
+ (NSUnitArea *) squareMicrometers
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"um^2"
coefficient: 1e-12
constant: 0.0]);
}
+ (NSUnitArea *) squareNanometers
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"nm^2"
coefficient: 1e-18
constant: 0.0]);
}
+ (NSUnitArea *) squareInches
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"in^2"
coefficient: 0.00064516
constant: 0.0]);
}
+ (NSUnitArea *) squareFeet
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"ft^2"
coefficient: 0.092903
constant: 0.0]);
}
+ (NSUnitArea *) squareYards
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"yd^2"
coefficient: 0.836127
constant: 0.0]);
}
+ (NSUnitArea *) squareMiles
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"mi^2"
coefficient: 2.59e+6
constant: 0.0]);
}
+ (NSUnitArea *) acres
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"acres"
coefficient: 4046.86
constant: 0.0]);
}
+ (NSUnitArea *) ares
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"ares"
coefficient: 100.0
constant: 0.0]);
}
+ (NSUnitArea *) hectares
{
return AUTORELEASE([[NSUnitArea alloc] initWithSymbol: @"hectares"
coefficient: 10000.0
constant: 0.0]);
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitConcentrationMass
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self gramsPerLiter];
}
2019-10-06 04:37:30 +00:00
// Base unit - gramsPerLiter
2019-10-07 03:22:17 +00:00
+ (NSUnitConcentrationMass *) gramsPerLiter
{
return AUTORELEASE([[NSUnitConcentrationMass alloc] initWithSymbol: @"g/L"
coefficient: 1.0
constant: 0.0]);
2019-10-07 03:22:17 +00:00
}
+ (NSUnitConcentrationMass *) milligramsPerDeciliter
2019-10-07 03:22:17 +00:00
{
return AUTORELEASE([[NSUnitConcentrationMass alloc] initWithSymbol: @"mg/dL"
coefficient: 0.01
constant: 0.0]);
2019-10-07 03:22:17 +00:00
}
2019-10-04 02:29:00 +00:00
+ (NSUnitConcentrationMass *) millimolesPerLiterWithGramsPerMole:(double)gramsPerMole
2019-10-07 03:22:17 +00:00
{
return AUTORELEASE([[NSUnitConcentrationMass alloc] initWithSymbol: @"mmol/L"
coefficient: 18.0 * gramsPerMole
constant: 0.0]);
2019-10-07 03:22:17 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitDispersion
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self partsPerMillion];
}
2019-10-06 04:37:30 +00:00
// Base unit - partsPerMillion
+ (NSUnitDispersion *) partsPerMillion
2019-10-07 03:59:27 +00:00
{
return AUTORELEASE([[NSUnitDispersion alloc] initWithSymbol: @"ppm"
coefficient: 1.0
constant: 0.0]);
2019-10-07 03:59:27 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitDuration
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self seconds];
}
2019-10-06 04:37:30 +00:00
// Base unit - seconds
+ (NSUnitDuration *) seconds
2019-10-07 04:03:12 +00:00
{
return AUTORELEASE([[NSUnitDuration alloc] initWithSymbol: @"sec"
coefficient: 1.0
constant: 0.0]);
2019-10-07 04:03:12 +00:00
}
+ (NSUnitDuration *) minutes
2019-10-07 04:03:12 +00:00
{
return AUTORELEASE([[NSUnitDuration alloc] initWithSymbol: @"min"
coefficient: 60.0
constant: 0.0]);
2019-10-07 04:03:12 +00:00
}
+ (NSUnitDuration *) hours
2019-10-07 04:03:12 +00:00
{
return AUTORELEASE([[NSUnitDuration alloc] initWithSymbol: @"hr"
coefficient: 3600.0
constant: 0.0]);
2019-10-07 04:03:12 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitElectricCharge
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self coulombs];
}
2019-10-06 04:37:30 +00:00
// Base unit - coulombs
+ (NSUnitElectricCharge *) coulombs
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"C"
coefficient: 1.0
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
+ (NSUnitElectricCharge *) megaampereHours
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"MAh"
coefficient: 3.6e9
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
+ (NSUnitElectricCharge *) kiloampereHours
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"kAh"
coefficient: 3600000.0
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
+ (NSUnitElectricCharge *) ampereHours
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"mAh"
coefficient: 3600.0
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
+ (NSUnitElectricCharge *) milliampereHours
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"hr"
coefficient: 3.6
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
+ (NSUnitElectricCharge *) microampereHours
2019-10-07 04:15:41 +00:00
{
return AUTORELEASE([[NSUnitElectricCharge alloc] initWithSymbol: @"uAh"
coefficient: 0.0036
constant: 0.0]);
2019-10-07 04:15:41 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitElectricCurrent
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self amperes];
}
2019-10-06 04:37:30 +00:00
// Base unit - amperes
+ (NSUnitElectricCurrent *) megaamperes
2019-10-07 04:52:13 +00:00
{
return AUTORELEASE([[NSUnitElectricCurrent alloc] initWithSymbol: @"MA"
coefficient: 1000000.0
constant: 0.0]);
2019-10-07 04:52:13 +00:00
}
+ (NSUnitElectricCurrent *) kiloamperes
2019-10-07 04:52:13 +00:00
{
return AUTORELEASE([[NSUnitElectricCurrent alloc] initWithSymbol: @"kA"
coefficient: 1000.0
constant: 0.0]);
2019-10-07 04:52:13 +00:00
}
+ (NSUnitElectricCurrent *) amperes
2019-10-07 04:52:13 +00:00
{
return AUTORELEASE([[NSUnitElectricCurrent alloc] initWithSymbol: @"A"
coefficient: 1.0
constant: 0.0]);
2019-10-07 04:52:13 +00:00
}
+ (NSUnitElectricCurrent *) milliamperes
{
return AUTORELEASE([[NSUnitElectricCurrent alloc] initWithSymbol: @"mA"
coefficient: 0.001
constant: 0.0]);
2019-10-07 04:52:13 +00:00
}
+ (NSUnitElectricCurrent *) microamperes
{
return AUTORELEASE([[NSUnitElectricCurrent alloc] initWithSymbol: @"uA"
coefficient: 0.000001
constant: 0.0]);
2019-10-07 04:52:13 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitElectricPotentialDifference
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self volts];
}
2019-10-06 04:37:30 +00:00
// Base unit - volts
+ (NSUnitElectricPotentialDifference *) megavolts
{
return AUTORELEASE([[NSUnitElectricPotentialDifference alloc] initWithSymbol: @"MV"
coefficient: 1000000.0
constant: 0.0]);
}
+ (NSUnitElectricPotentialDifference *) kilovolts
{
return AUTORELEASE([[NSUnitElectricPotentialDifference alloc] initWithSymbol: @"kV"
coefficient: 1000.0
constant: 0.0]);
}
+ (NSUnitElectricPotentialDifference *) volts
{
return AUTORELEASE([[NSUnitElectricPotentialDifference alloc] initWithSymbol: @"V"
coefficient: 1.0
constant: 0.0]);
}
+ (NSUnitElectricPotentialDifference *) millivolts
{
return AUTORELEASE([[NSUnitElectricPotentialDifference alloc] initWithSymbol: @"mV"
coefficient: 0.001
constant: 0.0]);
}
+ (NSUnitElectricPotentialDifference *) microvolts
{
return AUTORELEASE([[NSUnitElectricPotentialDifference alloc] initWithSymbol: @"uV"
coefficient: 0.000001
constant: 0.0]);
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitElectricResistance
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self ohms];
}
2019-10-06 04:37:30 +00:00
// Base unit - ohms
+ (NSUnitElectricResistance *) megaohms
2019-10-07 05:54:16 +00:00
{
return AUTORELEASE([[NSUnitElectricResistance alloc] initWithSymbol: @"MOhm"
coefficient: 100000.0
constant: 0.0]);
2019-10-07 05:54:16 +00:00
}
+ (NSUnitElectricResistance *) kiloohms
2019-10-07 05:54:16 +00:00
{
return AUTORELEASE([[NSUnitElectricResistance alloc] initWithSymbol: @"kOhm"
coefficient: 1000.0
constant: 0.0]);
2019-10-07 05:54:16 +00:00
}
+ (NSUnitElectricResistance *) ohms
2019-10-07 05:54:16 +00:00
{
return AUTORELEASE([[NSUnitElectricResistance alloc] initWithSymbol: @"Ohm"
coefficient: 1.0
constant: 0.0]);
2019-10-07 05:54:16 +00:00
}
+ (NSUnitElectricResistance *) milliohms
2019-10-07 05:54:16 +00:00
{
return AUTORELEASE([[NSUnitElectricResistance alloc] initWithSymbol: @"mOhm"
coefficient: 0.001
constant: 0.0]);
2019-10-07 05:54:16 +00:00
}
+ (NSUnitElectricResistance *) microohms
2019-10-07 05:54:16 +00:00
{
return AUTORELEASE([[NSUnitElectricResistance alloc] initWithSymbol: @"uOhm"
coefficient: 0.000001
constant: 0.0]);
2019-10-07 05:54:16 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitEnergy
2019-10-04 02:29:00 +00:00
+ (instancetype) baseUnit
{
return [self joules];
}
2019-10-06 04:37:30 +00:00
// Base unit - joules
2019-10-07 07:16:01 +00:00
+ (NSUnitEnergy *) kilojoules
{
return AUTORELEASE([[NSUnitEnergy alloc] initWithSymbol: @"kJ"
2019-10-07 07:16:01 +00:00
coefficient: 1000.0
constant: 0.0]);
2019-10-07 07:16:01 +00:00
}
+ (NSUnitEnergy *) joules
2019-10-07 07:16:01 +00:00
{
return AUTORELEASE([[NSUnitEnergy alloc] initWithSymbol: @"J"
2019-10-07 07:16:01 +00:00
coefficient: 1.0
constant: 0.0]);
2019-10-07 07:16:01 +00:00
}
+ (NSUnitEnergy *) kilocalories
2019-10-07 07:16:01 +00:00
{
return AUTORELEASE([[NSUnitEnergy alloc] initWithSymbol: @"kCal"
2019-10-07 07:16:01 +00:00
coefficient: 4184.0
constant: 0.0]);
2019-10-07 07:16:01 +00:00
}
+ (NSUnitEnergy *) calories
2019-10-07 07:16:01 +00:00
{
return AUTORELEASE([[NSUnitEnergy alloc] initWithSymbol: @"cal"
2019-10-07 07:16:01 +00:00
coefficient: 4.184
constant: 0.0]);
2019-10-07 07:16:01 +00:00
}
+ (NSUnitEnergy *) kilowattHours
2019-10-07 07:16:01 +00:00
{
return AUTORELEASE([[NSUnitEnergy alloc] initWithSymbol: @"kWh"
2019-10-07 07:16:01 +00:00
coefficient: 3600000.0
constant: 0.0]);
2019-10-07 07:16:01 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitFrequency
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self hertz];
}
2019-10-06 04:37:30 +00:00
// Base unit - hertz
2019-10-04 02:29:00 +00:00
+ (NSUnitFrequency *) terahertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"thz"
coefficient: 1e12
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) gigahertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"ghz"
coefficient: 1e9
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) megahertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"GHz"
coefficient: 1000000.0
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) kilohertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"KHz"
coefficient: 1000.0
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) hertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"Hz"
coefficient: 1.0
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) millihertz
2019-10-07 07:47:46 +00:00
{
2021-01-18 11:52:37 +00:00
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"mHz"
coefficient: 0.001
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) microhertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"uHz"
coefficient: 0.000001
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
+ (NSUnitFrequency *) nanohertz
2019-10-07 07:47:46 +00:00
{
return AUTORELEASE([[NSUnitFrequency alloc] initWithSymbol: @"nHz"
coefficient: 1e-9
constant: 0.0]);
2019-10-07 07:47:46 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitFuelEfficiency
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self litersPer100Kilometers];
}
2019-10-06 04:37:30 +00:00
// Base unit - litersPer100Kilometers
2019-10-04 02:29:00 +00:00
2019-10-08 05:03:25 +00:00
+ (NSUnitFuelEfficiency *) litersPer100Kilometers
{
return AUTORELEASE([[NSUnitFuelEfficiency alloc] initWithSymbol: @"L/100km"
coefficient: 1.0
constant: 0.0]);
2019-10-08 05:03:25 +00:00
}
+ (NSUnitFuelEfficiency *) milesPerImperialGallon
{
// FIXME
return AUTORELEASE([[NSUnitFuelEfficiency alloc] initWithSymbol: @"mpg"
coefficient: 0.0
constant: 0.0]);
2019-10-08 05:03:25 +00:00
}
+ (NSUnitFuelEfficiency *) milesPerGallon
{
// FIXME
return AUTORELEASE([[NSUnitFuelEfficiency alloc] initWithSymbol: @"mpg"
coefficient: 0.0
constant: 0.0]);
2019-10-08 05:03:25 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitLength
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self meters];
}
2019-10-06 04:37:30 +00:00
// Base unit - meters
2019-10-04 02:29:00 +00:00
+ (NSUnitLength *) megameters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"Mm"
coefficient: 1000000.0
constant: 0.0]);
}
+ (NSUnitLength *) kilometers
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"kM"
coefficient: 1000.0
constant: 0.0]);
}
+ (NSUnitLength *) hectometers
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"hm"
coefficient: 100.0
constant: 0.0]);
}
+ (NSUnitLength *) decameters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"dam"
coefficient: 10
constant: 0.0]);
}
+ (NSUnitLength *) meters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"meters"
coefficient: 1.0
constant: 0.0]);
}
+ (NSUnitLength *) decimeters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"dm"
coefficient: 0.1
constant: 0.0]);
}
+ (NSUnitLength *) centimeters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"cm"
coefficient: 0.01
constant: 0.0]);
}
+ (NSUnitLength *) millimeters
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"mm"
coefficient: 0.001
constant: 0.0]);
}
+ (NSUnitLength *) micrometers
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"um"
coefficient: 0.000001
constant: 0.0]);
}
+ (NSUnitLength *) nanometers
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"nm"
coefficient: 1e-9
constant: 0.0]);
}
+ (NSUnitLength *) picometers
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"pm"
coefficient: 1e-12
constant: 0.0]);
}
+ (NSUnitLength *) inches
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"in"
coefficient: 0.254
constant: 0.0]);
}
+ (NSUnitLength *) feet
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"ft"
coefficient: 0.3048
constant: 0.0]);
}
+ (NSUnitLength *) yards
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"yd"
coefficient: 0.9144
constant: 0.0]);
}
+ (NSUnitLength *) miles
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"mi"
coefficient: 1609.34
constant: 0.0]);
}
+ (NSUnitLength *) scandinavianMiles
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"smi"
coefficient: 10000
constant: 0.0]);
}
+ (NSUnitLength *) lightyears
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"ly"
coefficient: 9.461e+15
constant: 0.0]);
}
+ (NSUnitLength *) nauticalMiles
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"NM"
coefficient: 1852.0
constant: 0.0]);
}
+ (NSUnitLength *) fathoms
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"ftm"
coefficient: 1.8288
constant: 0.0]);
}
+ (NSUnitLength *) furlongs
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"fur"
coefficient: 201.168
constant: 0.0]);
}
+ (NSUnitLength *) astronomicalUnits
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"ua"
coefficient: 1.496e+11
constant: 0.0]);
}
+ (NSUnitLength *) parsecs
{
return AUTORELEASE([[NSUnitLength alloc] initWithSymbol: @"pc"
coefficient: 3.086e+16
constant: 0.0]);
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitIlluminance
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self lux];
}
2019-10-06 04:37:30 +00:00
// Base unit - lux
2019-10-07 04:23:55 +00:00
+ (NSUnitIlluminance *) lux
{
return AUTORELEASE([[NSUnitIlluminance alloc] initWithSymbol: @"lux"
coefficient: 1.0
constant: 0.0]);
2019-10-07 04:23:55 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitMass
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self kilograms];
}
2019-10-06 04:37:30 +00:00
// Base unit - kilograms
2019-10-04 02:29:00 +00:00
+ (NSUnitMass *) kilograms
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"kg"
coefficient: 1.0
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) grams
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"g"
coefficient: 0.001
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) decigrams
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"dg"
coefficient: 0.0001
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) centigrams
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"cg"
coefficient: 0.00001
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) milligrams
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"mg"
coefficient: 0.000001
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) micrograms
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"ug"
coefficient: 1e-9
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) nanograms
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"ng"
coefficient: 1e-12
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) picograms
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"pg"
coefficient: 1e-15
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) ounces
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"oz"
coefficient: 0.0283495
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
2019-10-24 21:06:06 +00:00
+ (NSUnitMass *) pounds
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"lb"
coefficient: 0.453592
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) stones
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"st"
coefficient: 6.35029
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) metricTons
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"t"
coefficient: 1000
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) shortTons
2019-10-07 06:49:28 +00:00
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"ton"
coefficient: 907.185
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) carats
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"ct"
coefficient: 0.0002
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) ouncesTroy
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"oz t"
coefficient: 0.03110348
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
+ (NSUnitMass *) slugs
{
return AUTORELEASE([[NSUnitMass alloc] initWithSymbol: @"slug"
coefficient: 14.5939
constant: 0.0]);
2019-10-07 06:49:28 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitPower
2019-10-06 04:37:30 +00:00
+ (instancetype) baseUnit
{
return [self watts];
}
2019-10-06 04:37:30 +00:00
// Base unit - watts
2019-10-04 02:29:00 +00:00
+ (NSUnitPower *) terawatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"TW"
coefficient: 1e12
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) gigawatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"GW"
coefficient: 1e9
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) megawatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"MW"
coefficient: 1000000.0
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) kilowatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"kW"
coefficient: 1000.0
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) watts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"W"
coefficient: 1.0
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) milliwatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"mW"
coefficient: 0.001
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) microwatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"uW"
coefficient: 0.000001
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) nanowatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"nW"
coefficient: 1e-9
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) picowatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"pW"
coefficient: 1e-12
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) femtowatts
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"fW"
coefficient: 1e-15
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
+ (NSUnitPower *) horsepower
2019-10-07 13:57:59 +00:00
{
return AUTORELEASE([[NSUnitPower alloc] initWithSymbol: @"hp"
coefficient: 745.7
constant: 0.0]);
2019-10-07 13:57:59 +00:00
}
2019-10-04 02:29:00 +00:00
@end
2019-10-06 04:37:30 +00:00
@implementation NSUnitPressure
+ (instancetype) baseUnit
{
return [self newtonsPerMetersSquared];
}
2019-10-06 04:37:30 +00:00
// Base unit - newtonsPerMetersSquared (equivalent to 1 pascal)
2019-10-04 02:29:00 +00:00
+ (NSUnitPressure *) newtonsPerMetersSquared
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"N/m^2"
coefficient: 1.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) gigapascals
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"GPa"
2019-10-08 05:31:24 +00:00
coefficient: 1e9
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) megapascals
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"MPa"
2019-10-08 05:31:24 +00:00
coefficient: 1000000.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) kilopascals
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"kPa"
2019-10-08 05:31:24 +00:00
coefficient: 1000.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) hectopascals
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"hPa"
2019-10-08 05:31:24 +00:00
coefficient: 100.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) inchesOfMercury
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"inHg"
2019-10-08 05:31:24 +00:00
coefficient: 3386.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) bars
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"bars"
2019-10-08 05:31:24 +00:00
coefficient: 100000.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) millibars
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"mbars"
2019-10-08 05:31:24 +00:00
coefficient: 100.0
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) millimetersOfMercury
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"mmHg"
coefficient: 133.322
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
+ (NSUnitPressure *) poundsForcePerSquareInch
2019-10-08 05:31:24 +00:00
{
return AUTORELEASE([[NSUnitPressure alloc] initWithSymbol: @"psi"
2019-10-08 05:31:24 +00:00
coefficient: 6894.76
constant: 0.0]);
2019-10-08 05:31:24 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitSpeed
+ (instancetype) baseUnit
{
return [self metersPerSecond];
}
2019-10-04 02:29:00 +00:00
2019-10-06 04:37:30 +00:00
// Base unit - metersPerSecond
2019-10-08 04:44:38 +00:00
+ (NSUnitSpeed *) metersPerSecond
{
return AUTORELEASE([[NSUnitSpeed alloc] initWithSymbol: @"m/s"
coefficient: 1.0
constant: 0.0]);
2019-10-08 04:44:38 +00:00
}
+ (NSUnitSpeed *) kilometersPerHour
{
return AUTORELEASE([[NSUnitSpeed alloc] initWithSymbol: @"km/h"
coefficient: 0.277778
constant: 0.0]);
2019-10-08 04:44:38 +00:00
}
+ (NSUnitSpeed *) milesPerHour
{
return AUTORELEASE([[NSUnitSpeed alloc] initWithSymbol: @"mph"
coefficient: 0.44704
constant: 0.0]);
2019-10-08 04:44:38 +00:00
}
+ (NSUnitSpeed *) knots
{
return AUTORELEASE([[NSUnitSpeed alloc] initWithSymbol: @"kn"
coefficient: 0.51444
constant: 0.0]);
2019-10-08 04:44:38 +00:00
}
2019-10-04 02:29:00 +00:00
@end
2019-10-06 04:37:30 +00:00
@implementation NSUnitTemperature
+ (instancetype) baseUnit
{
return [self kelvin];
}
2019-10-06 04:37:30 +00:00
// Base unit - kelvin
2019-10-07 05:11:29 +00:00
+ (NSUnitTemperature *) kelvin
{
return AUTORELEASE([[NSUnitTemperature alloc] initWithSymbol: @"K"
coefficient: 1.0
constant: 0.0]);
2019-10-07 05:11:29 +00:00
}
2019-10-04 02:29:00 +00:00
2019-10-07 05:11:29 +00:00
+ (NSUnitTemperature *) celsius
{
return AUTORELEASE([[NSUnitTemperature alloc] initWithSymbol: @"C"
coefficient: 1.0
constant: 273.15]);
2019-10-07 05:11:29 +00:00
}
+ (NSUnitTemperature *) fahrenheit
{
return AUTORELEASE([[NSUnitTemperature alloc] initWithSymbol: @"F"
coefficient: 0.55555555555556
constant: 255.37222222222427]);
2019-10-07 05:11:29 +00:00
}
2019-10-04 02:29:00 +00:00
@end
@implementation NSUnitVolume
2019-10-08 06:07:20 +00:00
+ (instancetype) baseUnit
{
return [self liters];
}
2019-10-04 02:29:00 +00:00
2019-10-06 04:37:30 +00:00
// Base unit - liters
+ (NSUnitVolume *) megaliters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"ML"
coefficient: 1000000.0
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) kiloliters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"kL"
coefficient: 1000.0
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) liters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"L"
coefficient: 1.0
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) deciliters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"dL"
coefficient: 0.1
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) centiliters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"cL"
coefficient: 0.01
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) milliliters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"mL"
coefficient: 0.001
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicKilometers
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"km^3"
coefficient: 1e12
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicMeters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"m^3"
coefficient: 1000.0
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicDecimeters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"dm^3"
coefficient: 1.0
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicCentimeters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"cm^3"
coefficient: 0.0001
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicMillimeters
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"mm^3"
coefficient: 0.000001
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicInches
2019-10-08 06:07:20 +00:00
{
2021-01-18 11:52:37 +00:00
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"in^3"
coefficient: 0.0163871
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicFeet
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"ft^3"
coefficient: 28.3168
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicYards
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"yd^3"
coefficient: 764.555
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cubicMiles
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"mi^3"
coefficient: 4.168e+12
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) acreFeet
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"af"
coefficient: 1.233e+6
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) bushels
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"bsh"
coefficient: 32.2391
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) teaspoons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"tsp"
coefficient: 0.00492892
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) tablespoons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"tbsp"
coefficient: 0.0147868
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) fluidOunces
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"fl oz"
coefficient: 0.295735
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) cups
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"cups"
coefficient: 0.24
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) pints
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"pt"
coefficient: 0.473176
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) quarts
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"qt"
coefficient: 0.946353
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) gallons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"gal"
coefficient: 3.78541
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialTeaspoons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"tsp"
coefficient: 0.00591939
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialTablespoons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"tbsp"
coefficient: 0.0177582
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialFluidOunces
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"fl oz"
coefficient: 0.0284131
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialPints
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"pt"
coefficient: 0.568261
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialQuarts
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"qt"
coefficient: 1.13652
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) imperialGallons
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"gal"
coefficient: 4.54609
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
+ (NSUnitVolume *) metricCups
2019-10-08 06:07:20 +00:00
{
return AUTORELEASE([[NSUnitVolume alloc] initWithSymbol: @"metric cup"
coefficient: 0.25
constant: 0.0]);
2019-10-08 06:07:20 +00:00
}
2019-10-04 02:29:00 +00:00
@end