mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/calculation] New additional results on units
The additional results on units now include conversions into both unit systems (metric and imperial). Change-Id: Ie0f12eb3735e775560b66c2cbd78bc9a659145bb
This commit is contained in:
committed by
Émilie Feral
parent
3ff25fb5c1
commit
6c676782aa
@@ -883,6 +883,9 @@ public:
|
||||
static bool IsSIVolume(Expression & e);
|
||||
static bool IsSIEnergy(Expression & e);
|
||||
static bool IsSITime(Expression & e);
|
||||
static bool IsSIDistance(Expression & e);
|
||||
static bool IsSIMass(Expression & e);
|
||||
static bool IsSISurface(Expression & e);
|
||||
bool isMeter() const;
|
||||
bool isSecond() const;
|
||||
bool isKilogram() const;
|
||||
|
||||
@@ -515,6 +515,19 @@ bool Unit::IsSITime(Expression & e) {
|
||||
return e.type() == ExpressionNode::Type::Unit && static_cast<Unit &>(e).isSecond();
|
||||
}
|
||||
|
||||
bool Unit::IsSIDistance(Expression & e) {
|
||||
return e.type() == ExpressionNode::Type::Unit && static_cast<Unit &>(e).isMeter();
|
||||
}
|
||||
|
||||
bool Unit::IsSIMass(Expression & e) {
|
||||
return e.type() == ExpressionNode::Type::Unit && static_cast<Unit &>(e).isKilogram();
|
||||
}
|
||||
|
||||
bool Unit::IsSISurface(Expression & e) {
|
||||
return e.type() == ExpressionNode::Type::Power &&
|
||||
e.childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(0).convert<Unit>().isMeter() &&
|
||||
e.childAtIndex(1).type() == ExpressionNode::Type::Rational && e.childAtIndex(1).convert<const Rational>().isTwo();
|
||||
}
|
||||
|
||||
double Unit::ConvertedValueInUnit(Expression e, Unit unit, Context * context) {
|
||||
Expression conversion = UnitConvert::Builder(e.clone(), unit);
|
||||
|
||||
Reference in New Issue
Block a user