2 using System.Collections.Generic;
5 using System.Threading.Tasks;
26 private readonly Dictionary<PointRef, LeaderBoardEntry> _leaderBoard
27 =
new Dictionary<PointRef, LeaderBoardEntry>();
40 var entry = _leaderBoard[vert];
41 if (vector.
Length.CompareTo(entry.Vector.Length) < 0)
43 if (entry.Cone != null)
45 entry.Cone.Invalidate();
55 var infinity =
new Vector(
"{Infinity,Infinity,Infinity}".MsEvalWith());
69 var startHEClone = StartHE.FacetCloneWithOriginalOpposites;
70 var startPointClone = StartPoint.DeepClone;
71 startHEClone.Anchor(
new[] {startPointClone});
72 var transVector =
new Vector(
ML[
"-{0}"].Format(startPointClone.Expr).Eval());
73 startHEClone.NegativeTranslate(transVector);
76 startHEClone.ForceNewFacet.Graphics,
80 var queue =
new Queue<VectorCone>();
82 var hePairs = StartHE.HEsFromHere
83 .NetZip(startHEClone.HEsFromHere, (o, c) =>
new WorkingCopy<HalfEdge>(o, c));
85 foreach (var pair
in hePairs)
87 var vectToStart = Vector.FromPoints(
PointRef.Origin, pair.Copy.Start.Expr);
96 if ((
bool)
ML[
"{0} == {1}"].Format(vectToStart.Expr,
"{0,0,0}").EvalObject())
100 if ((
bool)
ML[
"{0} == {1}"].Format(vectToEnd.Expr,
"{0,0,0}").EvalObject())
106 IEnumerable<PointRef> newEndPoint = null;
107 var newHE =
new WorkingCopy<HalfEdge>(pair.Original.Opposite,
108 pair.Original.Opposite.FacetCloneWithOriginalOpposites);
109 if (newHE.Original.Facet ==
EndFacet)
111 newEndPoint =
new[] {EndPoint.DeepClone};
113 newHE.Copy.Opposite = pair.Copy;
114 newHE.Copy.Unfold(newEndPoint);
115 newHE.Copy.Opposite = pair.Original;
116 PointRef endPoint = (newEndPoint != null) ? newEndPoint.First() : null;
125 transformedEndPoint: endPoint
131 while (queue.Count > 0)
134 if (loopNumber == 10)
139 var cone = queue.Dequeue();
141 if ((
bool)
ML[
"{0}[[3]] < -.0001 || {0}[[3]] > .0001"].Format(cone.CurrentEdge.Copy.Start.Expr).EvalObject())
143 throw new Exception(
"Relative source is not on plane");
148 var splitCones = cone.TryExtend();
151 if (splitCones.Left != null)
153 if ((
bool)
ML[
"{0} < {1}"]
154 .Format(cone.Aperture, splitCones.Left.Aperture)
157 Console.WriteLine(
"Child larger than parent");
159 queue.Enqueue(splitCones.Left);
161 if (splitCones.Right != null)
163 if ((
bool)
ML[
"{0} < {1}"]
164 .Format(cone.Aperture, splitCones.Right.Aperture)
167 Console.WriteLine(
"Child larger than parent");
169 queue.Enqueue(splitCones.Right);
172 return _leaderBoard[
EndPoint].Vector.Expr;
VectorCSPF(Polyhedron poly, HalfEdge startHe, Facet endFacet, PointRef start, PointRef end)
Expr ComputeShortestPath()
IEnumerable< HalfEdge > HalfEdges
Holds a reference to a point in the form of a Mathematica expression
The building blocks of a geometric model, a HalfEdge consists of a reference to a start and end point...
bool SeeIfConeHasShortestPath(VectorCone subject, Vector vector, PointRef vert)
Facets are little more than a link to a HalfEdge, but they provide a convenient interface for manipul...
A polyhedron! It contains a list of facets.
static Expr Origin
For testing use