、、、の3 つの形状クラスCircle
がありSquare
、ConvexPolygon
関数があります。
bool ShapesIntersect(const Circle& s1, const Circle& s2);
bool ShapesIntersect(const Circle& s1, const Square& s2);
// ... and the other 7 combinations
多態的な関数が欲しい
Matrix<bool> ComputeShapeIntersectionMatrix(
const vector<Shape>& shapes1,
const vector<Shape>& shapes2);
上記の形状固有のメソッドを呼び出して、交差のマトリックスを埋めます。
C ++でこれを正確に行うことは不可能だと思いますが、交差行列を計算するコードを変更せずに新しい形状タイプを追加できる限り、他のソリューションで問題ありません。