Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using Newtonsoft.Json;
using REST_JSON_API;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
/// <summary>
/// Point in 3D Space
/// </summary>
public class PrismFact : FactWrappedCRTP<PrismFact>
{
//used points
public string PidT, PidD;
public Vector3 A, B, C, a, b, c, D;
public float cPosition;
public float Volume = 0.0F;
public TriangleFact2 GetT {get => (TriangleFact2)FactRecorder.AllFacts[PidT];}
public PointFact GetD {get => (PointFact)FactRecorder.AllFacts[PidD];}
protected void calculate_vectors(){
A = ((TriangleFact2)FactRecorder.AllFacts[PidT]).A + Vector3.zero;
B = ((TriangleFact2)FactRecorder.AllFacts[PidT]).B + Vector3.zero;
C = ((TriangleFact2)FactRecorder.AllFacts[PidT]).C + Vector3.zero;
a = ((TriangleFact2)FactRecorder.AllFacts[PidT]).a + Vector3.zero;
b = ((TriangleFact2)FactRecorder.AllFacts[PidT]).b + Vector3.zero;
c = ((TriangleFact2)FactRecorder.AllFacts[PidT]).c + Vector3.zero;
D = ((PointFact)FactRecorder.AllFacts[PidD]).Point + Vector3.zero;
cPosition = Vector3.Distance(A, c) / Vector3.Distance(A, B);
Volume = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Area * Vector3.Distance(A, D);
Position = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Position;
Rotation = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Rotation;
}
public PrismFact() : base(){
this.PidT = null;
this.PidD = null;
}
[JsonConstructor]
public PrismFact( string PidT, string PidD) : base()
{
this.PidT = PidT;
this.PidD = PidD;
calculate_vectors();
}
/// <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="Point">sets <see cref="Point"/></param>
/// <param name="ServerDefinition">MMT URI as OMS</param>
public PrismFact(string PidT, string PidD, SOMDoc ServerDefinition) : base()
{
this.PidT = PidT;
this.PidD = PidD;
this.ServerDefinition = ServerDefinition;
calculate_vectors();
}
/// \copydoc Fact.parseFact(ScrollFact)
public new static IEnumerator parseFact(List<Fact> ret, MMTFact fact)
{
if (((MMTGeneralFact)fact).defines is not OMA df)
yield break;
OMS triangleT, pointD;
triangleT = (OMS)df.arguments[0];
pointD = (OMS)df.arguments[1];
string PidT = triangleT.uri;
string PidD = pointD.uri;
ret.Add(new PrismFact(PidT, PidD));
//ParsingDictionary.parseTermsToId.TryAdd(defines.ToString(), fact.@ref.uri);
//ret.Add(new PointFact(SOMDoc.MakeVector3(defines), fact.@ref));
}
/// \copydoc Fact.hasDependentFacts
public override bool HasDependentFacts => true;
/// \copydoc Fact.getDependentFactIds
protected override string[] GetDependentFactIds()
=> new string[] { PidT, PidD};
/// \copydoc Fact.GetHashCode
/* public override int GetHashCode()
=> this.Point.GetHashCode();
*/
protected override void RecalculateTransform()
{
calculate_vectors();
}
/// \copydoc Fact.Equivalent(Fact, Fact)
protected override bool EquivalentWrapped(PrismFact p1, PrismFact p2){
return DependentFactsEquivalent(p1, p1);
}
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new PrismFact(this.PidT, this.PidD);
}
public override MMTFact MakeMMTDeclaration()
{
SOMDoc tp = new OMS(MMTConstants.PrismType);
return new MMTGeneralFact(_LastLabel, tp, Defines());
}
public override SOMDoc Defines()
=> new OMA(
new OMS(MMTConstants.PrismCons),
new[] {
new OMS(PidT),
new OMS(PidD),
}
);
}