Triangle constructor
Creates a Triangle by defining its three vertices.
Implementation
Triangle({required this.p1, required this.p2, required this.p3}) {
// A valid triangle must have a non-zero area.
// We check if the points are collinear using a determinant (cross product).
final crossProduct = (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
if (crossProduct == 0) {
throw ArgumentError('Impossible triangle: Points are collinear.');
}
}