Homework assignment #1

Develop a new class Location that stores a location of an object in plane coordinates (x and y). These coordinates should both be floating point numbers. This class should have:

Please also write a function Distance() which is not a member of the class Location, but takes two arguments of the type const Location& and computes the distance between two given points. Let the function access the private data members of the class.

You should submit three files:

Needed analytical geometry:

  1. For two given points (x1, y1) and (x2, y2) the distance between them is:
    D = sqrt( (x1-x2)2 + (y1-y2)2)
    	  
  2. For given point (x, y), angle α and distance d (as shown on the picture)
    the new coordinates (xnew, ynew) are to be computed as
    xnew = x + d * cos(α)
    ynew = y + d * sin(α)
    	  
    Please note that your function takes the angle parameter in degrees, but the trigonometric functions in C++ takes angle in radians. Thus, you need to convert degrees to radians. In order to do that, we need to recall that 180o is exactly π. Thus
    	  α = angle/180 * π