public CapsuleCache(Capsule c) { capsule = c; Vec2 d = c.p1 - c.p0; length = d.Len(); invLength = Mathf.TryInvertPositive(length, out circle); normal = d.Rot90() * invLength; center = Vec2.Lerp(0.5f, c.p0, c.p1); }
private static ClosestPoints CollideCircles(CapsuleCache c0, CapsuleCache c1) { Vec2 dir = c1.center - c0.center; float dist = dir.Len(); return(new ClosestPoints( point0: c0.center, point1: c1.center, normal: dir.SafeDivPositive(dist), distance: dist - c0.capsule.radius - c1.capsule.radius )); }