mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[calculation/additional_outputs] Use input rather than output if possible, and open on tan
This commit is contained in:
@@ -251,8 +251,11 @@ Calculation::AdditionalInformationType Calculation::additionalInformationType(Co
|
||||
* - > input: 2cos(2) - cos(2)
|
||||
* > output: cos(2)
|
||||
*/
|
||||
if (input().isDefinedCosineOrSine(context, complexFormat, preferences->angleUnit()) || o.isDefinedCosineOrSine(context, complexFormat, preferences->angleUnit())) {
|
||||
return AdditionalInformationType::Trigonometry;
|
||||
if (i.isDefinedCosineOrSineOrTangent(context, complexFormat, preferences->angleUnit())) {
|
||||
return AdditionalInformationType::TrigonometryInput;
|
||||
}
|
||||
if (o.isDefinedCosineOrSineOrTangent(context, complexFormat, preferences->angleUnit())) {
|
||||
return AdditionalInformationType::TrigonometryOutput;
|
||||
}
|
||||
if (o.hasUnit()) {
|
||||
Expression unit;
|
||||
|
||||
@@ -40,7 +40,8 @@ public:
|
||||
Integer,
|
||||
Rational,
|
||||
SecondDegree,
|
||||
Trigonometry,
|
||||
TrigonometryInput,
|
||||
TrigonometryOutput,
|
||||
Unit,
|
||||
Matrix,
|
||||
Complex
|
||||
|
||||
@@ -103,12 +103,12 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
vc = &m_complexController;
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::SecondDegree) {
|
||||
vc = &m_secondDegreeController;
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::Trigonometry) {
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::TrigonometryInput) {
|
||||
vc = &m_trigonometryController;
|
||||
// Find which of the input or output is the cosine/sine
|
||||
ExpressionNode::Type t = e.type();
|
||||
e = t == ExpressionNode::Type::Cosine || t == ExpressionNode::Type::Sine ? e : calculationAtIndex(focusRow)->input();
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::Integer) {
|
||||
e = calculationAtIndex(focusRow)->input();
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::TrigonometryOutput) {
|
||||
vc = &m_trigonometryController;
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::Integer) {
|
||||
vc = &m_integerController;
|
||||
} else if (additionalInfoType == Calculation::AdditionalInformationType::Rational) {
|
||||
vc = &m_rationalController;
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
bool isRationalOne() const;
|
||||
bool isRandom() const { return node()->isRandom(); }
|
||||
bool isParameteredExpression() const { return node()->isParameteredExpression(); }
|
||||
bool isDefinedCosineOrSine(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
bool isDefinedCosineOrSineOrTangent(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
bool isBasedIntegerCappedBy(const char * integerString) const;
|
||||
bool isDivisionOfIntegers() const;
|
||||
bool hasDefinedComplexApproximation(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
@@ -260,9 +260,9 @@ bool Expression::getLinearCoefficients(char * variables, int maxVariableSize, Ex
|
||||
return !isMultivariablePolynomial;
|
||||
}
|
||||
|
||||
bool Expression::isDefinedCosineOrSine(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
|
||||
bool Expression::isDefinedCosineOrSineOrTangent(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
|
||||
ExpressionNode::Type t = type();
|
||||
if (t == ExpressionNode::Type::Cosine || t == ExpressionNode::Type::Sine) {
|
||||
if (t == ExpressionNode::Type::Cosine || t == ExpressionNode::Type::Sine || t == ExpressionNode::Type::Tangent) {
|
||||
float r = childAtIndex(0).approximateToScalar<float>(context, complexFormat, angleUnit);
|
||||
if (!std::isnan(r)) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user