public Sweep set(Sweep other) { localCenter.set(other.localCenter); c0.set(other.c0); c.set(other.c); a0 = other.a0; a = other.a; alpha0 = other.alpha0; return this; }
// TODO_ERIN might not need to return the separation public float initialize(SimplexCache cache, DistanceProxy proxyA, Sweep sweepA, DistanceProxy proxyB, Sweep sweepB, float t1) { m_proxyA = proxyA; m_proxyB = proxyB; int count = cache.count; Debug.Assert(0 < count && count < 3); m_sweepA = sweepA; m_sweepB = sweepB; m_sweepA.getTransform(xfa, t1); m_sweepB.getTransform(xfb, t1); // log.debug("initializing separation.\n" + // "cache: "+cache.count+"-"+cache.metric+"-"+cache.indexA+"-"+cache.indexB+"\n" // "distance: "+proxyA. if (count == 1) { m_type = TOIType.POINTS; /* * Vec2 localPointA = m_proxyA.GetVertex(cache.indexA[0]); Vec2 localPointB = * m_proxyB.GetVertex(cache.indexB[0]); Vec2 pointA = Mul(transformA, localPointA); Vec2 * pointB = Mul(transformB, localPointB); m_axis = pointB - pointA; m_axis.Normalize(); */ localPointA.set(m_proxyA.getVertex(cache.indexA[0])); localPointB.set(m_proxyB.getVertex(cache.indexB[0])); Transform.mulToOutUnsafe(xfa, localPointA, ref pointA); Transform.mulToOutUnsafe(xfb, localPointB, ref pointB); m_axis.set(pointB); m_axis.subLocal(pointA); float s = m_axis.normalize(); return s; } else if (cache.indexA[0] == cache.indexA[1]) { // Two points on B and one on A. m_type = TOIType.FACE_B; localPointB1.set(m_proxyB.getVertex(cache.indexB[0])); localPointB2.set(m_proxyB.getVertex(cache.indexB[1])); temp.set(localPointB2); temp.subLocal(localPointB1); Vec2.crossToOutUnsafe(temp, 1f, ref m_axis); m_axis.normalize(); Rot.mulToOutUnsafe(xfb.q, m_axis, ref normal); m_localPoint.set(localPointB1); m_localPoint.addLocal(localPointB2); m_localPoint.mulLocal(.5f); Transform.mulToOutUnsafe(xfb, m_localPoint, ref pointB); localPointA.set(proxyA.getVertex(cache.indexA[0])); Transform.mulToOutUnsafe(xfa, localPointA, ref pointA); temp.set(pointA); temp.subLocal(pointB); float s = Vec2.dot(temp, normal); if (s < 0.0f) { m_axis.negateLocal(); s = -s; } return s; } else { // Two points on A and one or two points on B. m_type = TOIType.FACE_A; localPointA1.set(m_proxyA.getVertex(cache.indexA[0])); localPointA2.set(m_proxyA.getVertex(cache.indexA[1])); temp.set(localPointA2); temp.subLocal(localPointA1); Vec2.crossToOutUnsafe(temp, 1.0f, ref m_axis); m_axis.normalize(); Rot.mulToOutUnsafe(xfa.q, m_axis, ref normal); m_localPoint.set(localPointA1); m_localPoint.addLocal(localPointA2); m_localPoint.mulLocal(.5f); Transform.mulToOutUnsafe(xfa, m_localPoint, ref pointA); localPointB.set(m_proxyB.getVertex(cache.indexB[0])); Transform.mulToOutUnsafe(xfb, localPointB, ref pointB); temp.set(pointB); temp.subLocal(pointA); float s = Vec2.dot(temp, normal); if (s < 0.0f) { m_axis.negateLocal(); s = -s; } return s; } }