Skip to content
Snippets Groups Projects
Commit 2bc371c3 authored by MaZiFAU's avatar MaZiFAU
Browse files

BugFix; SOMDocToLambdaExpression;

BugFix:
+ R inputs updates now with scroll
+ R values have proper label

SOMDocToLambdaExpression:
+ more constants
+ manual angle_between (TODO: autamatic per AST)
parent c24478a3
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ public Scroll Scroll
{
_Scroll = value;
SetLabel(null);
ResetPayload();
}
}
private Scroll _Scroll;
......
......@@ -675,7 +675,7 @@ public static List<Fact> MMTFactory(MMTFact ingredient)
//}
//catch (NotSupportedException) { }
MakeFact(ret, CompiledValue, indirect_payload, true, ingredient.@ref);
MakeFact(ret, CompiledValue, indirect_payload, false, ingredient.@ref); //true => server does not recognize fact
return ret;
}
......
......@@ -628,6 +628,10 @@ protected override string[] GetDependentFactIds()
protected override void RecalculateTransform() { }
/// \copydoc Fact.generateLabel
protected override string generateLabel(FactRecorder name_space)
=> $"R{value}";
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new)
=> new RealLitFact(value);
}
......
......@@ -83,6 +83,7 @@ public static class MMTConstants
public static readonly string MinusRealLit = "http://mathhub.info/MitM/Foundation?RealLiterals?minus_real_lit";
public static readonly string InvertRealLit = "http://mathhub.info/MitM/Foundation?RealLiterals?inv_real_lit";
public static readonly string TimesRealLit = "http://mathhub.info/MitM/Foundation?RealLiterals?times_real_lit";
public static readonly string RealMultiplication = "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication";
public static readonly string LEQRealLit = "http://mathhub.info/MitM/Foundation?RealLiterals?leq_real_lit";
public static readonly string IfThenElse = "http://mathhub.info/FrameIT/frameworld?IfThenElseX?ifthenelsex";
......@@ -102,8 +103,8 @@ public static class MMTConstants
public static readonly string ToArray = "?ToArray";
public static readonly string Invoke = "?lambda";
public static readonly string Sin = "Sin";
public static readonly string Cos = "Cos";
public static readonly string Sin = "http://mathhub.info/MitM/Foundation?Trigonometry?sin";
public static readonly string Cos = "http://mathhub.info/MitM/Foundation?Trigonometry?cos";
public static readonly string Divide = "Divide";
public static readonly string SquareRoot = "http://mathhub.info/MitM/Foundation?RealLiterals?sqrt";
public static readonly string LessThan = "LessThan";
......
......@@ -113,6 +113,8 @@ protected static class SOMDocToLambdaExpression
MakeTupel },
{ MMTConstants.Product, // TODO:Automate
MakeTupel },
{ MMTConstants.Angle, // TODO: get AST from server?
CalculateAngle },
{ MMTConstants.MakeObjectArray,
MakeObjArray },
{ MMTConstants.ListApplicant,
......@@ -227,6 +229,8 @@ protected static class SOMDocToLambdaExpression
ExpressionType.Multiply},
{ MMTConstants.VecMultI,
ExpressionType.Multiply},
{ MMTConstants.RealMultiplication,
ExpressionType.Multiply},
{ "MultiplyAssign",
ExpressionType.MultiplyAssign},
{ "MultiplyAssignChecked",
......@@ -345,15 +349,10 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected)
{
return lamda_maker(lambda_applicant, lambda_arguments, found_bound_params);
}
else
if (MMTConstants.OMS_TO_TYPE.TryGetValue(URI, out Type type))
{
return Expression.Lambda(Expression.Default(type), null);
}
else // Last entree to avoid stack-overflow:
if (FactRecorder.AllFacts.TryGetValue(URI, out Fact fact))
{
type = fact.CompiledValue.GetType();
Type type = fact.CompiledValue.GetType();
Expression lambda_orig =
Expression.Constant(fact.CompiledValue, type);
......@@ -376,6 +375,11 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected)
else
return _PartialInvoke(lambda_orig, lambda_applicant, found_bound_params);
}
else
if (MMTConstants.OMS_TO_TYPE.TryGetValue(URI, out Type type))
{
return Expression.Lambda(Expression.Default(type), null);
}
throw new NotImplementedException("Could not map URI: \"" + URI + "\"");
}
......@@ -534,6 +538,16 @@ public static LambdaExpression ProjRVecTupel(LambdaExpression[] lambda_applicant
: MakeTupel(Items_applicant, lambda_arguments, bound_params);
}
public static LambdaExpression CalculateAngle(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params)
=> MakeTupel(new[] {
ExpresionFuncToLambda(
(Expression<Func<Vector3, Vector3, Vector3, float>>)((Vector3 a, Vector3 b, Vector3 c)
=> Mathf.Acos(Vector3.Dot((b - a).normalized, (b - c).normalized))),
"angle_between", lambda_applicant, bound_params
)},
null, bound_params
);
public static LambdaExpression MakeTupel(LambdaExpression[] lambda_applicant, LambdaExpression[] lambda_arguments, ParameterExpression[] bound_params)
{
if (lambda_applicant.Length == 3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment