public static bool IntersectSphereSphere(Sphere s1, Sphere s2, ref Distance_Query_Result res) { var vct = s2.Position - s1.Position; var dist = vct.Length(); dist -= (s1.Radius + s2.Radius); if (dist > 0) { return(false); } if (vct != Vector3.Zero) { vct.Normalize(); } var point = s2.Position - vct * s2.Radius; res.Normal_W = vct; res.first_has_normal = true; res.Point_W_0 = point; res.signed_distance = dist; res.first_has_normal = true; return(true); }
public static bool IntersectSphereSphere(Sphere s1, Sphere s2, ref Distance_Query_Result res) { var vct = s2.Position - s1.Position; var dist = vct.Length(); dist -= (s1.Radius + s2.Radius) ; if (dist > 0) return false; if(vct!=Vector3.Zero)vct.Normalize(); var point=s2.Position-vct*s2.Radius; res.Normal_W=vct; res.first_has_normal=true; res.Point_W_0=point; res.signed_distance=dist; res.first_has_normal=true; return true; }