2 using System.Collections.Generic;
5 using System.Threading.Tasks;
35 private readonly WorkingCopy<HalfEdge> _currentEdge;
36 private readonly
Vector _lBind;
37 private readonly
Vector _rBind;
39 private readonly
PointRef _transformedEndPoint;
44 _currentEdge = currentEdge;
49 _transformedEndPoint = transformedEndPoint;
54 get {
return CurrentEdge.Original.Facet; }
59 get {
return CurrentEdge.Original.Facet.Tag; }
64 get {
return _valid; }
69 get {
return _currentEdge; }
74 get {
return _lBind; }
79 get {
return _rBind; }
97 if (_transformedEndPoint != null)
99 var vectorToEnd =
new Vector(_transformedEndPoint.
Expr);
107 var oppPoint = CurrentEdge.Copy.Next.End;
108 var vectorToOpp =
new Vector(oppPoint.Expr);
110 var lCompare = VectorMath.SignedAngle(vectorToOpp,
LBind).CompareTo();
111 var rCompare = VectorMath.SignedAngle(vectorToOpp,
RBind).CompareTo();
113 if (lCompare == 0 || lCompare != rCompare)
122 if (lCompare.EqualsAny(0, 1))
124 var leftHE = CurrentEdge.Original.Prev.Opposite;
125 var newHE =
new WorkingCopy<HalfEdge>(leftHE, leftHE.FacetCloneWithOriginalOpposites);
127 IEnumerable<PointRef> newEndPoint = null;
130 if (newHE.Original.Facet == _cspf.
EndFacet)
132 newEndPoint =
new[] {_cspf.EndPoint.DeepClone};
134 newHE.Copy.Opposite = CurrentEdge.Copy.Prev;
135 newHE.Copy.Unfold(newEndPoint);
136 newHE.Copy.Opposite = CurrentEdge.Original.Prev;
138 var rBind = (rCompare > 0) ? vectorToOpp :
RBind;
140 PointRef endPoint = (newEndPoint != null) ? newEndPoint.First() : null;
148 transformedEndPoint: endPoint
152 if (rCompare.EqualsAny(0, -1))
154 var rightHE = CurrentEdge.Original.Next.Opposite;
155 var newHE =
new WorkingCopy<HalfEdge>(rightHE, rightHE.FacetCloneWithOriginalOpposites);
157 IEnumerable<PointRef> newEndPoint = null;
160 if (newHE.Original.Facet == _cspf.
EndFacet)
162 newEndPoint =
new[] { _cspf.EndPoint.DeepClone };
164 newHE.Copy.Opposite = CurrentEdge.Copy.Next;
165 newHE.Copy.Unfold(newEndPoint);
166 newHE.Copy.Opposite = CurrentEdge.Original.Next;
168 PointRef endPoint = (newEndPoint != null) ? newEndPoint.First() : null;
170 var lBind = (lCompare < 0) ? vectorToOpp :
LBind;
178 transformedEndPoint: endPoint
191 get {
return VectorMath.SignedAngle(
RBind,
LBind); }
211 return "Graphics3D[" +
ML[
"List"].Bracket(
212 ML[
"List"].Bracket(ChainToParents.Select(p => p.CurrentEdge.Copy.ForceNewFacet.Graphics)).Eval(),
216 ).Eval().ToString() +
"]";
221 static class VectorMath
223 public static Expr SignedAngle(Vector vector1, Vector vector2)
225 return "Sign[Dot[{{ -{0}[[2]], {0}[[1]], 0 }}, {1}]]*ArcCos[Dot[Normalize[{0}], Normalize[{1}]]]"
226 .MsEvalWith(vector1.Expr, vector2.Expr);
IEnumerable< VectorCone > ChainToParents
Expr Expr
Mathematica expression that represents a point in space
Holds a reference to a point in the form of a Mathematica expression
WorkingCopy< HalfEdge > CurrentEdge
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...
static Expr Origin
For testing use
VectorCone(VectorCone parent, WorkingCopy< HalfEdge > currentEdge, VectorCSPF cspf, Vector lBind, Vector rBind, PointRef transformedEndPoint)