pair accel(path p, Int t, Int sign=0)
{
return p.accel(t,sign);
}
pair accel(path p, real t)
{
return p.accel(t);
}
real radius(path p, real t)
{
pair v=p.dir(t,false);
pair 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;
}
path reverse(path p)
{
return p.reverse();
}
path subpath(path p, Int a, Int b)
{
return p.subpath((Int) a, (Int) b);
}
path subpath(path p, real a, real b)
{
return p.subpath(a,b);
}
path nurb(pair z0, pair z1, pair z2, pair z3,
real w0, real w1, real w2, real w3, Int m)
{
return nurb(z0,z1,z2,z3,w0,w1,w2,w3,m);
}
Int length(path p)
{
return p.length();
}
bool cyclic(path p)
{
return p.cyclic();
}
bool straight(path p, Int t)
{
return p.straight(t);
}
// Return the intersection point of the extensions of the line segments
// PQ and pq.
pair extension(pair P, pair Q, pair p, pair q)
{
pair ac=P-Q;
pair bd=q-p;
real det=ac.getx()*bd.gety()-ac.gety()*bd.getx();
if(det == 0) return pair(infinity,infinity);
return P+((p.getx()-P.getx())*bd.gety()-(p.gety()-P.gety())*bd.getx())*ac/det;
}
path g = p->read<path *>(0)->transformed(t);
pair z = g.min();
double minx = z.getx(), miny = z.gety();
for (size_t i = 1; i < size; ++i) {
path g = p->read<path *>(i)->transformed(t);
pair z = g.min();
double x = z.getx(), y = z.gety();
if (x < minx)
minx = x;
if (y < miny)
miny = y;
}
path g = p->read<path *>(0)->transformed(t);
pair z = g.max();
double maxx = z.getx(), maxy = z.gety();
for (size_t i = 1; i < size; ++i) {
path g = p->read<path *>(i)->transformed(t);
pair z = g.max();
double x = z.getx(), y = z.gety();
if (x > maxx)
maxx = x;
if (y > maxy)
maxy = y;
}
// Return a positive (negative) value if a--b--c--cycle is oriented
// counterclockwise (clockwise) or zero if all three points are colinear.
// Equivalently, return a positive (negative) value if c lies to the
// left (right) of the line through a and b or zero if c lies on this line.
// The value returned is the determinant
// |a.x a.y 1|
// |b.x b.y 1|
// |c.x c.y 1|
//
real orient(pair a, pair b, pair c)
{
return orient2d(a,b,c);
}
// Return a positive (negative) value if d lies inside (outside)
// the circle passing through the counterclockwise-oriented points a,b,c
// or zero if d lies on this circle.
// The value returned is the determinant
// |a.x a.y a.x^2+a.y^2 1|
// |b.x b.y b.x^2+b.y^2 1|
// |c.x c.y c.x^2+c.y^2 1|
// |d.x d.y d.x^2+d.y^2 1|
real incircle(pair a, pair b, pair c, pair d)
{
return incircle(a.getx(),a.gety(),b.getx(),b.gety(),c.getx(),c.gety(),
d.getx(),d.gety());
}