Skip to content
Snippets Groups Projects
Commit c0024627 authored by mariuskern's avatar mariuskern
Browse files

Facts

parent 148c56a9
No related branches found
No related tags found
No related merge requests found
......@@ -11,19 +11,17 @@
/// </summary>
public class CuboidFact : FactWrappedCRTP<CuboidFact>
{
//used points
public string PidR, PidT;
public Vector3 T;
public RectangleFact RF = null;
public float Volume = 0.0F;
[JsonIgnore] public Vector3 T;
[JsonIgnore] public RectangleFact RF = null;
[JsonIgnore] public float Volume = 0.0F;
public RectangleFact GetR {get => (RectangleFact)FactRecorder.AllFacts[PidR];}
public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
protected void calculate_vectors(){
[JsonIgnore] public RectangleFact GetR {get => (RectangleFact)FactRecorder.AllFacts[PidR];}
[JsonIgnore] public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
protected void calculate_vectors(){
/*
A = ((PointFact)FactRecorder.AllFacts[PidA]).Point + Vector3.zero;
B = ((PointFact)FactRecorder.AllFacts[PidB]).Point + Vector3.zero;
......@@ -66,16 +64,14 @@ protected void calculate_vectors(){
Vector3 up = Vector3.Cross(right, cross).normalized;
Rotation = Quaternion.LookRotation(cross, up);
}
public CuboidFact() : base(){
this.PidR = null;
this.PidT = null;
}
[JsonConstructor]
// [JsonConstructor]
public CuboidFact( string PidR, string PidT) : base()
{
......@@ -83,7 +79,6 @@ public CuboidFact( string PidR, string PidT) : base()
this.PidT = PidT;
calculate_vectors();
}
/// <summary>
......@@ -94,18 +89,12 @@ public CuboidFact( string PidR, string PidT) : base()
/// <param name="ServerDefinition">MMT URI as OMS</param>
public CuboidFact(string PidR, string PidT, SOMDoc ServerDefinition) : base()
{
this.PidR = PidR;
this.PidT = PidT;
this.ServerDefinition = ServerDefinition;
calculate_vectors();
}
/// \copydoc Fact.parseFact(ScrollFact)
......@@ -160,7 +149,7 @@ protected override bool EquivalentWrapped(CuboidFact f1, CuboidFact f2){
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new CuboidFact(this.PidR, this.PidT);
return new CuboidFact(old_to_new[this.PidR], old_to_new[this.PidT]);
}
......
......@@ -11,25 +11,22 @@
/// </summary>
public class CylinderFact : FactWrappedCRTP<CylinderFact>
{
//used points
public string PidM, PidE, PidT;
public Vector3 M, E, T;
public float Volume = 0.0F;
public float Radius = 0.0F;
public float Height = 0.0F;
[JsonIgnore] public Vector3 M, E, T;
[JsonIgnore] public float Volume = 0.0F;
[JsonIgnore] public float Radius = 0.0F;
[JsonIgnore] public float Height = 0.0F;
public PointFact GetM {get => (PointFact)FactRecorder.AllFacts[PidM];}
public PointFact GetE {get => (PointFact)FactRecorder.AllFacts[PidE];}
public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
[JsonIgnore] public PointFact GetM {get => (PointFact)FactRecorder.AllFacts[PidM];}
[JsonIgnore] public PointFact GetE {get => (PointFact)FactRecorder.AllFacts[PidE];}
[JsonIgnore] public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
protected void calculate_vectors(){
M = ((PointFact)FactRecorder.AllFacts[PidM]).Point + Vector3.zero;
E = ((PointFact)FactRecorder.AllFacts[PidE]).Point + Vector3.zero;
T = ((PointFact)FactRecorder.AllFacts[PidT]).Point + Vector3.zero;
M = GetM.Point + Vector3.zero;
E = GetE.Point + Vector3.zero;
T = GetT.Point + Vector3.zero;
//Rotation = Quaternion.LookRotation(forward, new Vector3(1.0F, 0.0F, 0.0F));
Position = T;
......@@ -44,8 +41,6 @@ protected void calculate_vectors(){
Rotation = Quaternion.LookRotation(rightvector, bottomnormal);
Volume = Mathf.PI * Radius * Radius * Height;
}
public CylinderFact() : base(){
......@@ -53,7 +48,8 @@ public CylinderFact() : base(){
this.PidE = null;
this.PidT = null;
}
[JsonConstructor]
// [JsonConstructor]
public CylinderFact( string PidM, string PidE, string PidT) : base()
{
this.PidM = PidM;
......@@ -96,8 +92,6 @@ public CylinderFact(string PidM, string PidE, string PidT, SOMDoc ServerDefiniti
string PidE = pointE.uri;
string PidT = pointT.uri;
ret.Add(new CylinderFact(PidM, PidE, PidT));
//ParsingDictionary.parseTermsToId.TryAdd(defines.ToString(), fact.@ref.uri);
......@@ -139,7 +133,7 @@ public bool isEqual(CylinderFact f2){
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new CylinderFact(this.PidM, this.PidE, this.PidT);
return new CylinderFact(old_to_new[this.PidM], old_to_new[this.PidE], old_to_new[this.PidT]);
}
......
......@@ -12,45 +12,40 @@
/// </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;
[JsonIgnore] public Vector3 A, B, C, a, b, c, D;
[JsonIgnore] public float cPosition;
[JsonIgnore] public float Volume = 0.0F;
[JsonIgnore] public TriangleFact2 GetT {get => (TriangleFact2)FactRecorder.AllFacts[PidT];}
[JsonIgnore] public PointFact GetD {get => (PointFact)FactRecorder.AllFacts[PidD];}
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;
A = GetT.A + Vector3.zero;
B = GetT.B + Vector3.zero;
C = GetT.C + Vector3.zero;
a = GetT.a + Vector3.zero;
b = GetT.b + Vector3.zero;
c = GetT.c + Vector3.zero;
D = GetD.Point + Vector3.zero;
cPosition = Vector3.Distance(A, c) / Vector3.Distance(A, B);
Volume = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Area * Vector3.Distance(A, D);
Volume = GetT.Area * Vector3.Distance(A, D);
Position = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Position;
Position = GetT.Position;
Rotation = ((TriangleFact2)FactRecorder.AllFacts[PidT]).Rotation;
Rotation = GetT.Rotation;
}
public PrismFact() : base(){
this.PidT = null;
this.PidD = null;
}
[JsonConstructor]
// [JsonConstructor]
public PrismFact( string PidT, string PidD) : base()
{
this.PidT = PidT;
......@@ -119,7 +114,7 @@ protected override bool EquivalentWrapped(PrismFact p1, PrismFact p2){
}
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new PrismFact(this.PidT, this.PidD);
return new PrismFact(old_to_new[this.PidT], old_to_new[this.PidD]);
}
public override MMTFact MakeMMTDeclaration()
......
......@@ -12,24 +12,18 @@
/// </summary>
public class PyramidFact : FactWrappedCRTP<PyramidFact>
{
//used points
public string PidR, PidD;
public Vector3 A, B, C, M, D, D_offset;
public float ab;
public float bc;
public float Volume = 0.0F;
[JsonIgnore] public Vector3 A, B, C, M, D, D_offset;
[JsonIgnore] public float ab;
[JsonIgnore] public float bc;
[JsonIgnore] public float Volume = 0.0F;
[JsonIgnore] public RectangleFact GetR {get => (RectangleFact)FactRecorder.AllFacts[PidR];}
[JsonIgnore] public PointFact GetD {get => (PointFact)FactRecorder.AllFacts[PidD];}
public RectangleFact GetR {get => (RectangleFact)FactRecorder.AllFacts[PidR];}
public PointFact GetD {get => (PointFact)FactRecorder.AllFacts[PidD];}
protected void calculate_vectors(){
A = GetR.A + Vector3.zero;
B = GetR.B + Vector3.zero;
C = GetR.C + Vector3.zero;
......@@ -69,7 +63,8 @@ public PyramidFact() : base(){
this.PidR = null;
this.PidD = null;
}
[JsonConstructor]
// [JsonConstructor]
public PyramidFact( string PidT, string PidD) : base()
{
this.PidR = PidT;
......@@ -138,7 +133,7 @@ protected override bool EquivalentWrapped(PyramidFact p1, PyramidFact p2){
}
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new PyramidFact(this.PidR, this.PidD);
return new PyramidFact(old_to_new[this.PidR], old_to_new[this.PidD]);
}
public override MMTFact MakeMMTDeclaration()
......
......@@ -11,25 +11,20 @@
/// </summary>
public class RectangleFact : FactWrappedCRTP<RectangleFact>
{
//used points
public string PidA, PidB, PidC;
public Vector3 A, B, C, D;
public float Area = 0.0F;
[JsonIgnore] public Vector3 A, B, C, D;
[JsonIgnore] public float Area = 0.0F;
[JsonIgnore] public PointFact GetA {get => (PointFact)FactRecorder.AllFacts[PidA];}
[JsonIgnore] public PointFact GetB {get => (PointFact)FactRecorder.AllFacts[PidB];}
[JsonIgnore] public PointFact GetC {get => (PointFact)FactRecorder.AllFacts[PidC];}
public PointFact GetA {get => (PointFact)FactRecorder.AllFacts[PidA];}
public PointFact GetB {get => (PointFact)FactRecorder.AllFacts[PidB];}
public PointFact GetC {get => (PointFact)FactRecorder.AllFacts[PidC];}
protected void calculate_vectors(){
A = ((PointFact)FactRecorder.AllFacts[PidA]).Point + Vector3.zero;
B = ((PointFact)FactRecorder.AllFacts[PidB]).Point + Vector3.zero;
C = ((PointFact)FactRecorder.AllFacts[PidC]).Point + Vector3.zero;
private void calculate_vectors(){
A = GetA.Point + Vector3.zero;
B = GetB.Point + Vector3.zero;
C = GetC.Point + Vector3.zero;
D = (A - B) + C;
Area = (Vector3.Distance(A, B) * Vector3.Distance(B, C));
......@@ -89,7 +84,8 @@ public RectangleFact() : base(){
this.PidB = null;
this.PidC = null;
}
[JsonConstructor]
// [JsonConstructor]
public RectangleFact( string PidA, string PidB, string PidC) : base()
{
this.PidA = PidA;
......@@ -176,7 +172,7 @@ public bool isEqual(RectangleFact f2){
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new RectangleFact(this.PidA, this.PidB, this.PidC);
return new RectangleFact(old_to_new[this.PidA], old_to_new[this.PidB], old_to_new[this.PidC]);
}
......
......@@ -11,26 +11,19 @@
/// </summary>
public class SphereFact : FactWrappedCRTP<SphereFact>
{
//used points
public string PidM, PidT;
public Vector3 M, T;
[JsonIgnore] public Vector3 M, T;
[JsonIgnore] public float Volume = 0.0F;
[JsonIgnore] public float Radius = 0.0F;
public float Volume = 0.0F;
public float Radius = 0.0F;
[JsonIgnore] public PointFact GetM {get => (PointFact)FactRecorder.AllFacts[PidM];}
[JsonIgnore] public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
public PointFact GetM {get => (PointFact)FactRecorder.AllFacts[PidM];}
public PointFact GetT {get => (PointFact)FactRecorder.AllFacts[PidT];}
protected void calculate_vectors(){
M = ((PointFact)FactRecorder.AllFacts[PidM]).Point + Vector3.zero;
T = ((PointFact)FactRecorder.AllFacts[PidT]).Point + Vector3.zero;
Debug.Log(M);
Debug.Log(T);
M = GetM.Point + Vector3.zero;
T = GetT.Point + Vector3.zero;
Radius = Vector3.Distance(M, T);
Volume = 4/3 * (Mathf.PI) * (Radius * Radius * Radius);
......@@ -41,14 +34,14 @@ protected void calculate_vectors(){
LocalScale = scale;
Position = M;
}
public SphereFact() : base(){
this.PidM = null;
this.PidT = null;
}
[JsonConstructor]
// [JsonConstructor]
public SphereFact( string PidM, string PidT) : base()
{
this.PidM = PidM;
......@@ -129,7 +122,7 @@ public bool isEqual(SphereFact f2){
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new SphereFact(this.PidM, this.PidT);
return new SphereFact(old_to_new[this.PidM], old_to_new[this.PidT]);
}
......
......@@ -16,22 +16,18 @@ public class TriangleFact2 : FactWrappedCRTP<TriangleFact2>
//used points
public string PidA, PidB, PidC;
public Vector3 A, B, C, a, b, c;
[JsonIgnore] public Vector3 A, B, C, a, b, c;
[JsonIgnore] public float cPosition;
[JsonIgnore] public float Area = 0.0F;
public float cPosition;
[JsonIgnore] public PointFact GetA {get => (PointFact)FactRecorder.AllFacts[PidA];}
[JsonIgnore] public PointFact GetB {get => (PointFact)FactRecorder.AllFacts[PidB];}
[JsonIgnore] public PointFact GetC {get => (PointFact)FactRecorder.AllFacts[PidC];}
public float Area = 0.0F;
public PointFact GetA {get => (PointFact)FactRecorder.AllFacts[PidA];}
public PointFact GetB {get => (PointFact)FactRecorder.AllFacts[PidB];}
public PointFact GetC {get => (PointFact)FactRecorder.AllFacts[PidC];}
protected void calculate_vectors(){
A = ((PointFact)FactRecorder.AllFacts[PidA]).Point + Vector3.zero;
B = ((PointFact)FactRecorder.AllFacts[PidB]).Point + Vector3.zero;
C = ((PointFact)FactRecorder.AllFacts[PidC]).Point + Vector3.zero;
A = GetA.Point + Vector3.zero;
B = GetB.Point + Vector3.zero;
C = GetC.Point + Vector3.zero;
a = B + Vector3.Project(A - B, C - B);
b = C + Vector3.Project(B - C, A - C);
c = A + Vector3.Project(C - A, B - A);
......@@ -110,7 +106,8 @@ public TriangleFact2() : base(){
this.PidB = null;
this.PidC = null;
}
[JsonConstructor]
// [JsonConstructor]
public TriangleFact2( string PidA, string PidB, string PidC) : base()
{
this.PidA = PidA;
......@@ -184,7 +181,7 @@ protected override bool EquivalentWrapped(TriangleFact2 t1, TriangleFact2 t2){
protected override Fact _ReInitializeMe(Dictionary<string, string> old_to_new){
return new TriangleFact2(this.PidA, this.PidB, this.PidC);
return new TriangleFact2(old_to_new[this.PidA], old_to_new[this.PidB], old_to_new[this.PidC]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment