// CORRECTNESS: not calculating tangents across closed rotoPaths Vec2f AbstractPath::tangent(const int i) const { assert(i>=0 && i<getNumElements()); if (_tangents) return _tangents[i]; Vec2f U; if (i==0) Vec2f_Sub(U,getElement(1), getElement(0)); else if (i==getNumElements()-1) Vec2f_Sub(U,getElement(getNumElements()-1), getElement(getNumElements()-2)); else { Vec2f_Sub(U,getElement(i+1), getElement(i-1)); } U.Normalize(); return U; }
Bboxf2D DrawPath::calcBbox() const { Bboxf2D bbox; for (int i = 0; i < getNumElements(); i++) { Bboxf2D currBox; Vec2f currLoc = getElement(i), extLoc, thick(_thick.getElement(i), _thick.getElement(i)); Vec2f_Sub(extLoc, currLoc, thick); currBox.includePoint(extLoc); Vec2f_Add(extLoc, currLoc, thick); currBox.includePoint(extLoc); bbox.setToUnion(currBox); } return bbox; }