diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/RenderedScrollFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/RenderedScrollFact.cs index 26f2efd33a8f2b8f40da052497cd403ea1ffa7ae..36d7ef334aa0629f5c171c76e1783f545f574f12 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/RenderedScrollFact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactWrapper/RenderedScrollFact.cs @@ -24,6 +24,7 @@ public Scroll Scroll { _Scroll = value; SetLabel(null); + ResetPayload(); } } private Scroll _Scroll; diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs index d8e40c1e99b3337493152bca4a0bfe6971afadb2..c10ea05da6b2351d5b3ae302bb46fa72fe87c0f4 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/Fact.cs @@ -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; } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs index c53d2f7e7ad8b91b00e8c110aeabeb00ea39314c..07daa97d8a53570dd28ded29142a2ecfb9f30a43 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/MMTTypes.cs @@ -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); } diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs index 827aacce90faea860be75e06aece7c307c2b289d..5d613eace8ab82ddddb114bab9d25cdd166be697 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs @@ -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"; diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs index 192673b53e736d0b32456e39780c26bf1dc0d397..ae2b510da774a981f03851e50d1c44f12fb4690b 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs @@ -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