From 38f115d91eed2513194b053fa9bb4a94f7d90129 Mon Sep 17 00:00:00 2001
From: Paul-Walcher <paulwalcher12@gmail.com>
Date: Sat, 4 May 2024 12:51:48 +0200
Subject: [PATCH] Fixed Circle Fact

---
 .../FactHandling/Facts/CircleFact.cs          | 43 ++++++++++++++++---
 .../CommunicationProtocoll/MMTConstants.cs    |  3 +-
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/Assets/Scripts/InteractionEngine/FactHandling/Facts/CircleFact.cs b/Assets/Scripts/InteractionEngine/FactHandling/Facts/CircleFact.cs
index 902763cf..78893f65 100644
--- a/Assets/Scripts/InteractionEngine/FactHandling/Facts/CircleFact.cs
+++ b/Assets/Scripts/InteractionEngine/FactHandling/Facts/CircleFact.cs
@@ -3,6 +3,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using UnityEditor.Callbacks;
 using UnityEngine;
 
 /// <summary>
@@ -100,7 +101,25 @@ public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, SOMDoc
         if (planeApplicant.Equals(MMTConstants.pointNormalPlane))
         {
             //OMA pointAOMA = (OMA)planeOMA.arguments[0];
-            normal = SOMDoc.MakeVector3((OMA)planeOMA.arguments[1]);
+            //normal = SOMDoc.MakeVector3((OMA)planeOMA.arguments[1]);
+
+            string planeOMAuri1, planeOMAuri2, planeOMAuri3;
+            planeOMAuri1 = planeOMA.arguments[0].ToString();
+            planeOMAuri2 = planeOMA.arguments[1].ToString();
+            planeOMAuri3 = planeOMA.arguments[2].ToString();
+
+            PointFact planeOMApf1, planeOMApf2, planeOMApf3;
+
+            planeOMApf1 = (PointFact)FactRecorder.AllFacts[planeOMAuri1];
+            planeOMApf2 = (PointFact)FactRecorder.AllFacts[planeOMAuri2];
+            planeOMApf3 = (PointFact)FactRecorder.AllFacts[planeOMAuri3];
+
+            Vector3 p1 = planeOMApf1.Point, p2 = planeOMApf2.Point, p3 = planeOMApf3.Point;
+
+            Vector3 v1 = p2 - p1, v2 = p3 - p1;
+            normal = Vector3.Cross(v1, v2);
+
+
         }
         // In case of parametrized plane
         else if (planeApplicant.Equals(MMTConstants.ParametrizedPlane))
@@ -114,10 +133,24 @@ public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, SOMDoc
         else throw new ArgumentException("Invalid planeApplicant: " + planeApplicant);
 
         // get the mid point uri
-        string parse_id_M = df.arguments[1].ToString();
-        string M_uri = ParsingDictionary.parseTermsToId[parse_id_M];
-        string A_uri = ParsingDictionary.parseTermsToId[planeOMA.arguments[0].ToString()];
-        float radius = ((OMLIT<float>)df.arguments[2]).value;
+        string M_uri = df.arguments[1].ToString();
+        string A_uri = planeOMA.arguments[0].ToString();
+        //float radius = ((OMLIT<float>)df.arguments[2]).value;
+
+        float radius = 0.0F;
+
+        OMA commonOMA = (OMA)df.arguments[2];
+
+        string uri1, uri2;
+        uri1 = commonOMA.arguments[0].ToString();
+        uri2 = commonOMA.arguments[1].ToString();
+
+        PointFact pf1, pf2;
+
+        pf1 = (PointFact)FactRecorder.AllFacts[uri1];
+        pf2 = (PointFact)FactRecorder.AllFacts[uri2];
+
+        radius = Vector3.Distance(pf1.Point, pf2.Point);
 
         if (!FactRecorder.AllFacts.ContainsKey(M_uri)
          || !FactRecorder.AllFacts.ContainsKey(A_uri))
diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs
index 8d3934ac..8c4ff7d4 100644
--- a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs
+++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs
@@ -49,7 +49,7 @@ public static class MMTConstants
         public static readonly string ConeOfCircleApex = "http://mathhub.info/FrameIT/frameworld?FrameITCone?circleConeOf";
 
         public static readonly string ParametrizedPlane = "http://mathhub.info/MitM/core/geometry?Planes?ParametrizedPlane";
-        public static readonly string pointNormalPlane = "http://mathhub.info/MitM/core/geometry?Planes?pointNormalPlane";
+        public static readonly string pointNormalPlane = "http://mathhub.info/FrameIT/frameworld?FrameITCircle?pointsToPlaneNormal";
         public static readonly string OnCircle = "http://mathhub.info/FrameIT/frameworld?FrameITCircle?pointOnCircle";
         public static readonly string AnglePlaneLine = "http://mathhub.info/FrameIT/frameworld?FrameITCircle?angleCircleLine";
         public static readonly string OrthoCircleLine = "http://mathhub.info/FrameIT/frameworld?FrameITCircle?orthogonalCircleLine";
@@ -123,6 +123,7 @@ public static class MMTConstants
         public const string ScrollCylinderVolumeScroll = "http://mathhub.info/FrameIT/frameworld?CylinderVolumeScroll";
         public const string ScrollCircleLineAngleToAngleScroll = "http://mathhub.info/FrameIT/frameworld?CircleLineAngleToAngleScroll";
         public const string ScrollMidpoint = "http://mathhub.info/FrameIT/frameworld?Midpoint";
+        public const string ScrollMidpoint2 = "http://mathhub.info/FrameIT/frameworld?Midpoint";
         public const string ScrollTest = "http://mathhub.info/FrameIT/frameworld?Test";
         public const string ScrollCircleScroll = "http://mathhub.info/FrameIT/frameworld?CircleScroll";
         public const string ScrollCircleLineAngleScroll = "http://mathhub.info/FrameIT/frameworld?CircleLineAngleScroll";
-- 
GitLab