title: Map coordinates of an area in Python
body: <p>A bit of a tricky question but I hope you can help me out.
  I've received a coding assignment and I'm having some trouble working my way around to a solution.</p>
  
  <p>The situation is this: suppose I have a weapon in coordinates (X,Y); When it fires, a sound damage function kicks in that affects people in close proximity to the gun. I need to write a function that will calculate - in accordance to the caliber being fired - whether or not a person (an instance of a Person class) is present in the dangerous area. The sound from the gun spreads out from a 45-degree angle and has a radius that changes in accordance to the caliber being fired (but is predetermined by me, so let's assume the radius equals to 5). 
  My explanation might be a little messy, so I'll try to organize it a little to make things clearer: I need to write a function that is called whenever a gun is being fired. The function needs to check whether or not a person is in dangerously close proximity to the gun being fired as if he is he will be inflicted with damage to his hearing (by a separate, pre-made function). The damage scales in accordance with the person's relative distance from the gun. The area is measured in a cone that spreads out the edge of the gun in a 45 degree angle in a random radius.</p>
  
  <p>I'm a little confused as to how to tackle this problem. I have already written a function that calculates the coordinates of each "Person". But I need a way to map out all the coordinates of the impact area so that I can a) tell whether the person should be affected by the sound-damage function and b) tell how badly he was hit (as the damage would be worse if he was standing 1 meter away from the gun as opposed to 4 meters away).</p>
  
  <p>Maybe I'm approaching the problem in a wrong way - I want to learn and am happy to listen to any suggestions. I'm no expert by any means and would love to maybe get some directions as to how to approach this problem in the most efficient way.</p>
  
  <p>Edit: The code I've written so far is the following:</p>
  
  <pre><code>class Soldier(object):
  def __init__(self):
      # Soldier ID is a randomly generated string including of 3 numbers.
      ID = str(int(random.random() * 1000))
      self.ID = ID
      # soldier's position is set by default to [0,0]
      self.position = [0,0]
  def getID(self):
      # gets the ID number (string) of the instance
      print (self.ID)
  def setPosition(self, position):
      # sets the position (a list) of the instance
      self.position = position
  def getPosition(self):
      # gets the position (list) of the instance
      print(self.position)
  
  def randomize_soldier_position(soldiersList):
  """
  Gets as input a list of instances of soldiers, and assigns a random location to each one of the instances.
  """
  for i in soldiersList:
      # for the values of X and Y we generate a random floating point number extending to 3 digits. 
      X = round((random.random() * 100), 3)
      Y = round((random.random()* 100), 3)
      # sets the [X,Y] values for each of the instances.
      i.setPosition([X,Y])
      print(i.position)
  </code></pre>
  
  <p>I haven't touched the code of the actual function I need to write as I have no idea where to even begin...</p>
  
  <p>Thanks in advance! :)</p>