Question: . ( Particle Representation ) Define a data type called Blob in blob.py to represent a particle ( aka blob ) . The data type

.(Particle Representation) Define a data type called Blob in blob.py to represent a particle (aka blob). The data type must support the following API: Blob Blob() constructs an empty blob b b.add(x, y) adds a pixel (x, y) to b b.mass() b.distanceTo(c) str(b) returns the mass of b, ie, the number of pixels in it returns the Euclidean distance between the center of mass of b and the center of mass of blob c returns a string representation of b. Instance variables:- x-coordinate of center of mass, _x (float)- y-coordinate of center of mass, _y (float)- Number of pixels, _pixels (int) Blob()- Initialize the instance variables appropriately b.add(x, y)- Use the idea of running average1 to update the center of mass of blob b- Increment the number of pixels in blob b by 1 b.mass()- Return the number of pixels in the blob b b.distanceTo(c)- Return the Euclidean distance between the center of mass of blob b and the center of mass of blob c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!