summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runpath3d.in
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/runpath3d.in')
-rw-r--r--Build/source/utils/asymptote/runpath3d.in59
1 files changed, 58 insertions, 1 deletions
diff --git a/Build/source/utils/asymptote/runpath3d.in b/Build/source/utils/asymptote/runpath3d.in
index f4e355d838f..74c337748f7 100644
--- a/Build/source/utils/asymptote/runpath3d.in
+++ b/Build/source/utils/asymptote/runpath3d.in
@@ -17,6 +17,7 @@ triplearray2* => tripleArray2()
#include "path3.h"
#include "array.h"
#include "drawsurface.h"
+#include "predicates.h"
using namespace camp;
using namespace vm;
@@ -262,6 +263,25 @@ realarray2* intersections(path3 p, path3 q, real fuzz=-1)
return V;
}
+realarray* intersect(path3 p, triplearray2 *P, real fuzz=-1)
+{
+ triple *A;
+ copyArray2C(A,P,true,4);
+ if(fuzz <= 0) fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
+ norm(A,16));
+ std::vector<real> T,U,V;
+ bool found=intersections(T,U,V,p,A,fuzz,true);
+ delete[] A;
+ if(found) {
+ array *W=new array(3);
+ (*W)[0]=T[0];
+ (*W)[1]=U[0];
+ (*W)[2]=V[0];
+ return W;
+ } else
+ return new array(0);
+}
+
realarray2* intersections(path3 p, triplearray2 *P, real fuzz=-1)
{
triple *A;
@@ -269,7 +289,7 @@ realarray2* intersections(path3 p, triplearray2 *P, real fuzz=-1)
if(fuzz <= 0) fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
norm(A,16));
std::vector<real> T,U,V;
- intersections(T,U,V,p,A,fuzz);
+ intersections(T,U,V,p,A,fuzz,false);
delete[] A;
size_t n=T.size();
array *W=new array(n);
@@ -337,3 +357,40 @@ pair maxratio(path3 g)
{
return g.ratio(::max);
}
+
+// Return a negative (positive) value if a--b--c--cycle is oriented
+// counterclockwise (clockwise) when viewed from d or zero if all four
+// points are coplanar.
+// The value returned is the determinant
+// |a.x a.y a.z 1|
+// |b.x b.y b.z 1|
+// |c.x c.y c.z 1|
+// |d.x d.y d.z 1|
+real orient(triple a, triple b, triple c, triple d)
+{
+ real A[]={a.getx(),a.gety(),a.getz()};
+ real B[]={b.getx(),b.gety(),b.getz()};
+ real C[]={c.getx(),c.gety(),c.getz()};
+ real D[]={d.getx(),d.gety(),d.getz()};
+ return orient3d(A,B,C,D);
+}
+
+// Return a positive (negative) value if e lies inside (outside)
+// the sphere passing through the points a,b,c,d oriented so that
+// a--b--c--cycle appears in clockwise order when viewed from d
+// or zero if all five points are cospherical.
+// The value returned is the determinant
+// |a.x a.y a.z a.x^2+a.y^2+a.z^2 1|
+// |b.x b.y b.z b.x^2+b.y^2+b.z^2 1|
+// |c.x c.y c.z c.x^2+c.y^2+c.z^2 1|
+// |d.x d.y d.z d.x^2+d.y^2+d.z^2 1|
+// |e.x e.y e.z e.x^2+e.y^2+e.z^2 1|
+real insphere(triple a, triple b, triple c, triple d, triple e)
+{
+ real A[]={a.getx(),a.gety(),a.getz()};
+ real B[]={b.getx(),b.gety(),b.getz()};
+ real C[]={c.getx(),c.gety(),c.getz()};
+ real D[]={d.getx(),d.gety(),d.getz()};
+ real E[]={e.getx(),e.gety(),e.getz()};
+ return insphere(A,B,C,D,E);
+}