sphereSphere method
bool
sphereSphere(
- Sphere si,
- Sphere sj,
- Vector3 xi,
- Vector3 xj,
- Quaternion qi,
- Quaternion qj,
- Body bi,
- Body bj, [
- Shape? rsi,
- Shape? rsj,
- bool justTest = false,
])
Implementation
bool sphereSphere(
Sphere si,
Sphere sj,
Vector3 xi,
Vector3 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.sub2(xi, contactEq.ni);
contactEq.ni.normalize();
// Contact point locations
contactEq.ri.setFrom(contactEq.ni);
contactEq.rj.setFrom(contactEq.ni);
contactEq.ri.scale2(si.radius, contactEq.ri);
contactEq.rj.scale2(-sj.radius, contactEq.rj);
contactEq.ri.add2(xi, contactEq.ri);
contactEq.ri.sub2(bi.position, contactEq.ri);
contactEq.rj.add2(xj, contactEq.rj);
contactEq.rj.sub2(bj.position, contactEq.rj);
result.add(contactEq);
createFrictionEquationsFromContact(contactEq, frictionResult);
return false;
}