Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pound-force inch torque conversion #40

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/properties/torque.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ enum TORQUE {
newtonMeter,
dyneMeter,
poundForceFeet,
poundForceInch,
kilogramForceMeter,
poundalMeter,
}

class Torque extends DoubleProperty<TORQUE> {
///Class for torque conversions, e.g. if you want to convert 1 square meters in acres:
///Class for torque conversions, e.g. if you want to convert 1 newton meter in pound-force feet:
///```dart
///var torque = Torque(removeTrailingZeros: false);
///torque.convert(Unit(TORQUE.square_meters, value: 1));
///print(TORQUE.acres);
///torque.convert(Unit(TORQUE.newtonMeter, value: 1));
///print(TORQUE.poundForceFeet);
/// ```
Torque(
{super.significantFigures,
Expand All @@ -30,6 +31,7 @@ class Torque extends DoubleProperty<TORQUE> {
TORQUE.newtonMeter: 'N·m',
TORQUE.dyneMeter: 'dyn·m',
TORQUE.poundForceFeet: 'lbf·ft',
TORQUE.poundForceInch: 'lbf·in',
TORQUE.kilogramForceMeter: 'kgf·m',
TORQUE.poundalMeter: 'pdl·m',
},
Expand All @@ -42,6 +44,10 @@ class Torque extends DoubleProperty<TORQUE> {
coefficientProduct: 1.35581794902490555,
name: TORQUE.poundForceFeet,
),
ConversionNode(
coefficientProduct: 0.1129848290854088,
name: TORQUE.poundForceInch,
),
Comment on lines +47 to +50
Copy link
Owner

@ferraridamiano ferraridamiano Oct 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to implement it as 1/12 of pound force feet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest I am not familiar with the laguage, do you have a suggestion on how to reference the value or should I just write 1.35581794902490555/12

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the ConversionNode as a List to the leafNode property of the pound force feet conversionNode

ConversionNode(
coefficientProduct: 9.807,
name: TORQUE.kilogramForceMeter,
Expand All @@ -56,6 +62,7 @@ class Torque extends DoubleProperty<TORQUE> {
Unit get newtonMeter => getUnit(TORQUE.newtonMeter);
Unit get dyneMeter => getUnit(TORQUE.dyneMeter);
Unit get poundForceFeet => getUnit(TORQUE.poundForceFeet);
Unit get poundForceInch => getUnit(TORQUE.poundForceInch);
Unit get kilogramForceMeter => getUnit(TORQUE.kilogramForceMeter);
Unit get poundalMeter => getUnit(TORQUE.poundalMeter);
}
1 change: 1 addition & 0 deletions test/conversion_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ void main() {
TORQUE.newtonMeter: 1,
TORQUE.dyneMeter: 1e5,
TORQUE.poundForceFeet: 0.7375621489,
TORQUE.poundForceInch: 8.8507457868,
TORQUE.kilogramForceMeter: 0.10196798205364,
TORQUE.poundalMeter: 7.2330138512099,
};
Expand Down
4 changes: 3 additions & 1 deletion test/getters_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ void main() {
runGetterTest(property.newtonMeter, property.getUnit(TORQUE.newtonMeter));
runGetterTest(property.dyneMeter, property.getUnit(TORQUE.dyneMeter));
runGetterTest(
property.poundForceFeet, property.getUnit(TORQUE.poundForceFeet));
property.poundForceFeet, property.getUnit(TORQUE.poundForceFeet));
runGetterTest(
property.poundForceInch, property.getUnit(TORQUE.poundForceInch));
runGetterTest(property.kilogramForceMeter,
property.getUnit(TORQUE.kilogramForceMeter));
runGetterTest(property.poundalMeter, property.getUnit(TORQUE.poundalMeter));
Expand Down
Loading