-
Notifications
You must be signed in to change notification settings - Fork 1
/
entity.py
39 lines (29 loc) · 993 Bytes
/
entity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Name: Entity class
Project: UAV Obstacle Avoidance Using Q-Learning Techniques
Authors: Katherine Glasheen, Marc Gonzalez, Shayon Gupta,
Travis Hainsworth, Ramya Kanlapuli
Description: This class implements a generic physical object
in the simulation including basic physical attributes and
graphical representation.
"""
import math
class entity:
# Initializer function
def __init__(self, location):
# Initialize location in grid as list
self.location = location
# Return location
def get_location(self):
return self.location
# Set location
def set_location(self, new_location):
self.location = new_location if len(self.location) == len(new_location) else self.location
# Return distance of entity location from target
def distance(self, other):
magnitude = 0
# Assumes distance vectors are the same dimension
for i,j in zip(self.location, other):
# Get magnitude of difference vector
magnitude += pow(abs(i-j),2)
return math.sqrt(magnitude)