lib/Manifold.js
function clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {
  // Start with no output points
  var numOut = 0;

  // Calculate the distance of end points to the line
  var distance0 = Vec2.dot(normal, vIn[0].v) - offset;
  var distance1 = Vec2.dot(normal, vIn[1].v) - offset;

  // If the points are behind the plane
  if (distance0 <= 0.0)
    vOut[numOut++].set(vIn[0]);
  if (distance1 <= 0.0)
    vOut[numOut++].set(vIn[1]);

  // If the points are on different sides of the plane
  if (distance0 * distance1 < 0.0) {
    // Find intersection point of edge and plane
    var interp = distance0 / (distance0 - distance1);
    vOut[numOut].v.setCombine(1 - interp, vIn[0].v, interp, vIn[1].v);

    // VertexA is hitting edgeB.
    vOut[numOut].id.cf.indexA = vertexIndexA;
    vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;
    vOut[numOut].id.cf.typeA = Manifold.e_vertex;
    vOut[numOut].id.cf.typeB = Manifold.e_face;
    ++numOut;
  }

  return numOut;
}
function clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {
  // Start with no output points
  var numOut = 0;

  // Calculate the distance of end points to the line
  var distance0 = Vec2.dot(normal, vIn[0].v) - offset;
  var distance1 = Vec2.dot(normal, vIn[1].v) - offset;

  // If the points are behind the plane
  if (distance0 <= 0.0)
    vOut[numOut++].set(vIn[0]);
  if (distance1 <= 0.0)
    vOut[numOut++].set(vIn[1]);

  // If the points are on different sides of the plane
  if (distance0 * distance1 < 0.0) {
    // Find intersection point of edge and plane
    var interp = distance0 / (distance0 - distance1);
    vOut[numOut].v.setCombine(1 - interp, vIn[0].v, interp, vIn[1].v);

    // VertexA is hitting edgeB.
    vOut[numOut].id.cf.indexA = vertexIndexA;
    vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;
    vOut[numOut].id.cf.typeA = Manifold.e_vertex;
    vOut[numOut].id.cf.typeB = Manifold.e_face;
    ++numOut;
  }

  return numOut;
}
function clipSegmentToLine ( vOut , vIn , normal , offset , vertexIndexA ) { // Start with no output points var numOut = 0 ; // Calculate the distance of end points to the line var distance0 = Vec2 . dot ( normal , vIn [ 0 ] . v ) - offset ; var distance1 = Vec2 . dot ( normal , vIn [ 1 ] . v ) - offset ; // If the points are behind the plane if ( distance0 <= 0.0 ) vOut [ numOut ++ ] . set ( vIn [ 0 ] ) ; if ( distance1 <= 0.0 ) vOut [ numOut ++ ] . set ( vIn [ 1 ] ) ; // If the points are on different sides of the plane if ( distance0 * distance1 < 0.0 ) { // Find intersection point of edge and plane var interp = distance0 / ( distance0 - distance1 ) ; vOut [ numOut ] . v . setCombine ( 1 - interp , vIn [ 0 ] . v , interp , vIn [ 1 ] . v ) ; // VertexA is hitting edgeB. vOut [ numOut ] . id . cf . indexA = vertexIndexA ; vOut [ numOut ] . id . cf . indexB = vIn [ 0 ] . id . cf . indexB ; vOut [ numOut ] . id . cf . typeA = Manifold . e_vertex ; vOut [ numOut ] . id . cf . typeB = Manifold . e_face ; ++ numOut ; } return numOut ; }
Clipping for contact manifolds. Sutherland-Hodgman clipping.

@param {ClipVertex[2]} vOut
@param {ClipVertex[2]} vIn
Clipping for contact manifolds . Sutherland - Hodgman clipping .