sphereParticle method
bool
sphereParticle(
- Sphere sj,
- Particle si,
- Vec3 xj,
- Vec3 xi,
- Quaternion qj,
- Quaternion qi,
- Body bj,
- Body bi, [
- Shape? rsi,
- Shape? rsj,
- bool justTest = false,
])
Implementation
bool sphereParticle(
Sphere sj,
Particle si,
Vec3 xj,
Vec3 xi,
Quaternion qj,
Quaternion qi,
Body bj,
Body bi,
[
Shape? rsi,
Shape? rsj,
bool justTest = false
]){
// The normal is the unit vector from sphere center to particle center
final normal = _particleSphereNormal;
normal.set(0, 0, 1);
xi.vsub(xj, normal);
final lengthSquared = normal.lengthSquared();
if (lengthSquared <= sj.radius * sj.radius) {
if (justTest) {
return true;
}
final r = createContactEquation(bi, bj, si, sj, rsi, rsj);
normal.normalize();
r.rj.copy(normal);
r.rj.scale(sj.radius, r.rj);
r.ni.copy(normal); // Contact normal
r.ni.negate(r.ni);
r.ri.set(0, 0, 0); // Center of particle
result.add(r);
createFrictionEquationsFromContact(r, frictionResult);
}
return false;
}