triple accel(path3 p, Int t, Int sign=0)
{
return p.accel(t,sign);
}
triple accel(path3 p, real t)
{
return p.accel(t);
}
real radius(path3 p, real t)
{
triple v=p.dir(t,false);
triple a=p.accel(t);
real d=dot(a,v);
real v2=v.abs2();
real a2=a.abs2();
real denom=v2*a2-d*d;
real r=v2*sqrt(v2);
return denom > 0 ? r/sqrt(denom) : 0.0;
}
real radius(triple z0, triple c0, triple c1, triple z1, real t)
{
triple v=(3.0*(z1-z0)+9.0*(c0-c1))*t*t+(6.0*(z0+c1)-12.0*c0)*t+3.0*(c0-z0);
triple a=6.0*(z1-z0+3.0*(c0-c1))*t+6.0*(z0+c1)-12.0*c0;
real d=dot(a,v);
real v2=v.abs2();
real a2=a.abs2();
real denom=v2*a2-d*d;
real r=v2*sqrt(v2);
return denom > 0 ? r/sqrt(denom) : 0.0;
}
path3 reverse(path3 p)
{
return p.reverse();
}
path3 subpath(path3 p, Int a, Int b)
{
return p.subpath((Int) a, (Int) b);
}
path3 subpath(path3 p, real a, real b)
{
return p.subpath(a,b);
}
Int length(path3 p)
{
return p.length();
}
bool cyclic(path3 p)
{
return p.cyclic();
}
bool straight(path3 p, Int t)
{
return p.straight(t);
}
// return the maximum distance squared of points c0 and c1 from
// the respective internal control points of z0--z1.
real straightness(triple z0, triple c0, triple c1, triple z1)
{
return Straightness(z0,c0,c1,z1);
}
// return the straightness of segment i of path3 g.
real straightness(path3 p, Int t)
{
if(p.straight(t)) return 0;
return Straightness(p.point(t),p.postcontrol(t),p.precontrol(t+1),
p.point(t+1));
}
// 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);
}