Add a distanceFromPoint method that works similar to distanceFromOrigin except that it takes a Point as a parameter and computes the distance between that point and self. For example, print(p.distanceFromPoint(q)) should print 5.0.
Add a distanceFromPoint method that works similar to distanceFromOrigin except that it takes a Point as a parameter and computes the distance between that point and self. For example, print(p.distanceFromPoint(q)) should print 5.0.
Add a method reflect_x to Point which returns a new Point, one which is the reflection of the point about the x-axis. For example, print(q.refect_x()) should print (-6, 7).
Add a method slope_from_origin which returns the slope of the line joining the origin to the point. For example, print(p.slope_from_origin()) should print 2.5 when p is (4, 10)
Add a method slope_from_origin which returns the slope of the line joining the origin to the point. For example, print(p.slope_from_origin()) should print 2.5 when p is (4, 10)
The equation of a straight line is βy = ax + bβ, (or perhaps βy = mx + cβ). The coefficients a and b completely describe the line. Write a method in the Point class so that if a point instance is given another point, it will compute the equation of the straight line joining the two points. It must return the two coefficients as a tuple of two values. For example,
Add a method called move that will take two parameters, call them dx and dy. The method will cause the point to move in the x and y direction the number of units given. (Hint: you will change the values of the state of the point). So for a point p at (7,6)p.move(5, 10) should change the x and y to (12,16)
Add a method called move that will take two parameters, call them dx and dy. The method will cause the point to move in the x and y direction the number of units given. (Hint: you will change the values of the state of the point). So for a point p at (7,6)p.move(5, 10) should change to (12,16)