putStartAndEndOn method

void putStartAndEndOn(
  1. Vector3 start,
  2. Vector3 end
)

Implementation

void putStartAndEndOn(
  Vector3 start,
  Vector3 end,
) {
  var currentStart = getStart();
  var currentEnd = getEnd();
  var currentVec = currentEnd - currentStart;

  if (currentStart == currentEnd) {
    throw 'Cannot position endpoints of a closed loop';
  }

  var targetVec = end - start;

  scaleUniformly(targetVec.norm() / currentVec.norm(),
      aboutPoint: currentStart);
  rotate(targetVec.angle() - currentVec.angle(), aboutPoint: currentStart);
  shift(start - currentStart);
}