Newer
Older
using System;
using System.Collections.Generic;
using static CommunicationEvents;
Marco Zimmer
committed
using JsonSubTypes;
Marco Zimmer
committed
public class ParsingDictionary {
//TODO? get rid of this, use reflection? instead, if possible
//TODO: docu
//public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new Dictionary<string, Func<Scroll.ScrollFact, Fact>>() {
public static Dictionary<string, Func<Scroll.ScrollFact, Fact>> parseFactDictionary = new() {
{JSONManager.MMTURIs.Point, PointFact.parseFact},
{JSONManager.MMTURIs.Metric, LineFact.parseFact},
{JSONManager.MMTURIs.Angle, AngleFact.parseFact},
{JSONManager.MMTURIs.LineType, RayFact.parseFact},
{JSONManager.MMTURIs.LineOf, RayFact.parseFact},
{JSONManager.MMTURIs.OnLine, OnLineFact.parseFact},
{JSONManager.MMTURIs.ParallelLine, ParallelLineFact.parseFact},
{JSONManager.MMTURIs.CircleType3d, CircleFact.parseFact},
{JSONManager.MMTURIs.OnCircle, OnCircleFact.parseFact },
{JSONManager.MMTURIs.AnglePlaneLine, AngleCircleLineFact.parseFact },
{JSONManager.MMTURIs.RadiusCircleMetric, RadiusFact.parseFact },
{JSONManager.MMTURIs.AreaCircle, AreaCircleFact.parseFact },
{JSONManager.MMTURIs.OrthoCircleLine, OrthogonalCircleLineFact.parseFact },
{JSONManager.MMTURIs.VolumeCone ,ConeVolumeFact.parseFact },
{JSONManager.MMTURIs.TruncatedVolumeCone ,TruncatedConeVolumeFact.parseFact },
{JSONManager.MMTURIs.RightAngle, RightAngleFact.parseFact },
{JSONManager.MMTURIs.CylinderVolume, CylinderVolumeFact.parseFact },
{JSONManager.MMTURIs.TestType, TestFact.parseFact },
{JSONManager.MMTURIs.EqualityCircles, EqualCirclesFact.parseFact },
{JSONManager.MMTURIs.UnEqualityCircles, UnEqualCirclesFact.parseFact }
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/// Current solution to retrieve the fact ID from
public static string MMTermToString (MMTTerm term){
if(term == null)
return null;
// case for OMA
if( term is OMA){
OMA term_casted = (OMA) term;
string applicant = ((OMS)term_casted.applicant).uri;
string argument = "";
for (int i = 0; i < term_casted.arguments.Count; i++) {
argument = argument+ " " + MMTermToString(term_casted.arguments[i]);
}
return " " + applicant + " "+ argument;
}
// case for OMS
if (term is OMS)
{
OMS term_casted = (OMS)term;
return term_casted.uri;
}
// case for OMF
if (term is OMF) {
OMF term_casted = (OMF)term;
return term_casted.f.ToString();
}
return "couldn't understand the type";
}
public static Dictionary<string, string> parseTermsToId = new Dictionary<string, string>();
/// <summary>
/// class to Read AddFact Responses.
/// </summary>
// TODO: docu
public class AddFactResponse
{
public string uri;
Marco Zimmer
committed
public static bool sendAdd(MMTDeclaration mmtDecl, out string uri)
{
string body = MMTSymbolDeclaration.ToJson(mmtDecl);
return sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body, out uri);
}
public static bool sendAdd(string path, string body, out string uri)
{
if (!CommunicationEvents.ServerRunning)
{
Debug.LogWarning("Server not running");
Marco Zimmer
committed
uri = null;
return false;
Marco Zimmer
committed
if(VerboseURI)
Debug.Log("Sending to Server:\n" + body);
//Put constructor parses stringbody to byteArray internally (goofy workaround)
Marco Zimmer
committed
using UnityWebRequest www = UnityWebRequest.Put(path, body);
www.method = UnityWebRequest.kHttpVerbPOST;
www.SetRequestHeader("Content-Type", "application/json");
www.timeout = 1;
//TODO: implement real asynchronous communication ...
AsyncOperation op = www.SendWebRequest();
while (!op.isDone) ;
if (www.result == UnityWebRequest.Result.ConnectionError
|| www.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogWarning(www.error);
Marco Zimmer
committed
uri = null;
return false;
}
else
{
string answer = www.downloadHandler.text;
Marco Zimmer
committed
AddFactResponse res = JsonUtility.FromJson<AddFactResponse>(answer);
if (VerboseURI)
Debug.Log("Server added Fact:\n" + res.uri);
uri = res.uri;
return true;
}
}
}
/// <summary>
/// %Fact representation of Unity; mostly mirrors Facts of MMT.
/// </summary>
Marco Zimmer
committed
[JsonConverter(typeof(JsonSubtypes), "s_type")]
[JsonSubtypes.KnownSubType(typeof(PointFact), "PointFact")]
[JsonSubtypes.KnownSubType(typeof(LineFact), "LineFact")]
[JsonSubtypes.KnownSubType(typeof(RayFact), "RayFact")]
[JsonSubtypes.KnownSubType(typeof(OnLineFact), "OnLineFact")]
[JsonSubtypes.KnownSubType(typeof(AngleFact), "AngleFact")]
[JsonSubtypes.KnownSubType(typeof(CircleFact), "CircleFact")]
[JsonSubtypes.KnownSubType(typeof(ParallelLineFact), "ParallelLine")]
[JsonSubtypes.KnownSubType(typeof(OnCircleFact), "OnCircleFact")]
[JsonSubtypes.KnownSubType(typeof(AngleCircleLineFact), "AnglePlaneLineFact")]
[JsonSubtypes.KnownSubType(typeof(AreaCircleFact), "AreaCircle")]
[JsonSubtypes.KnownSubType(typeof(RadiusFact), "RadiusCircleMetric")]
[JsonSubtypes.KnownSubType(typeof(OrthogonalCircleLineFact), "OrthogonalCircleLineFact")]
[JsonSubtypes.KnownSubType(typeof(ConeVolumeFact), "ConeVolumeFact")]
[JsonSubtypes.KnownSubType(typeof(TruncatedConeVolumeFact), "TruncatedConeVolumeFact")]
[JsonSubtypes.KnownSubType(typeof(RightAngleFact), "RightAngleFact")]
[JsonSubtypes.KnownSubType(typeof(CylinderVolumeFact), "CylinderVolumeFact")]
[JsonSubtypes.KnownSubType(typeof(TestFact), "TestFact")]
[JsonSubtypes.KnownSubType(typeof(EqualCirclesFact), "EqualCirclesFact")]
[JsonSubtypes.KnownSubType(typeof(UnEqualCirclesFact), "UnEqualCirclesFact")]
/// <summary>
/// Reference to <c>GameObject</c> that represents this Fact in the GameWorld.
/// </summary>
/// <seealso cref="FactObject"/>
public GameObject Representation;
Marco Zimmer
committed
/// <value>
/// [ClassName] for JSON de-/serialization.
/// Set in every non-abstract subclass of Fact.
/// Also add JsonSubtypes.KnownSubType decorator for deserialization to Fact!
Marco Zimmer
committed
/// </value>
Marco Zimmer
committed
protected static /*new*/ string s_type = "ERROR: set s_type in T:Fact"; // In the subtype! NOT here!
Marco Zimmer
committed
/// <value>
/// Unique Id. e.g.: MMT URI
/// </value>
public string Id {
get { return _URI; }
set { if (_URI == null) _URI = value; } // needed for JSON
/// <summary>
/// MMT URI
/// </summary>
Marco Zimmer
committed
/// <value>
/// <c>get</c> initiates and subsequently updates a human readable name. <remarks>Should be called once a constructor call to be initiated.</remarks>
/// <c>set</c> calls <see cref="rename(string)"/>
/// </value>
Marco Zimmer
committed
public string Label {
get { // in case of renamed dependables
return (_Facts.GetNumberOfFacts() == 0 && this is not PointFact) // JsonSerialization toggle && allow first (Point)Fact to be created
Marco Zimmer
committed
|| (hasCustomLabel && _CustomLabel != null)
? _CustomLabel
: generateLabel();
Marco Zimmer
committed
}
set { rename(value); }
}
/// <value>
/// Is true if Fact has a custom <see cref="Label"/> which is not <c>null</c> or <c>""</c>.
/// </value>
public bool hasCustomLabel {
get { return LabelId < 0; }
Marco Zimmer
committed
}
/// <summary>
/// Stores custom <see cref="Label"/> if set.
/// </summary>
Marco Zimmer
committed
protected string _CustomLabel = null;
/// <summary>
/// Counter to organize auto generated <see cref="Label"/>.
/// Set to negative, if custom \ref Label is assigned.
/// </summary>
// property for JSON to set AFTER Label => declare AFTER Label
public int LabelId { get; set; }
/// <summary>
/// Reference to <see cref="FactOrganizer"/> in which this Fact and all its <see cref="getDependentFactIds">depending Facts</see> are beeing organized.
/// </summary>
protected FactOrganizer _Facts;
/// <summary>
/// Only being used by [JsonReader](https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonReader.htm) to initiate empty \ref Fact "Facts".
/// <seealso cref="JSONManager"/>
/// </summary>
protected Fact()
{
this._Facts = new FactOrganizer();
/// <summary>
/// Standard base-constructor.
/// </summary>
/// <param name="organizer"><see cref="_Facts"/></param>
protected Fact(FactOrganizer organizer)
{
this._Facts = organizer;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="organizer"><see cref="_Facts"/></param>
protected Fact(Fact fact, FactOrganizer organizer)
this._Facts = organizer;
if (hasCustomLabel)
_CustomLabel = fact.Label;
}
/// <summary>
/// Assignes a custom <see cref="Label"/>, if <paramref name="newLabel"/> is not yet taken;
/// or clears custom <see cref="Label"/>.
/// </summary>
/// <param name="newLabel">To be new <see cref="Label"/>. To reset to auto-generation set to <c>null</c> or <c>""</c>.</param>
/// <returns></returns>
//TODO: notify about updated dependable Labelnames for UI
//TODO: check for colissions with not yet generated names
public bool rename(string newLabel)
// returns true if succeded
{
if (string.IsNullOrEmpty(newLabel))
// switch back to autogenerated
{
generateLabel();
_CustomLabel = null;
return true;
}
else
// set CustomLabel if available
{
if (_Facts.ContainsLabel(newLabel))
return false;
freeAutoLabel();
_CustomLabel = newLabel;
Marco Zimmer
committed
/// <returns><see langword="true"/> if Fact depends on other \ref Fact "Facts"; equivalent to <see cref="getDependentFactIds"/> returns non empty array</returns>
Marco Zimmer
committed
public abstract bool hasDependentFacts();
/// <returns> array of Fact <see cref="Id"> Ids </see> on which this Fact depends.</returns>
/// <example><see cref="AngleFact"/> needs 3 <see cref="PointFact"/>s to be defined.</example>
public abstract string[] getDependentFactIds();
/// <summary>
/// Initiates a <paramref name="prefab"/> at <paramref name="transform"/> e.g. by setting <see cref="Label"/>.
/// </summary>
/// <remarks>Does not set <see cref="Representation"/>.</remarks>
/// <param name="prefab"><c>GameObject</c> Prefab that will represent this Fact</param>
/// <param name="transform"><c>Transform</c> where to initiate <paramref name="prefab"/></param>
/// <returns></returns>
// TODO: set Representation here instead of ...
public abstract GameObject instantiateDisplay(GameObject prefab, Transform transform);
/// <summary>
/// Frees ressources e.g. <see cref="Label"/> and will eventually delete %Fact Server-Side in far-near future when feature is supported.
/// </summary>
/// <param name="keep_clean">when set to <c>true</c> will upkeep <see cref="Label"/> organization.</param>
// TODO? replace by ~Fact() { }
Marco Zimmer
committed
public virtual void delete(bool keep_clean = true)
Marco Zimmer
committed
if (keep_clean)
Marco Zimmer
committed
Marco Zimmer
committed
if (VerboseURI)
Marco Zimmer
committed
Debug.Log("Server removed Fact:\n" + this.Id);
/// <summary>
/// Compares \ref Fact "this" against <paramref name="f2"/>.
/// </summary>
/// <param name="f2">Fact to compare to</param>
/// <returns><c>true</c> if <paramref name="f2"/> is semantical very similar to \ref Fact "this"</returns>
Marco Zimmer
committed
public abstract bool Equivalent(Fact f2);
/// <summary>
/// Compares <paramref name="f1"/> against <paramref name="f2"/>.
/// </summary>
/// <param name="f1">Fact to compare to</param>
/// <param name="f2">Fact to compare to</param>
/// <returns><c>true</c> if <paramref name="f2"/> is semantical very similar to <paramref name="f1"/></returns>
Marco Zimmer
committed
public abstract bool Equivalent(Fact f1, Fact f2);
/// <summary>
/// canonical
/// </summary>
/// <returns>unique-ish Hash</returns>
public abstract override int GetHashCode();
/// <summary>
/// auto-generates <see cref="Label"/> using generation variable(s) e.g. <see cref="LabelId"/>;
/// if custom <see cref="Label"/> is set, tries to restore original generated <see cref="Label"/> **without** resetting <see cref="_CustomLabel"/>. If original <see cref="Label"/> is already taken, a new one will be generated.
/// </summary>
/// <returns>auto-generated <see cref="Label"/></returns>
Marco Zimmer
committed
protected virtual string generateLabel()
{
if (LabelId < 0)
// reload Label if possible
LabelId = _Facts.UnusedLabelIds.Remove(-LabelId) ? -LabelId : 0;
Marco Zimmer
committed
if (LabelId == 0)
if (_Facts.UnusedLabelIds.Count == 0)
LabelId = ++_Facts.MaxLabelId;
Marco Zimmer
committed
else
{
LabelId = _Facts.UnusedLabelIds.Min;
_Facts.UnusedLabelIds.Remove(LabelId);
Marco Zimmer
committed
}
return ((char)(64 + LabelId)).ToString();
}
/// <summary>
/// Parses <see cref="Scroll.ScrollFact"/> to actual Fact
/// </summary>
/// <param name="fact">instance to be parsed</param>
/// <returns>parsed Fact</returns>
public static Fact parseFact(Scroll.ScrollFact fact)
{
return null;
}
/// <summary>
/// Tells <see cref="_Facts"/> that \ref Fact "this" no longer uses auto-generated <see cref="Label"/>, but remembers current generation variable(s).
/// </summary>
// TODO? only get _Fact to freeLabel/
public /*protected internal*/ void freeAutoLabel()
{
if (LabelId > 0)
_Facts.UnusedLabelIds.Add(LabelId);
// store Label for name-persistance
Marco Zimmer
committed
LabelId = -LabelId;
}
/// <summary>
/// Implements CRTP for <see cref="Fact"/>; Escalates constructors;
/// </summary>
/// <typeparam name="T">class, which inherits from FactWrappedCRTP</typeparam>
Marco Zimmer
committed
public abstract class FactWrappedCRTP<T>: Fact where T: FactWrappedCRTP<T>
/// <summary>\copydoc Fact.Fact()</summary>
protected FactWrappedCRTP() : base() { }
/// <summary>\copydoc Fact.Fact(FactOrganizer)</summary>
protected FactWrappedCRTP(FactOrganizer organizer) : base(organizer) { }
/// <summary>\copydoc Fact.Fact(Fact, FactOrganizer)</summary>
protected FactWrappedCRTP(FactWrappedCRTP<T> fact, FactOrganizer organizer) : base(fact, organizer) { }
/// \copydoc Fact.Equivalent(Fact)
Marco Zimmer
committed
public override bool Equivalent(Fact f2)
{
return Equivalent(this, f2);
}
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
public override bool Equivalent(Fact f1, Fact f2)
{
return f1.GetType() == f2.GetType() && EquivalentWrapped((T)f1, (T)f2);
Marco Zimmer
committed
}
/// <summary>CRTP step of <see cref="Equivalent(Fact)"/> and <see cref="Equivalent(Fact, Fact)"/></summary>
Marco Zimmer
committed
protected abstract bool EquivalentWrapped(T f1, T f2);
}
/// <summary>
/// Base-class for 1D-Facts
/// </summary>
Marco Zimmer
committed
public abstract class AbstractLineFact: FactWrappedCRTP<AbstractLineFact>
{
/// @{ <summary>
/// One <see cref="Fact.Id">Id</see> of two <see cref="PointFact"/> defining <see cref="Dir"/>.
/// </summary>
/// @}
Marco Zimmer
committed
/// <summary>
/// Normalized Direction from <see cref="Pid1"/> to <see cref="Pid2"/>.
/// </summary>
public Vector3 Dir;
Marco Zimmer
committed
/// <summary>
/// \copydoc Fact.Fact()
/// </summary>
protected AbstractLineFact() : base()
{
Pid1 = null;
Pid2 = null;
Dir = Vector3.zero;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
protected AbstractLineFact(AbstractLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
set_public_members(old_to_new[fact.Pid1], old_to_new[fact.Pid2]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="AbstractLineFact.Pid1"/></param>
/// <param name="pid2">sets <see cref="AbstractLineFact.Pid2"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
protected AbstractLineFact(string pid1, string pid2, FactOrganizer organizer): base(organizer)
{
set_public_members(pid1, pid2);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
protected AbstractLineFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(organizer)
{
set_public_members(pid1, pid2);
this._URI = backendURI;
}
Marco Zimmer
committed
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Dir"/>
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
private void set_public_members(string pid1, string pid2)
Marco Zimmer
committed
{
this.Pid1 = pid1;
this.Pid2 = pid2;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
Marco Zimmer
committed
this.Dir = (pf2.Point - pf1.Point).normalized;
}
/// \copydoc Fact.hasDependentFacts
Marco Zimmer
committed
public override bool hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
Marco Zimmer
committed
{
Marco Zimmer
committed
}
/// \copydoc Fact.GetHashCode
Marco Zimmer
committed
public override int GetHashCode()
{
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode();
Marco Zimmer
committed
}
}
/// <summary>
/// Implements CRTP for <see cref="AbstractLineFact"/>; Escalates constructors;
/// </summary>
/// <typeparam name="T">class, which inherits from AbstractLineFactWrappedCRTP</typeparam>
Marco Zimmer
committed
public abstract class AbstractLineFactWrappedCRTP<T>: AbstractLineFact where T: AbstractLineFactWrappedCRTP<T>
{
/// <summary>\copydoc Fact.Fact</summary>
protected AbstractLineFactWrappedCRTP () : base() { }
Marco Zimmer
committed
/// <summary>\copydoc AbstractLineFact.AbstractLineFact(AbstractLineFact, Dictionary{string, string}, FactOrganizer)</summary>
protected AbstractLineFactWrappedCRTP (AbstractLineFactWrappedCRTP<T> fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, old_to_new, organizer) { }
/// <summary>\copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer)</summary>
protected AbstractLineFactWrappedCRTP (string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer) { }
/// <summary>\copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer)</summary>
protected AbstractLineFactWrappedCRTP (string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer) { }
Marco Zimmer
committed
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(AbstractLineFact f1, AbstractLineFact f2)
{
return EquivalentWrapped((T)f1, (T)f2);
}
/// <summary>CRTP step of <see cref="EquivalentWrapped(AbstractLineFact, AbstractLineFact)"/></summary>
Marco Zimmer
committed
protected abstract bool EquivalentWrapped(T f1, T f2);
/// <summary>
/// Point in 3D Space
/// </summary>
Marco Zimmer
committed
public class PointFact : FactWrappedCRTP<PointFact>
Marco Zimmer
committed
/// \copydoc Fact.s_type
Marco Zimmer
committed
protected static new string s_type = "PointFact";
Marco Zimmer
committed
/// <summary> Position </summary>
/// <summary> Orientation for <see cref="Fact.Representation"/> </summary>
public Vector3 Normal;
/// <summary> \copydoc Fact.Fact </summary>
public PointFact() : base()
{
this.Point = Vector3.zero;
this.Normal = Vector3.zero;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public PointFact(PointFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(fact.Point, fact.Normal);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="P">sets <see cref="Point"/></param>
/// <param name="N">sets <see cref="Normal"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public PointFact(Vector3 P, Vector3 N, FactOrganizer organizer) : base(organizer)
{
init(P, N);
}
/// <summary>
/// Initiates <see cref="Point"/>, <see cref="Normal"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="P">sets <see cref="Point"/></param>
/// <param name="N">sets <see cref="Normal"/></param>
private void init(Vector3 P, Vector3 N)
this.Point = P;
this.Normal = N;
new OMF(P.x),
new OMF(P.y),
new OMF(P.z)
//OMS constructor generates full URI
MMTTerm tp = new OMS(JSONManager.MMTURIs.Point);
MMTTerm df = new OMA(new OMS(JSONManager.MMTURIs.Tuple), arguments);
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
Marco Zimmer
committed
AddFactResponse.sendAdd(mmtDecl, out this._URI);
string parse_id = ParsingDictionary.MMTermToString(df);
ParsingDictionary.parseTermsToId[parse_id] = this._URI;
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// <see cref="Normal"/> set to <c>Vector3.up</c>
/// </summary>
/// <param name="a">sets <c>x</c> coordinate of <see cref="Point"/></param>
/// <param name="b">sets <c>y</c> coordinate of <see cref="Point"/></param>
/// <param name="c">sets <c>z</c> coordinate of <see cref="Point"/></param>
/// <param name="uri">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public PointFact(float a, float b, float c, string uri, FactOrganizer organizer) : base(organizer)
this.Normal = Vector3.up;
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static PointFact parseFact(Scroll.ScrollFact fact) {
String uri = fact.@ref.uri;
OMA df = (OMA)((Scroll.ScrollSymbolFact)fact).df;
float a = (float)((OMF)df.arguments[0]).f;
float b = (float)((OMF)df.arguments[1]).f;
float c = (float)((OMF)df.arguments[2]).f;
string parse_id = ParsingDictionary.MMTermToString(df);
if(!ParsingDictionary.parseTermsToId.ContainsKey(parse_id))
ParsingDictionary.parseTermsToId[parse_id] = uri;
return new PointFact(a, b, c, uri, StageStatic.stage.factState);
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts() {
return false;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds() {
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
Marco Zimmer
committed
public override int GetHashCode()
Marco Zimmer
committed
return this.Point.GetHashCode() ^ this.Normal.GetHashCode();
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(PointFact f1, PointFact f2)
return Math3d.IsApproximatelyEqual(f1.Point, f2.Point);
Marco Zimmer
committed
/// <summary>
/// Line within 3D Space of finite length
/// </summary>
Marco Zimmer
committed
public class LineFact : AbstractLineFactWrappedCRTP<LineFact>
Marco Zimmer
committed
/// \copydoc Fact.s_type
Marco Zimmer
committed
protected static new string s_type = "LineFact";
Marco Zimmer
committed
/// <summary> Distance between <see cref="AbstractLineFact.Pid1"/> and <see cref="AbstractLineFact.Pid2"/></summary>
public float Distance;
/// <summary> \copydoc Fact.Fact </summary>
public LineFact() : base()
{
Distance = 0;
}
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(AbstractLineFact, Dictionary<string, string>, FactOrganizer) </summary>
public LineFact(LineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, old_to_new, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2]);
}
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer) </summary>
public LineFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer)
{
SetDistance();
}
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary>
public LineFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer)
{
init(pid1, pid2);
}
/// <summary>
/// Initiates <see cref="AbstractLineFact.Pid1"/>, <see cref="AbstractLineFact.Pid2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="AbstractLineFact.Pid1"/></param>
/// <param name="pid2">sets <see cref="AbstractLineFact.Pid2"/></param>
private void init(string pid1, string pid2)
SetDistance();
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
Marco Zimmer
committed
string p1URI = pf1.Id;
string p2URI = pf2.Id;
MMTTerm valueTp = new OMS(JSONManager.MMTURIs.RealLit);
John Schihada
committed
MMTTerm value = new OMF(v);
John Schihada
committed
MMTValueDeclaration mmtDecl = new MMTValueDeclaration(this.Label, lhs, valueTp, value);
Marco Zimmer
committed
AddFactResponse.sendAdd(mmtDecl, out this._URI);
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static LineFact parseFact(Scroll.ScrollFact fact)
string uri = fact.@ref.uri;
string pointAUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
string pointBUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri;
Marco Zimmer
committed
if (StageStatic.stage.factState.ContainsKey(pointAUri)
&& StageStatic.stage.factState.ContainsKey(pointBUri))
return new LineFact(pointAUri, pointBUri, uri, StageStatic.stage.factState);
//If dependent facts do not exist return null
else {
return null;
}
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "[" + _Facts[Pid1].Label + _Facts[Pid2].Label + "]";
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(LineFact f1, LineFact f2)
Marco Zimmer
committed
if ((f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2))// ||
//(f1.Pid1 == f2.Pid2 && f1.Pid2 == f2.Pid1))
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
Marco Zimmer
committed
return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2))
;//|| (p1f1.Equivalent(p2f2) && p2f1.Equivalent(p1f2));
/// <summary> Calculates and sets <see cref="Distance"/>; <remarks> <see cref="AbstractLineFact.Pid1"/> and <see cref="AbstractLineFact.Pid2"/> needs to be set first.</remarks></summary>
private void SetDistance()
{
this.Distance = Vector3.Distance(((PointFact)_Facts[Pid1]).Point, ((PointFact)_Facts[Pid2]).Point);
}
/// <summary>
/// Ray within 3D Space of infinite length
/// </summary>
Marco Zimmer
committed
public class RayFact : AbstractLineFactWrappedCRTP<RayFact>
Marco Zimmer
committed
/// \copydoc Fact.s_type
Marco Zimmer
committed
protected static new string s_type = "RayFact";
Marco Zimmer
committed
/// <summary> \copydoc Fact.Fact </summary>
public RayFact() : base() { }
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(AbstractLineFact, Dictionary<string, string>, FactOrganizer) </summary>
public RayFact(RayFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, old_to_new, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2]);
}
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, string, FactOrganizer) </summary>
public RayFact(string pid1, string pid2, string backendURI, FactOrganizer organizer) : base(pid1, pid2, backendURI, organizer)
{
_ = this.Label;
}
/// <summary> \copydoc AbstractLineFact.AbstractLineFact(string, string, FactOrganizer) </summary>
public RayFact(string pid1, string pid2, FactOrganizer organizer) : base(pid1, pid2, organizer)
{
init(pid1, pid2);
}
/// <summary>
/// Initiates <see cref="AbstractLineFact.Pid1"/>, <see cref="AbstractLineFact.Pid2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="AbstractLineFact.Pid1"/></param>
/// <param name="pid2">sets <see cref="AbstractLineFact.Pid2"/></param>
private void init(string pid1, string pid2)
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
Marco Zimmer
committed
Marco Zimmer
committed
string p1URI = pf1.Id;
string p2URI = pf2.Id;
List<MMTTerm> arguments = new List<MMTTerm>
{
new OMS(p1URI),
new OMS(p2URI)
};
//OMS constructor generates full URI
MMTTerm tp = new OMS(JSONManager.MMTURIs.LineType);
MMTTerm df = new OMA(new OMS(JSONManager.MMTURIs.LineOf), arguments);
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
Marco Zimmer
committed
AddFactResponse.sendAdd(mmtDecl, out this._URI);
string parse_id = ParsingDictionary.MMTermToString(df);
ParsingDictionary.parseTermsToId[parse_id] = this._URI;
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static RayFact parseFact(Scroll.ScrollFact fact)
{
if ((OMA)((Scroll.ScrollSymbolFact)fact).df == null)
return null;
string pointAUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[0]).uri;
string pointBUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[1]).uri;
if (StageStatic.stage.factState.ContainsKey(pointAUri)
Marco Zimmer
committed
&& StageStatic.stage.factState.ContainsKey(pointBUri))
return new RayFact(pointAUri, pointBUri, uri, StageStatic.stage.factState);
//If dependent facts do not exist return null
return null;
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
// TODO this string is too large to properly depict on scrolls.
// return "]" + _Facts[Pid1].Label + _Facts[Pid2].Label + "[";
return _Facts[Pid1].Label + _Facts[Pid2].Label ;
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(RayFact f1, RayFact f2)
Marco Zimmer
committed
if (!Math3d.IsApproximatelyParallel(f1.Dir, f2.Dir))
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
Marco Zimmer
committed
return Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p1f2.Point)
&& Math3d.IsPointApproximatelyOnLine(p1f1.Point, f1.Dir, p2f2.Point);
/// <summary>
/// A <see cref="PointFact"/> on a <see cref="AbstractLineFact"/>
/// </summary>
Marco Zimmer
committed
public class OnLineFact : FactWrappedCRTP<OnLineFact>
{
Marco Zimmer
committed
/// \copydoc Fact.s_type
Marco Zimmer
committed
protected static new string s_type = "OnLineFact";
Marco Zimmer
committed
public string
/// <summary> <see cref="PointFact"/>.<see cref="Fact.Id">Id</see> </summary>
Pid,
/// <summary> <see cref="AbstractLineFact"/>.<see cref="Fact.Id">Id</see> </summary>
Rid;
/// <summary> \copydoc Fact.Fact </summary>
public OnLineFact() : base()
{
this.Pid = null;
this.Rid = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public OnLineFact(OnLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid], old_to_new[fact.Rid]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="rid">sets <see cref="Rid"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OnLineFact(string pid, string rid, FactOrganizer organizer) : base(organizer)
{
init(pid, rid);
}
/// <summary>
/// Initiates <see cref="Pid"/>, <see cref="Rid"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="rid">sets <see cref="Rid"/></param>
private void init(string pid, string rid)
{
this.Pid = pid;
this.Rid = rid;
PointFact pf = _Facts[pid] as PointFact;
RayFact rf = _Facts[rid] as RayFact;
Marco Zimmer
committed
string pURI = pf.Id;
string rURI = rf.Id;
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(rURI),
new OMS(pURI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(JSONManager.MMTURIs.OnLine), innerArguments)
};
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(JSONManager.MMTURIs.Ded), outerArguments);
MMTTerm df = null;
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
Marco Zimmer
committed
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="rid">sets <see cref="Rid"/></param>
/// <param name="uri">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OnLineFact(string pid, string rid, string uri, FactOrganizer organizer) : base(organizer)
this.Pid = pid;
this.Rid = rid;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static OnLineFact parseFact(Scroll.ScrollFact fact)
{
string lineUri = "";
string pointUri = "";
if (((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0] is OMS)
{
// standard case
lineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
}
else {
// case when line Uri has a projl on the line Argument
lineUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).arguments[0]).uri;
pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
}
Marco Zimmer
committed
if (StageStatic.stage.factState.ContainsKey(pointUri)
&& StageStatic.stage.factState.ContainsKey(lineUri))
return new OnLineFact(pointUri, lineUri, uri, StageStatic.stage.factState);
//If dependent facts do not exist return null
else
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Pid].Label + "∈" + _Facts[Rid].Label;
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Rid].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
Marco Zimmer
committed
public override int GetHashCode()
return this.Pid.GetHashCode() ^ this.Rid.GetHashCode();
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(OnLineFact f1, OnLineFact f2)
Marco Zimmer
committed
if (f1.Pid == f2.Pid && f1.Rid == f2.Rid)
return true;
PointFact pf1 = (PointFact)_Facts[f1.Pid];
RayFact rf1 = (RayFact)_Facts[f1.Rid];
PointFact pf2 = (PointFact)_Facts[f2.Pid];
RayFact rf2 = (RayFact)_Facts[f2.Rid];
Marco Zimmer
committed
return pf1.Equivalent(pf2) && rf1.Equivalent(rf2);
}
/// <summary>
/// Angle comprised of three <see cref="PointFact">PointFacts</see> [A,B,C]
/// </summary>
Marco Zimmer
committed
public class AngleFact : FactWrappedCRTP<AngleFact>
{
Marco Zimmer
committed
/// \copydoc Fact.s_type
Marco Zimmer
committed
protected static new string s_type = "AngleFact";
Marco Zimmer
committed
/// @{ <summary>
/// One <see cref="Fact.Id">Id</see> of three <see cref="PointFact">PointFacts</see> defining Angle [<see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>].
/// </summary>
/// @}
/// <summary> <see langword="true"/>, if AngleFact is approximately 90° or 270°</summary>
/// <summary> \copydoc Fact.Fact </summary>
public AngleFact() : base()
{
this.Pid1 = null;
this.Pid2 = null;
this.Pid3 = null;
this.is_right_angle = false;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public AngleFact(AngleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2], old_to_new[fact.Pid3]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(organizer)
{
init(pid1, pid2, pid3);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
private void init(string pid1, string pid2, string pid3)
this.Pid1 = pid1;
this.Pid2 = pid2;
this.Pid3 = pid3;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
PointFact pf3 = _Facts[pid3] as PointFact;
float v = GetAngle(); // sets is_right_angle
John Schihada
committed
MMTDeclaration mmtDecl;
Marco Zimmer
committed
string p1URI = pf1.Id;
string p2URI = pf2.Id;
string p3URI = pf3.Id;
mmtDecl = generateNot90DegreeAngleDeclaration(v, p1URI, p2URI, p3URI);
Marco Zimmer
committed
AddFactResponse.sendAdd(mmtDecl, out this._URI);
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="Pid3">sets <see cref="Pid3"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.Pid3 = Pid3;
float v = GetAngle();
this._URI = backendURI;
_ = this.Label;
}
public AngleFact(string Pid1, string Pid2, string Pid3,float angle, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.Pid3 = Pid3;
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static AngleFact parseFact(Scroll.ScrollFact fact)
string uri = fact.@ref.uri;
string
pointAUri,
pointBUri,
pointCUri;
//If angle is not a 90Degree-Angle
if (fact.GetType().Equals(typeof(Scroll.ScrollValueFact)))
{
OMA df = (OMA)((Scroll.ScrollValueFact)fact).lhs;
if (df == null)
return null;
if (((Scroll.ScrollValueFact)fact).value != null)
angle = ((OMF)(((Scroll.ScrollValueFact)fact).value)).f;
pointAUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
pointBUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri;
pointCUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[2]).uri;
// this should never happen anymore
//If angle is a 90Degree-Angle
else {
Debug.Log("Angle 90 degrees parsed. This shouldn't happen anymore");
pointAUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[0]).uri;
pointBUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[1]).uri;
pointCUri = ((OMS)((OMA)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).arguments[2]).uri;
}
Marco Zimmer
committed
if (StageStatic.stage.factState.ContainsKey(pointAUri)
&& StageStatic.stage.factState.ContainsKey(pointBUri)
&& StageStatic.stage.factState.ContainsKey(pointCUri))
{
// return new AngleFact(pointAUri, pointBUri, pointCUri, uri, StageStatic.stage.factState);
return new AngleFact(pointAUri, pointBUri, pointCUri,angle, uri, StageStatic.stage.factState);
}
else
{ //If dependent facts do not exist return null
return null;
John Schihada
committed
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return (is_right_angle ? "⊾" : "∠") + _Facts[Pid1].Label + _Facts[Pid2].Label + _Facts[Pid3].Label;
/// <summary>
/// Computes smallest angle and sets <see cref="is_right_angle"/>
/// </summary>
/// <returns>Smallets angle between [<see cref="Pid1"/>, <see cref="Pid2"/>] and [<see cref="Pid2"/>, <see cref="Pid3"/>]</returns>
PointFact pf1 = _Facts[Pid1] as PointFact;
PointFact pf2 = _Facts[Pid2] as PointFact;
PointFact pf3 = _Facts[Pid3] as PointFact;
float v = Vector3.Angle((pf1.Point - pf2.Point), (pf3.Point - pf2.Point));
this.is_right_angle = Mathf.Abs(v - 90.0f) < 0.01;
return is_right_angle ? 90f : v;
}
/// <summary>
/// Constructs struct for right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="val">Angle == 90f, _not checked_</param>
/// <param name="p1URI"><see cref="Pid1"/></param>
/// <param name="p2URI"><see cref="Pid2"/></param>
/// <param name="p3URI"><see cref="Pid3"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
John Schihada
committed
private MMTDeclaration generate90DegreeAngleDeclaration(float val, string p1URI, string p2URI, string p3URI) {
MMTTerm argument = new OMA(
John Schihada
committed
new List<MMTTerm> {
John Schihada
committed
new OMA(
John Schihada
committed
new List<MMTTerm> {
new OMS(p1URI),
new OMS(p2URI),
new OMS(p3URI)
}
),
John Schihada
committed
}
);
MMTTerm tp = new OMA(new OMS(JSONManager.MMTURIs.Ded), new List<MMTTerm> { argument });
John Schihada
committed
MMTTerm df = null;
return new MMTSymbolDeclaration(this.Label, tp, df);
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="val">Angle != 90f, _not checked_</param>
/// <param name="p1URI"><see cref="Pid1"/></param>
/// <param name="p2URI"><see cref="Pid2"/></param>
/// <param name="p3URI"><see cref="Pid3"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
John Schihada
committed
private MMTDeclaration generateNot90DegreeAngleDeclaration(float val, string p1URI, string p2URI, string p3URI)
{
MMTTerm lhs =
new OMA(
John Schihada
committed
new List<MMTTerm> {
new OMS(p1URI),
new OMS(p2URI),
new OMS(p3URI)
}
);
MMTTerm valueTp = new OMS(JSONManager.MMTURIs.RealLit);
John Schihada
committed
MMTTerm value = new OMF(val);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
return new string[] { Pid1, Pid2, Pid3 };
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform) {
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid2].Label;
obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid3].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
Marco Zimmer
committed
public override int GetHashCode()
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode() ^ this.Pid3.GetHashCode();
/// \copydoc Fact.Equivalent(Fact, Fact)
Marco Zimmer
committed
protected override bool EquivalentWrapped(AngleFact f1, AngleFact f2)
Marco Zimmer
committed
if ((f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid3))// ||
//(f1.Pid1 == f2.Pid3 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid1))
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
PointFact p3f1 = (PointFact)_Facts[f1.Pid3];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
PointFact p3f2 = (PointFact)_Facts[f2.Pid3];
Marco Zimmer
committed
return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2) && p3f1.Equivalent(p3f2));
//|| (p1f1.Equivalent(p3f2) && p2f1.Equivalent(p2f2) && p1f1.Equivalent(p3f2));
}
}
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
/// <summary>
/// A RightAngleFact defined by 3 <see cref="PointFact">Pointfact</see>
/// </summary>
public class RightAngleFact : FactWrappedCRTP<RightAngleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "RightAngleFact";
/// <summary> three <see cref="PointFact">Pointfacts</see> defining the right angle </summary>
public string Pid1, Pid2, Pid3;
/// <summary> \copydoc Fact.Fact </summary>
public RightAngleFact() : base()
{
this.Pid1 = null;
this.Pid2 = null;
this.Pid3 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public RightAngleFact(RightAngleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2], old_to_new[fact.Pid3]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string pid1, string pid2, string pid3, FactOrganizer organizer) : base(organizer)
{
init(pid1, pid2, pid3);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="pid3">sets <see cref="Pid3"/></param>
private void init(string pid1, string pid2, string pid3)
{
this.Pid1 = pid1;
this.Pid2 = pid2;
this.Pid3 = pid3;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
PointFact pf3 = _Facts[pid3] as PointFact;
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
MMTDeclaration mmtDecl;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
string p3URI = pf3.Id;
mmtDecl = generateMMTDeclaration(p1URI, p2URI, p3URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="Pid3">sets <see cref="Pid3"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RightAngleFact(string Pid1, string Pid2, string Pid3, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.Pid3 = Pid3;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static RightAngleFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string Point1Uri = "";
string Point2Uri = "";
string Point3Uri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA rightAngleOMA = (OMA)proof_OMA.arguments[0]; // rightAngle OMA
if (rightAngleOMA.arguments[0] is OMS)
{
Point1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
Point2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
Point3Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[2]).uri;
}
if (StageStatic.stage.factState.ContainsKey(Point1Uri)
&& StageStatic.stage.factState.ContainsKey(Point2Uri)
&& StageStatic.stage.factState.ContainsKey(Point3Uri))
return new RightAngleFact(Point1Uri, Point2Uri, Point3Uri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Pid1].Label + _Facts[Pid2].Label + _Facts[Pid3].Label + "⊥";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="p1URI"> Uri for <see cref="Pid1"/></param>
/// <param name="p2URI"> Uri for <see cref="Pid2"/></param>
/// <param name="p3URI"> Uri for <see cref="Pid3"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string p1URI, string p2URI, string p3URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(p1URI),
new OMS(p2URI),
new OMS(p3URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.RightAngle), innerArguments)
};
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
return new MMTSymbolDeclaration(this.Label, tp, df);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Pid1, Pid2, Pid3 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid2].Label;
obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid3].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode() ^ this.Pid3.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(RightAngleFact f1, RightAngleFact f2)
{
if (f1.Pid1 == f2.Pid1 && f1.Pid2 == f2.Pid2 && f1.Pid3 == f2.Pid3)
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p2f1 = (PointFact)_Facts[f1.Pid2];
PointFact p3f1 = (PointFact)_Facts[f1.Pid3];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
PointFact p2f2 = (PointFact)_Facts[f2.Pid2];
PointFact p3f2 = (PointFact)_Facts[f2.Pid3];
return (p1f1.Equivalent(p1f2) && p2f1.Equivalent(p2f2) && p3f1.Equivalent(p3f2));
}
}
/// <summary>
/// Two parallel Lines comprised of two <see cref="LineFact">LineFacts</see>
/// </summary>
public class ParallelLineFact : FactWrappedCRTP<ParallelLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "ParallelLineFact";
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
/// @{ <summary>
/// One <see cref="Fact.Id">Id</see> of thwo <see cref="LineFact">PointFacts</see> defining Angle [<see cref="Lid1"/>, <see cref="Lid2"/>].
/// </summary>
public string Lid1, Lid2;
/// @}
/// <summary> \copydoc Fact.Fact </summary>
public ParallelLineFact() : base()
{
this.Lid1 = null;
this.Lid2 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public ParallelLineFact(ParallelLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Lid1], old_to_new[fact.Lid2]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="lid1">sets <see cref="Lid1"/></param>
/// <param name="lid2">sets <see cref="Lid2"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public ParallelLineFact(string lid1, string lid2, FactOrganizer organizer) : base(organizer)
{
init(lid1, lid2);
}
/// <summary>
/// Initiates <see cref="Lid1"/>, <see cref="Lid2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="lid1">sets <see cref="Lid1"/></param>
/// <param name="lid2">sets <see cref="Lid2"/></param>
private void init(string lid1, string lid2)
{
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
this.Lid1 = lid1;
this.Lid2 = lid2;
RayFact lf1 = _Facts[lid1] as RayFact;
RayFact lf2 = _Facts[lid2] as RayFact;
MMTDeclaration mmtDecl;
string l1URI = lf1.Id;
string l2URI = lf2.Id;
mmtDecl = generateParallelLineDeclaration( l1URI, l2URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Lid1">sets <see cref="Lid1"/></param>
/// <param name="Lid2">sets <see cref="Lid2"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public ParallelLineFact(string Lid1, string Lid2, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Lid1 = Lid1;
this.Lid2 = Lid2;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static ParallelLineFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string lineAUri = "";
string lineBUri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA parallel_lines_OMA = (OMA) proof_OMA.arguments[0]; // parallel
if (parallel_lines_OMA.arguments[0] is OMS) {
// Normaler Fall
lineAUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
lineBUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
}
// Second case might be redundant by now
else {
OMA Projl_line_A_OMA = (OMA)parallel_lines_OMA.arguments[0]; // ProjectL
lineAUri = ((OMS)Projl_line_A_OMA.arguments[0]).uri;
OMA Projl_line_B_OMA = (OMA)parallel_lines_OMA.arguments[1]; // ProjectL
lineBUri = ((OMS)Projl_line_B_OMA.arguments[0]).uri;
}
if (StageStatic.stage.factState.ContainsKey(lineAUri)
&& StageStatic.stage.factState.ContainsKey(lineBUri))
return new ParallelLineFact(lineAUri,lineBUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "||" + _Facts[Lid1].Label + _Facts[Lid2].Label;
}
/// <summary>
/// Constructs struct for right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="l1URI"><see cref="Lid1"/></param>
/// <param name="l2URI"><see cref="Lid2"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateParallelLineDeclaration(string l1URI, string l2URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(l1URI),
new OMS(l2URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.ParallelLine), innerArguments)
};
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
return mmtDecl;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Lid1, Lid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Lid1.GetHashCode() ^ this.Lid2.GetHashCode() ;
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(ParallelLineFact f1, ParallelLineFact f2)
{
if ((f1.Lid1 == f2.Lid1 && f1.Lid2 == f2.Lid2))
return true;
RayFact r1f1 = (RayFact)_Facts[f1.Lid1];
RayFact r2f1 = (RayFact)_Facts[f1.Lid2];
RayFact r1f2 = (RayFact)_Facts[f2.Lid1];
RayFact r2f2 = (RayFact)_Facts[f2.Lid2];
return (r1f1.Equivalent(r1f2) && r2f1.Equivalent(r2f2)) ;
}
}
/// <summary>
/// A Circle that is made out of a middle point, a plane and a radius
/// </summary>
public class CircleFact : FactWrappedCRTP<CircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "CircleFact";
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
/// <summary> defining the middle point of the circle </summary>
public string Pid1;
/// <summary> defining the base point of the circle plane </summary>
public string Pid2;
/// <summary> radius of the circle </summary>
public float radius;
/// <summary> normal vector of the plane </summary>
public Vector3 normal;
/// <summary> \copydoc Fact.Fact </summary>
public CircleFact() : base()
{
this.normal = Vector3.zero;
this.Pid1 = null;
this.Pid2 = null;
this.radius = 0;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public CircleFact(CircleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid1], old_to_new[fact.Pid2], fact.radius, fact.normal);
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public CircleFact(string pid1, string pid2, float radius, Vector3 normal, FactOrganizer organizer) : base(organizer)
{
init(pid1, pid2, radius, normal);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="radius"/>,<see cref="dir1"/>,<see cref="dir2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
private void init(string pid1, string pid2, float radius, Vector3 normal)
{
this.Pid1 = pid1;
this.Pid2 = pid2;
PointFact pf1 = _Facts[pid1] as PointFact;
PointFact pf2 = _Facts[pid2] as PointFact;
this.radius = radius;
this.normal = normal;
MMTDeclaration mmtDecl;
string p1URI = pf1.Id;
string p2URI = pf2.Id;
mmtDecl = generateCircleFactDeclaration(p1URI, p2URI, radius, normal);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public CircleFact(string Pid1, string Pid2, float radius, Vector3 normal, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Pid1 = Pid1;
this.Pid2 = Pid2;
this.radius = radius;
this.normal = normal;
this._URI = backendURI;
_ = this.Label;
}
/// <summary>
/// parses the Circlefact response of the MMT-Server
/// </summary>
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static CircleFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string M_uri = "";
string A_uri = "";
float radius = 0.0f;
Vector3 normal = Vector3.zero;
OMA df = (OMA)((Scroll.ScrollSymbolFact)fact).df;
if (df == null)
return null;
Scroll.ScrollSymbolFact casted_fact = (Scroll.ScrollSymbolFact)fact;
// get the mid point uri
string parse_id_M = ParsingDictionary.MMTermToString(((OMA)casted_fact.df).arguments[1]);
radius = ((OMF)((OMA)casted_fact.df).arguments[2]).f;
OMA planeOMA = (OMA)((OMA)casted_fact.df).arguments[0];
string planeApplicant = ((OMS)planeOMA.applicant).uri;
// Getting the plane
// IN case of a normale plane
if (planeApplicant.Equals(MMTURIs.pointNormalPlane))
{
OMA pointAOMA = (OMA)planeOMA.arguments[0];
string parse_id_A = ParsingDictionary.MMTermToString(planeOMA.arguments[0]);
A_uri = ParsingDictionary.parseTermsToId[parse_id_A];
OMA n = (OMA)planeOMA.arguments[1];
normal = new Vector3(((OMF)n.arguments[0]).f, ((OMF)n.arguments[1]).f, ((OMF)n.arguments[2]).f);
}
// In case of parametrized plane
else if(planeApplicant.Equals(MMTURIs.ParametrizedPlane))
{
OMA pointAOMA = (OMA)planeOMA.arguments[0];
string parse_id_A = ParsingDictionary.MMTermToString(planeOMA.arguments[0]);
A_uri = ParsingDictionary.parseTermsToId[parse_id_A];
OMA vOMA = (OMA)planeOMA.arguments[1];
OMA wOMA = (OMA)planeOMA.arguments[2];
Vector3 v = new Vector3(((OMF)vOMA.arguments[0]).f, ((OMF)vOMA.arguments[1]).f, ((OMF)vOMA.arguments[2]).f);
Vector3 w = new Vector3(((OMF)wOMA.arguments[0]).f, ((OMF)wOMA.arguments[1]).f, ((OMF)wOMA.arguments[2]).f);
normal = Vector3.Cross(v, w).normalized;
// incase of smth else. Shouldn't hapepen unless there is an error
else {
Debug.Log("planeApplicant" + planeApplicant);
Debug.Log("?? " + MMTURIs.pointNormalPlane);
return null;
}
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
if (StageStatic.stage.factState.ContainsKey(M_uri)
&& StageStatic.stage.factState.ContainsKey(A_uri))
return new CircleFact(M_uri,A_uri,radius,normal, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "○"+_Facts[Pid1].Label;
}
/// <summary>
/// Constructs struct for right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="p1URI"> <see cref="Pid1"/></param>
/// <param name="p2URI"> <see cref="Pid2"/></param>
/// <param name="radius"> <see cref="radius"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateCircleFactDeclaration( string p1URI, string p2URI, float radius, Vector3 normal)
{
PointFact p1 = _Facts[p1URI] as PointFact;
PointFact p2 = _Facts[p2URI] as PointFact;
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
List<MMTTerm> normalArgs = new List<MMTTerm>
{
new OMF(normal.x),
new OMF(normal.y),
new OMF(normal.z)
};
OMA NormalVector = new OMA(new OMS(MMTURIs.Tuple), normalArgs);
List<MMTTerm> planeArgs = new List<MMTTerm>
{
new OMS(p2URI),
NormalVector //n
};
OMA CirclePlane = new OMA(new OMS(MMTURIs.pointNormalPlane), planeArgs);
OMS middlePoint = new OMS(p1URI);
OMF Radius = new OMF(radius);
List<MMTTerm> outerArguments = new List<MMTTerm>
{
CirclePlane,
middlePoint,
Radius
};
//OMS constructor generates full URI
// Do i need this here? doubt
MMTTerm tp = new OMS(MMTURIs.CircleType3d);
MMTTerm df = new OMA(new OMS(MMTURIs.MkCircle3d), outerArguments);
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
return mmtDecl;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
public Vector3 getNormal()
{
return normal;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Pid1,Pid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid1].Label;
// obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode() ;
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(CircleFact f1, CircleFact f2)
{
if ( f1.Pid1 == f2.Pid1 && f1.normal == f2.normal && f1.radius == f2.radius)
return true;
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
return p1f1.Equivalent(p1f2)
&& Math3d.IsApproximatelyEqual(f1.normal, f2.normal)
&& Mathf.Approximately(f1.radius, f2.radius);
}
}
/// <summary>
/// A <see cref="PointFact"/> on a <see cref="CircleFact"/>
/// </summary>
public class OnCircleFact : FactWrappedCRTP<OnCircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "OnCircleFact";
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
/// <summary> the point on the circle </summary>
public string Pid;
/// <summary> the circle, which the point is on </summary>
public string Cid;
/// <summary> \copydoc Fact.Fact </summary>
public OnCircleFact() : base()
{
this.Pid = null;
this.Cid = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public OnCircleFact(OnCircleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Pid], old_to_new[fact.Cid]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="cid">sets <see cref="Cid"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OnCircleFact(string pid, string cid, FactOrganizer organizer) : base(organizer)
{
init(pid, cid);
}
/// <summary>
/// Initiates <see cref="Pid"/>, <see cref="Rid"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="cid">sets <see cref="Cid"/></param>
private void init(string pid, string cid)
{
this.Pid = pid;
this.Cid = cid;
PointFact pf = _Facts[pid] as PointFact;
CircleFact cf = _Facts[cid] as CircleFact;
string pURI = pf.Id;
string cURI = cf.Id;
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(cURI),
new OMS(pURI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.OnCircle), innerArguments)
};
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="pid">sets <see cref="Pid"/></param>
/// <param name="cid">sets <see cref="Cid"/></param>
/// <param name="uri">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OnCircleFact(string pid, string cid, string uri, FactOrganizer organizer) : base(organizer)
{
this.Pid = pid;
this.Cid = cid;
this._URI = uri;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static OnCircleFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string circleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
string pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
if (StageStatic.stage.factState.ContainsKey(pointUri)
&& StageStatic.stage.factState.ContainsKey(circleUri))
return new OnCircleFact(pointUri, circleUri, uri, StageStatic.stage.factState);
//If dependent facts do not exist return null
else
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Pid].Label + "∈" + _Facts[Cid].Label;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Pid, Cid };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid].Label + "∈" + _Facts[this.Cid].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Pid.GetHashCode() ^ this.Cid.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(OnCircleFact c1, OnCircleFact c2)
{
if (c1.Pid == c2.Pid && c1.Cid == c2.Pid)
return true;
PointFact pc1 = (PointFact)_Facts[c1.Pid];
CircleFact cc1 = (CircleFact)_Facts[c1.Cid];
PointFact pc2 = (PointFact)_Facts[c2.Pid];
CircleFact cc2 = (CircleFact)_Facts[c2.Cid];
return pc1.Equivalent(pc2) && cc1.Equivalent(cc2);
}
}
/// <summary>
/// Angle comprised of a line and a circle
/// </summary>
public class AngleCircleLineFact : FactWrappedCRTP<AngleCircleLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "AngleCircleLineFact";
/// One <see cref="Fact.Id">Id</see> of a <see cref="RayFact">RayFact</see> and a <see cref="CircleFact">CircleFact</see> defining Angle [<see cref="Cid1"/>, <see cref="Rid2"/>].
/// </summary>
public string Cid1, Rid2;
/// @}
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
/// <summary> \copydoc Fact.Fact </summary>
public AngleCircleLineFact() : base()
{
this.Cid1 = null;
this.Rid2 = null;
this.angle = 0.0f;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public AngleCircleLineFact(AngleCircleLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Rid2], fact.angle);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="rid2">sets <see cref="Rid2"/></param>
/// <param name="angle"> sets the angle </param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AngleCircleLineFact(string cid1, string rid2, float angle, FactOrganizer organizer) : base(organizer)
{
init(cid1, rid2, angle);
}
/// <summary>
/// Initiates <see cref="Cid1"/>, <see cref="Rid2"/>, <see cref="angle"/> <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="rid2">sets <see cref="Rid2"/></param>
/// <param name="angle"> sets the angle </param>
private void init(string cid1, string rid2, float angle)
{
this.Cid1 = cid1;
this.Rid2 = rid2;
this.angle = angle;
CircleFact cf1 = _Facts[cid1] as CircleFact;
RayFact rf2 = _Facts[rid2] as RayFact;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string r2URI = rf2.Id;
mmtDecl = generateMMTDeclaration(angle, c1URI, r2URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="´Rid2">sets <see cref="Rid2"/></param>
/// <param name="angle"> sets the angle </param>
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Rid2 = Rid2;
this.angle = angle;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static AngleCircleLineFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string
CircleUri,
RayUri;
OMA df = (OMA)((Scroll.ScrollValueFact)fact).lhs;
if (df == null)
return null;
// init it with 0 degrees, so we don't accidentally generate orthogonalfacts
// and the parsing works correctly if smb ever adds a scroll for this
float angle = 0.0f;
if((((Scroll.ScrollValueFact)fact).value)!=null)
angle = ((OMF)(((Scroll.ScrollValueFact)fact).value)).f;
CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
RayUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri;
if (StageStatic.stage.factState.ContainsKey(CircleUri)
&& StageStatic.stage.factState.ContainsKey(RayUri))
{
return new AngleCircleLineFact(CircleUri, RayUri, angle, uri, StageStatic.stage.factState);
}
else
{
//If dependent facts do not exist return null
return null;
}
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "∠" + _Facts[Cid1].Label + _Facts[Rid2].Label;
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="val">Angle != 90f, _not checked_</param>
/// <param name="c1URI"><see cref="Cid1"/></param>
/// <param name="R2URI"><see cref="Rid2"/></param>
/// <param name="val"><see cref="angle"/></param>
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(float val, string c1URI, string r2URI)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.AnglePlaneLine),
new List<MMTTerm> {
new OMS(c1URI),
new OMS(r2URI),
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(val);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Rid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Rid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Rid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(AngleCircleLineFact f1, AngleCircleLineFact f2)
{
if (f1.Cid1 == f2.Cid1 && f1.Rid2 == f2.Rid2 )
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
RayFact r2f1 = (RayFact)_Facts[f1.Rid2];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
RayFact r2f2 = (RayFact)_Facts[f2.Rid2];
return (c1f1.Equivalent(c1f2) && r2f1.Equivalent(r2f2));
}
}
/// <summary>
/// A RadiusFact that corresponds to a <see cref="CircleFact">PointFacts</see> and has a float value (the actual radius).
/// </summary>
public class RadiusFact : FactWrappedCRTP<RadiusFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "RadiusFact";
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
/// <summary> The circle corresponding to the radius </summary>
public string Cid1;
/// <summary> The radius as a float </summary>
public float rad;
/// <summary> \copydoc Fact.Fact </summary>
public RadiusFact() : base()
{
this.Cid1 = null;
this.rad = 0.0f;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public RadiusFact(RadiusFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RadiusFact(string cid1, FactOrganizer organizer) : base(organizer)
{
init(cid1);
}
/// <summary>
/// Initiates <see cref="Cid1"/> and <see cref="rad"/>
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
private void init(string cid1)
{
this.Cid1 = cid1;
CircleFact cf1 = _Facts[cid1] as CircleFact;
this.rad = cf1.radius;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
mmtDecl = generateMMTDeclaration(c1URI,this.rad);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public RadiusFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static RadiusFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
if (StageStatic.stage.factState.ContainsKey(CircleUri))
return new RadiusFact(CircleUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "r "+ _Facts[Cid1].Label;
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="rad"> see <see cref="rad"/></param>
/// <param name="c1URI"> see <see cref="Cid1"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration( string c1URI, float rad)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.RadiusCircleMetric),
new List<MMTTerm> {
new OMS(c1URI),
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(rad);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1};
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "r: "+_Facts[this.Cid1].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Cid1.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(RadiusFact f1, RadiusFact f2)
{
if (f1.Cid1 == f2.Cid1)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
// if they correspond to the same circle, then automatically the radius has to be the same
return (c1f1.Equivalent(c1f2));
}
}
/// <summary>
/// Area of a <see cref="CircleFact">CircleFact</see>
/// </summary>
public class AreaCircleFact : FactWrappedCRTP<AreaCircleFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "AreaCircleFact";
/// <summary> the circle <see cref="CircleFact">CircleFact</see> </summary>
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
public string Cid1;
/// <summary> the area which is contained by the circle </summary>
public float A;
/// <summary> \copydoc Fact.Fact </summary>
public AreaCircleFact() : base()
{
this.Cid1 = null;
this.A = 0.0f;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public AreaCircleFact(AreaCircleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AreaCircleFact(string cid1, FactOrganizer organizer) : base(organizer)
{
init(cid1);
}
/// <summary>
/// Initiates <see cref="Cid1"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
private void init(string cid1)
{
this.Cid1 = cid1;
CircleFact cf1 = _Facts[cid1] as CircleFact;
this.A = cf1.radius * cf1.radius * ( (float) Math.PI );
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
mmtDecl = generateMMTDeclaration(c1URI, this.A);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public AreaCircleFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static AreaCircleFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
if (StageStatic.stage.factState.ContainsKey(CircleUri))
return new AreaCircleFact(CircleUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "A(" + _Facts[Cid1].Label+")";
}
/// <summary>
/// Constructs a response, that is sent to the MMT-Server
/// </summary>
/// <param name="area"> area of the circle </param>
/// <param name="c1URI"> <see cref="Cid1"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string c1URI, float area)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.AreaCircle),
new List<MMTTerm> {
new OMS(c1URI),
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(area);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// is this a problem?
public override int GetHashCode()
{
return this.Cid1.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(AreaCircleFact f1, AreaCircleFact f2)
{
if (f1.Cid1 == f2.Cid1)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
return (c1f1.Equivalent(c1f2) && f1.A == f2.A);
}
}
/// <summary>
/// The volume of a cone A defined by a base area <see cref="CircleFact">CircleFact</see>, an apex <see cref="PointFact">PointFact</see> and the volume as float
/// </summary>
public class ConeVolumeFact : FactWrappedCRTP<ConeVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "ConeVolumeFact";
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="PointFact">PointFact</see> describing the apex point </summary>
public string Pid1;
/// <summary> the volume of the cone as a float </summary>
public float vol;
/// <summary> \copydoc Fact.Fact </summary>
public ConeVolumeFact() : base()
{
this.Cid1 = null;
this.Pid1 = null;
this.vol = 0.0f;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public ConeVolumeFact(ConeVolumeFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Pid1], fact.vol);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public ConeVolumeFact(string cid1,string pid1, float vol, FactOrganizer organizer) : base(organizer)
{
init(cid1,pid1,vol);
}
/// <summary>
/// Initiates <see cref="Cid1"/>, <see cref="Pid1"/>, <see cref="vol"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
private void init(string cid1,string pid1, float vol)
{
this.Cid1 = cid1;
this.Pid1 = pid1;
CircleFact cf1 = _Facts[cid1] as CircleFact;
PointFact pf1 = _Facts[pid1] as PointFact;
this.vol = vol;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string p1URI = pf1.Id;
mmtDecl = generateMMTDeclaration(c1URI, p1URI, vol);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="volume">sets <see cref="vol"/></param>
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public ConeVolumeFact(string Cid1,string Pid1, float volume, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Pid1 = Pid1;
this.vol = volume;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static ConeVolumeFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
if (((Scroll.ScrollValueFact)fact).lhs == null)
return null;
string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri;
string PointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri;
float volume = 0.0f;
if( (((Scroll.ScrollValueFact)fact).value) !=null )
volume = ((OMF) ((Scroll.ScrollValueFact)fact).value).f ;
if (StageStatic.stage.factState.ContainsKey(CircleUri)&& StageStatic.stage.factState.ContainsKey(PointUri))
return new ConeVolumeFact(CircleUri,PointUri,volume, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "V(" + _Facts[Cid1].Label +"," + _Facts[Pid1].Label+")";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
/// <param name="p1URI"> Uri for <see cref="Pid1"/></param>
/// <param name="val"> <see cref="vol"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string c1URI, string p1URI, float val)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.VolumeCone),
new List<MMTTerm> {
new OMA(new OMS(MMTURIs.ConeOfCircleApex),
new List<MMTTerm> {
new OMS(c1URI),
new OMS(p1URI),
}
),
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(val);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Pid1 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label+ _Facts[this.Pid1].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Cid1.GetHashCode()^this.Pid1.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(ConeVolumeFact f1, ConeVolumeFact f2)
{
if (f1.Cid1 == f2.Cid1 && f1.Pid1 == f2.Pid1)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
return (c1f1.Equivalent(c1f2)&& p1f1.Equivalent(p1f2) && (Mathf.Abs(f1.vol - f2.vol) < 0.001) );
}
}
/// <summary>
/// The fact that the plane of a <see cref="CircleFact">CircleFact</see> and the line <see cref="RayFact>RayFact</see> are orthogonal
/// </summary>
public class OrthogonalCircleLineFact : FactWrappedCRTP<OrthogonalCircleLineFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "OrthogonalCircleLineFact";
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="RayFact">Rayfact</see> describing the line </summary>
public string Lid1;
/// <summary> \copydoc Fact.Fact </summary>
public OrthogonalCircleLineFact() : base()
{
this.Cid1 = null;
this.Lid1 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public OrthogonalCircleLineFact(OrthogonalCircleLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Lid1]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="lid1">sets <see cref="Lid1"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OrthogonalCircleLineFact(string cid1, string lid1, FactOrganizer organizer) : base(organizer)
{
init(cid1, lid1);
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="lid1">sets <see cref="Lid1"/></param>
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
private void init(string cid1, string lid1)
{
this.Cid1 = cid1;
this.Lid1 = lid1;
CircleFact cf1 = _Facts[cid1] as CircleFact;
RayFact lf1 = _Facts[lid1] as RayFact;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string l1URI = lf1.Id;
mmtDecl = generateMMTDeclaration(c1URI, l1URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Lid1">sets <see cref="Lid1"/></param>
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public OrthogonalCircleLineFact(string Cid1, string Lid1, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Lid1 = Lid1;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static OrthogonalCircleLineFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string uri = fact.@ref.uri;
string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
string LineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
if (StageStatic.stage.factState.ContainsKey(CircleUri)
&& StageStatic.stage.factState.ContainsKey(LineUri))
return new OrthogonalCircleLineFact(CircleUri, LineUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Cid1].Label + "⊥" + _Facts[Lid1].Label;
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
/// <param name="l1URI"> Uri for <see cref="Lid1"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string c1URI, string l1URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(c1URI),
new OMS(l1URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.OrthoCircleLine), innerArguments)
};
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
return new MMTSymbolDeclaration(this.Label, tp, df);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Lid1 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid1].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Lid1.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(OrthogonalCircleLineFact f1, OrthogonalCircleLineFact f2)
{
if (f1.Cid1 == f2.Cid1 && f1.Lid1 == f2.Lid1)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
RayFact l1f1 = (RayFact)_Facts[f1.Lid1];
RayFact l1f2 = (RayFact)_Facts[f2.Lid1];
return (c1f1.Equivalent(c1f2) && l1f1.Equivalent(l1f2));
}
}
/// <summary>
/// The volume of a cone A defined by a base area <see cref="CircleFact">CircleFact</see>, a top area <see cref="CircleFact">CircleFact</see> and the volume as float
/// </summary>
public class TruncatedConeVolumeFact : FactWrappedCRTP<TruncatedConeVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "TruncatedConeVolumeFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary>
/// <summary> the volume of Truncated the cone as a float </summary>
/// <summary> a proof that both circles have not the same size </summary>
public string unequalCirclesProof;
/// <summary> OMA proof that the two circles are parallel </summary>
public OMA proof;
/// <summary> \copydoc Fact.Fact </summary>
public TruncatedConeVolumeFact() : base()
{
this.Cid1 = null;
this.Cid2 = null;
this.vol = 0.0f;
this.unequalCirclesProof = null;
this.proof = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public TruncatedConeVolumeFact(TruncatedConeVolumeFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Cid2], fact.vol, old_to_new[fact.unequalCirclesProof], fact.proof);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public TruncatedConeVolumeFact(string cid1, string cid2, float vol, string unequalproof, OMA proof, FactOrganizer organizer) : base(organizer)
init(cid1, cid2, vol,unequalproof, proof);
}
/// <summary>
/// sets variables and generates MMT Declaration
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
private void init(string cid1, string cid2, float vol, string unequalproof, OMA proof)
{
this.Cid1 = cid1;
this.Cid2 = cid2;
this.proof = proof;
this.unequalCirclesProof = unequalproof;
CircleFact cf1 = _Facts[cid1] as CircleFact;
CircleFact cf2 = _Facts[cid2] as CircleFact;
this.vol = vol;
UnEqualCirclesFact unEqualProof = _Facts[unequalproof] as UnEqualCirclesFact;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string c2URI = cf2.Id;
string pURI = unEqualProof.Id;
mmtDecl = generateMMTDeclaration(c1URI, c2URI, vol, pURI, proof);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Cid2">sets <see cref="Cid2"/></param>
/// <param name="volume">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public TruncatedConeVolumeFact(string Cid1, string Cid2, float volume, string unequalproof, OMA proof, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Cid2 = Cid2;
this.vol = volume;
this.proof = proof;
this.unequalCirclesProof = unequalproof;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static TruncatedConeVolumeFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string Circle1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri;
string Circle2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri;
float volume = ((OMF)((Scroll.ScrollValueFact)fact).value).f;
string UnEqualCirclesProof = ((OMS)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[2])).uri;
OMA proof = (OMA)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[3]);
if (StageStatic.stage.factState.ContainsKey(Circle1Uri) && StageStatic.stage.factState.ContainsKey(Circle2Uri))
return new TruncatedConeVolumeFact(Circle1Uri, Circle2Uri, volume, UnEqualCirclesProof , proof, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "V(" + _Facts[Cid1].Label +"," + _Facts[Cid2].Label+")";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
/// <param name="c2URI"> Uri for <see cref="Cid2"/></param>
/// <param name="val"> <see cref="vol"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string c1URI, string c2URI, float val, string unequalproof, OMA proof)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.TruncatedVolumeCone),
new List<MMTTerm> {
new OMS(c1URI),
new OMS(c2URI),
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
proof,
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(val);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Cid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label + _Facts[this.Cid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Cid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(TruncatedConeVolumeFact f1, TruncatedConeVolumeFact f2)
{
if (f1.Cid1 == f2.Cid1 && f1.Cid2 == f2.Cid2)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
CircleFact c2f1 = (CircleFact)_Facts[f1.Cid2];
CircleFact c2f2 = (CircleFact)_Facts[f2.Cid2];
return (c1f1.Equivalent(c1f2) && c2f1.Equivalent(c2f2) && (Mathf.Abs(f1.vol - f2.vol) < 0.001) );
/// <summary>
/// The volume of a cylinder defined by a base area <see cref="CircleFact">CircleFact</see>, a top area <see cref="CircleFact">CircleFact</see> and the volume as float
/// </summary>
public class CylinderVolumeFact : FactWrappedCRTP<CylinderVolumeFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "CylinderVolumeFact";
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
public string Cid1;
/// <summary> a <see cref="CircleFact">CircleFact</see> describing the top area </summary>
public string Cid2;
/// <summary> the volume of the cylinder as a float </summary>
public float vol;
/// <summary> a proof that both circles have the same size </summary>
public string equalCirclesProof;
/// <summary> OMA proof that the two circles are parallel </summary>
public OMA proof;
/// <summary> \copydoc Fact.Fact </summary>
public CylinderVolumeFact() : base()
{
this.Cid1 = null;
this.Cid2 = null;
this.vol = 0.0f;
this.proof = null;
this.equalCirclesProof = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public CylinderVolumeFact(CylinderVolumeFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Cid2], fact.vol, old_to_new[fact.equalCirclesProof], fact.proof);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public CylinderVolumeFact(string cid1, string cid2, float vol, string eqProof, OMA proof, FactOrganizer organizer) : base(organizer)
init(cid1, cid2, vol, eqProof, proof);
}
/// <summary>
/// sets variables and generates MMT Declaration
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="vol">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
private void init(string cid1, string cid2, float vol, string eqProof, OMA proof)
{
this.Cid1 = cid1;
this.Cid2 = cid2;
this.proof = proof;
this.equalCirclesProof = eqProof;
CircleFact cf1 = _Facts[cid1] as CircleFact;
CircleFact cf2 = _Facts[cid2] as CircleFact;
EqualCirclesFact pf1 = _Facts[eqProof] as EqualCirclesFact;
this.vol = vol;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string c2URI = cf2.Id;
mmtDecl = generateMMTDeclaration(c1URI, c2URI, vol,p1Uri, proof);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Cid2">sets <see cref="Cid2"/></param>
/// <param name="volume">sets <see cref="vol"/></param>
/// <param name="proof">sets <see cref="proof"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public CylinderVolumeFact(string Cid1, string Cid2, float volume, string eqProof, OMA proof, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Cid2 = Cid2;
this.vol = volume;
this.proof = proof;
this.equalCirclesProof = eqProof;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static CylinderVolumeFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
string Circle1Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri;
string Circle2Uri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri;
float volume = ((OMF)((Scroll.ScrollValueFact)fact).value).f;
string EqualCirclesProof = ((OMS)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[2])).uri;
OMA proof = (OMA)(((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[3]);
if (StageStatic.stage.factState.ContainsKey(Circle1Uri) && StageStatic.stage.factState.ContainsKey(Circle2Uri))
return new CylinderVolumeFact(Circle1Uri, Circle2Uri, volume, EqualCirclesProof, proof, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "V(" + _Facts[Cid1].Label + "," + _Facts[Cid2].Label + ")";
}
/// <summary>
/// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
/// <param name="c2URI"> Uri for <see cref="Cid2"/></param>
/// <param name="val"> <see cref="vol"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateMMTDeclaration(string c1URI, string c2URI, float val, string p1URI, OMA proof)
{
MMTTerm lhs =
new OMA(
new OMS(MMTURIs.CylinderVolume),
new List<MMTTerm> {
new OMS(c1URI),
new OMS(c2URI),
proof,
}
);
MMTTerm valueTp = new OMS(MMTURIs.RealLit);
MMTTerm value = new OMF(val);
return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Cid2, equalCirclesProof };
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label + _Facts[this.Cid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
/// uhhh is this a problem?
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Cid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(CylinderVolumeFact f1, CylinderVolumeFact f2)
{
if (f1.Cid1 == f2.Cid1 && f1.Cid2 == f2.Cid2)
return true;
CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
CircleFact c2f1 = (CircleFact)_Facts[f1.Cid2];
CircleFact c2f2 = (CircleFact)_Facts[f2.Cid2];
return (c1f1.Equivalent(c1f2) && c2f1.Equivalent(c2f2) && (Mathf.Abs(f1.vol - f2.vol) < 0.001) );
}
}
/// <summary>
/// A fact that describes, that two circles have the same size and is comprised of two <see cref="CircleFact">CircleFacts</see>
/// </summary>
public class EqualCirclesFact : FactWrappedCRTP<EqualCirclesFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "EqualCirclesFact";
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
/// @{ <summary>
/// two circles that are meant to be equal in area
/// </summary>
public string Cid1, Cid2;
/// @}
/// <summary> \copydoc Fact.Fact </summary>
public EqualCirclesFact() : base()
{
this.Cid1 = null;
this.Cid2 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public EqualCirclesFact(EqualCirclesFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Cid2]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public EqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : base(organizer)
{
init(cid1, cid2);
}
/// <summary>
/// Initiates <see cref="Cid1"/>, <see cref="Cid2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
private void init(string cid1, string cid2)
{
this.Cid1 = cid1;
this.Cid2 = cid2;
CircleFact cf1 = _Facts[cid1] as CircleFact;
CircleFact cf2 = _Facts[cid2] as CircleFact;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string c2URI = cf2.Id;
mmtDecl = generateEqualCirclesFactDeclaration(c1URI, c2URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Cid2">sets <see cref="Cid2"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public EqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Cid2 = Cid2;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static EqualCirclesFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string circleAUri = "";
string circleBUri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA parallel_circles_OMA = (OMA)proof_OMA.arguments[0]; // parallel
if (parallel_circles_OMA.arguments[0] is OMS)
{
// Normaler Fall
circleAUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
circleBUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
}
if (StageStatic.stage.factState.ContainsKey(circleAUri)
&& StageStatic.stage.factState.ContainsKey(circleBUri))
return new EqualCirclesFact(circleAUri, circleBUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Cid1].Label + " ≠ " + _Facts[Cid2].Label;
}
/// <summary>
/// Constructs struct for equalCirclesFact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"><see cref="Cid1"/></param>
/// <param name="c2URI"><see cref="Cid2"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateEqualCirclesFactDeclaration(string c1URI, string c2URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(c1URI),
new OMS(c2URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.EqualityCircles), innerArguments)
};
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
return mmtDecl;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Cid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Cid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(EqualCirclesFact f1, EqualCirclesFact f2)
{
if ((f1.Cid1 == f2.Cid1 && f1.Cid2 == f2.Cid2))
return true;
CircleFact e1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact e2f1 = (CircleFact)_Facts[f1.Cid2];
CircleFact e1f2 = (CircleFact)_Facts[f2.Cid1];
CircleFact e2f2 = (CircleFact)_Facts[f2.Cid2];
return (e1f1.Equivalent(e1f2) && e2f1.Equivalent(e2f2));
}
}
/// <summary>
/// A fact that describes, that two circles have not the same size and is comprised of two <see cref="CircleFact">CircleFacts</see>
/// </summary>
public class UnEqualCirclesFact : FactWrappedCRTP<UnEqualCirclesFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "UnEqualCirclesFact";
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
/// @{ <summary>
/// two circles that are meant to be unequal in area
/// </summary>
public string Cid1, Cid2;
/// @}
/// <summary> \copydoc Fact.Fact </summary>
public UnEqualCirclesFact() : base()
{
this.Cid1 = null;
this.Cid2 = null;
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public UnEqualCirclesFact(UnEqualCirclesFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init(old_to_new[fact.Cid1], old_to_new[fact.Cid2]);
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public UnEqualCirclesFact(string cid1, string cid2, FactOrganizer organizer) : base(organizer)
{
init(cid1, cid2);
}
/// <summary>
/// Initiates <see cref="Cid1"/>, <see cref="Cid2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="cid1">sets <see cref="Cid1"/></param>
/// <param name="cid2">sets <see cref="Cid2"/></param>
private void init(string cid1, string cid2)
{
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
this.Cid1 = cid1;
this.Cid2 = cid2;
CircleFact cf1 = _Facts[cid1] as CircleFact;
CircleFact cf2 = _Facts[cid2] as CircleFact;
MMTDeclaration mmtDecl;
string c1URI = cf1.Id;
string c2URI = cf2.Id;
mmtDecl = generateUnEqualCirclesFactDeclaration(c1URI, c2URI);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Cid1">sets <see cref="Cid1"/></param>
/// <param name="Cid2">sets <see cref="Cid2"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public UnEqualCirclesFact(string Cid1, string Cid2, string backendURI, FactOrganizer organizer) : base(organizer)
{
this.Cid1 = Cid1;
this.Cid2 = Cid2;
this._URI = backendURI;
_ = this.Label;
}
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static UnEqualCirclesFact parseFact(Scroll.ScrollFact fact)
{
OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
if (tp == null)
return null;
string circleAUri = "";
string circleBUri = "";
string uri = fact.@ref.uri;
OMA proof_OMA = (OMA)((Scroll.ScrollSymbolFact)fact).tp; // proof DED
OMA unequal_circles_OMA = (OMA)proof_OMA.arguments[0]; // unequal
if (unequal_circles_OMA.arguments[0] is OMS)
{
// Normaler Fall
circleAUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
circleBUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
}
if (StageStatic.stage.factState.ContainsKey(circleAUri)
&& StageStatic.stage.factState.ContainsKey(circleBUri))
return new UnEqualCirclesFact(circleAUri, circleBUri, uri, StageStatic.stage.factState);
else //If dependent facts do not exist return null
return null;
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return _Facts[Cid1].Label + " = " + _Facts[Cid2].Label;
}
/// <summary>
/// Constructs struct for equalCirclesFact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="c1URI"><see cref="Cid1"/></param>
/// <param name="c2URI"><see cref="Cid2"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateUnEqualCirclesFactDeclaration(string c1URI, string c2URI)
{
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(c1URI),
new OMS(c2URI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.UnEqualityCircles), innerArguments)
};
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
return mmtDecl;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return true;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { Cid1, Cid2 };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return this.Cid1.GetHashCode() ^ this.Cid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(UnEqualCirclesFact f1, UnEqualCirclesFact f2)
{
if ((f1.Cid1 == f2.Cid1 && f1.Cid2 == f2.Cid2))
return true;
CircleFact e1f1 = (CircleFact)_Facts[f1.Cid1];
CircleFact e2f1 = (CircleFact)_Facts[f1.Cid2];
CircleFact e1f2 = (CircleFact)_Facts[f2.Cid1];
CircleFact e2f2 = (CircleFact)_Facts[f2.Cid2];
return (e1f1.Equivalent(e1f2) && e2f1.Equivalent(e2f2));
}
}
/// TEST FACT
/// use this if you need to test certain implementations of facts.
/// </summary>
public class TestFact : FactWrappedCRTP<TestFact>
{
/// \copydoc Fact.s_type
[JsonProperty]
protected static new string s_type = "TestFact";
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
/// <summary> \copydoc Fact.Fact </summary>
public TestFact() : base()
{
}
/// <summary>
/// Copies <paramref name="fact"/> by initiating new MMT %Fact.
/// </summary>
/// <param name="fact">Fact to be copied</param>
/// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
/// <param name="organizer">sets <see cref="_Facts"/></param>
public TestFact(TestFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
{
init();
}
/// <summary>
/// Standard Constructor
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public TestFact( FactOrganizer organizer) : base(organizer)
{
init();
}
/// <summary>
/// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="radius"/>,<see cref="dir1"/>,<see cref="dir2"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
/// </summary>
/// <param name="pid1">sets <see cref="Pid1"/></param>
/// <param name="pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
private void init()
{
// mmtDecl = generateCircleFactDeclaration(p1URI, p2URI, radius, normal);
// AddFactResponse.sendAdd(mmtDecl, out this._URI);
}
/// <summary>
/// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
/// </summary>
/// <param name="Pid1">sets <see cref="Pid1"/></param>
/// <param name="Pid2">sets <see cref="Pid2"/></param>
/// <param name="radius">sets <see cref="radius"/></param>
/// <param name="normal">sets <see cref="normal"/></param>
/// <param name="backendURI">MMT URI</param>
/// <param name="organizer">sets <see cref="Fact._Facts"/></param>
public TestFact( string backendURI, FactOrganizer organizer) : base(organizer)
{
this._URI = backendURI;
_ = this.Label;
}
/// <summary>
/// parses the Circlefact response of the MMT-Server
/// </summary>
/// \copydoc Fact.parseFact(Scroll.ScrollFact)
public new static TestFact parseFact(Scroll.ScrollFact fact)
{
string uri = fact.@ref.uri;
Debug.Log("TestFact Uri:" + uri);
return new TestFact(uri, StageStatic.stage.factState);
}
/// \copydoc Fact.generateLabel
protected override string generateLabel()
{
return "test" ;
}
/// <summary>
/// Constructs struct for right-angled MMT %Fact <see cref="AddFactResponse"/>
/// </summary>
/// <param name="p1URI"> <see cref="Pid1"/></param>
/// <param name="p2URI"> <see cref="Pid2"/></param>
/// <param name="radius"> <see cref="radius"/></param>
/// <returns>struct for <see cref="AddFactResponse"/></returns>
private MMTDeclaration generateCircleFactDeclaration(string p1URI, string p2URI, float radius, Vector3 normal)
{
PointFact p1 = _Facts[p1URI] as PointFact;
PointFact p2 = _Facts[p2URI] as PointFact;
List<MMTTerm> normalArgs = new List<MMTTerm>
{
new OMF(normal.x),
new OMF(normal.y),
new OMF(normal.z)
};
OMA NormalVector = new OMA(new OMS(MMTURIs.Tuple), normalArgs);
List<MMTTerm> planeArgs = new List<MMTTerm>
{
new OMS(p2URI),
NormalVector //n
};
OMA CirclePlane = new OMA(new OMS(MMTURIs.pointNormalPlane), planeArgs);
OMS middlePoint = new OMS(p1URI);
OMF Radius = new OMF(radius);
List<MMTTerm> outerArguments = new List<MMTTerm>
{
CirclePlane,
middlePoint,
Radius
};
//OMS constructor generates full URI
// Do i need this here? doubt
MMTTerm tp = new OMS(MMTURIs.CircleType3d);
MMTTerm df = new OMA(new OMS(MMTURIs.MkCircle3d), outerArguments);
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
AddFactResponse.sendAdd(mmtDecl, out this._URI);
return mmtDecl;
}
/// \copydoc Fact.hasDependentFacts
public override Boolean hasDependentFacts()
{
return false;
}
/// \copydoc Fact.getDependentFactIds
public override string[] getDependentFactIds()
{
return new string[] { };
}
/// \copydoc Fact.instantiateDisplay(GameObject, Transform)
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
// obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid2].Label;
obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
/// \copydoc Fact.GetHashCode
public override int GetHashCode()
{
return 112315414;// this.Pid1.GetHashCode() ^ this.Pid2.GetHashCode();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(TestFact f1, TestFact f2)
{
return false;