sphereSphere method
bool
sphereSphere(
- Sphere si,
- Sphere sj,
- Vec3 xi,
- Vec3 xj,
- Quaternion qi,
- Quaternion qj,
- Body bi,
- Body bj, [
- Shape? rsi,
- Shape? rsj,
- bool justTest = false,
])
Implementation
bool sphereSphere(
Sphere si,
Sphere sj,
Vec3 xi,
Vec3 xj,
Quaternion qi,
Quaternion qj,
Body bi,
Body bj,
[
Shape? rsi,
Shape? rsj,
bool justTest = false
]){
if (justTest) {
return xi.distanceSquared(xj) < math.pow((si.radius + sj.radius),2);
}
// We will have only one contact in this case
final contactEq = createContactEquation(bi, bj, si, sj, rsi, rsj);
// Contact normal
xj.vsub(xi, contactEq.ni);
contactEq.ni.normalize();
// Contact point locations
contactEq.ri.copy(contactEq.ni);
contactEq.rj.copy(contactEq.ni);
contactEq.ri.scale(si.radius, contactEq.ri);
contactEq.rj.scale(-sj.radius, contactEq.rj);
contactEq.ri.vadd(xi, contactEq.ri);
contactEq.ri.vsub(bi.position, contactEq.ri);
contactEq.rj.vadd(xj, contactEq.rj);
contactEq.rj.vsub(bj.position, contactEq.rj);
result.add(contactEq);
createFrictionEquationsFromContact(contactEq, frictionResult);
return false;
}