Ejemplo n.º 1
0
    def find_hull(self, points):
        # Get the length of the list of points
        num_points = len(points)

        # Base case
        # If there is only 1 point, make a node for that point, make a hull using that node, and return the hull
        if num_points == 1:
            node = Node(points[0], None, None)
            node.next_node = node
            node.previous_node = node

            hull = Hull(node, node)

            return hull

        # Otherwise, if there is more than 1 point, split the list of points in half and find hulls for the left half
        # and the right half.  Once both hulls have been found, merge them
        # The time complexity is O(nlog(n)) because the points are split in half at each iteration, so there are log(n)
        # recursive calls, and merge_hulls is called at each recursive level, which runs in O(n) time.  So the
        # complexity is O(n) * O(log(n)), or O(nlog(n))
        # The space complexity is also O(nlog(n)), since there are log(n) recursive calls, and merge_hulls is called at
        # each recursive level, which has a space complexity of O(n).  So the complexity is O(n) * O(log(n)), or
        # O(nlog(n))
        else:
            mid = num_points // 2

            left_hull = self.find_hull(points[:mid])
            right_hull = self.find_hull(points[mid:])

            hull = self.merge_hulls(left_hull, right_hull)

            return hull
Ejemplo n.º 2
0
def STND(Vec, Avg_prd):
    STND_Vec = np.zeros((Vec.shape[0], ))
    Vec_Avg = Hull.HMA(Vec, Avg_prd)

    for ii in range(Avg_prd, Vec.shape[0]):
        STND_Vec[ii] = (Vec[ii] - Vec_Avg[ii]) / np.std((Vec[ii - Avg_prd:ii]))

    return STND_Vec
def BuildHulls(path):
    # top level structure for loading all necessary information
    HullData = list()
    for files in os.listdir(path):  # loading all xml files
        if files[len(files) - 3 : len(files)] != "xml":
            continue  # ascertain to only load xml files
        if files == "Hull.xml":
            HullLoaded = True
            xml = minidom.parse(path + "/" + files)  # read in Hull.xml
            HullList = xml.getElementsByTagName("Hull")  # read in Hull
            counter = 0
            for node in HullList:
                name = node.attributes["Name"].value
                if name.find("Terran") >= 0:
                    continue  # skip all UE racial hulls
                if name.find("Hissho") >= 0:
                    continue  # skip all Hissho racial hulls
                if name.find("Swarm") >= 0:
                    continue  # skip all Craver racial hulls
                if name.find("Emperor") >= 0:
                    continue  # skip all Sheredyn racial hulls
                if name.find("Sophon") >= 0:
                    continue  # skip all Sophon racial hulls
                if name.find("Horatio") >= 0:
                    continue  # skip all Horatio racial hulls
                if name.find("Sower") >= 0:
                    continue  # skip all Sower racial hulls
                if name.find("Amoeba") >= 0:
                    continue  # skip all Amoeba racial hulls
                if name.find("Resistance") >= 0:
                    continue  # skip all Pilgrm racial hulls
                if name.find("Automaton") >= 0:
                    continue  # skip all Automaton racial hulls
                if name.find("Harmony") >= 0:
                    continue  # skip all Harmony racial hulls
                if name.find("Vaulter") >= 0:
                    continue  # skip all Vaulter racial hulls
                if name.find("Pirates") >= 0:
                    continue  # skip all Pirate racial hulls
                HullData.append(Hull.struct())  # extend list of ROOT readable structs
                # enter all the values into the struct
                HullData[counter].Name = node.attributes["Name"].value
                HullData[counter].MaxHealth = node.attributes["MaxHealth"].value
                HullData[counter].Tonnage = node.attributes["MaxWeight"].value
                HullData[counter].MaxSpecialSlotWeight = node.attributes["MaxSpecialSlotWeight"].value
                HullData[counter].CommandPoint = node.attributes["CommandPoint"].value
                HullData[counter].Evade = node.attributes["Evade"].value
                HullData[counter].Weakness = node.attributes["HullWeakness"].value
                HullData[counter].EvasionDisorientation = node.attributes["EvasionDisorientation"].value
                HullData[counter].Cost = node.attributes["Cost"].value
                counter += 1  # get ready for the next entry
    if len(HullData) > 1:
        return HullData
    else:
        return -1
Ejemplo n.º 4
0
    def merge_hulls(self, left_hull, right_hull):
        # Find the upper and lower tangents (the tangents are tuples containing the 2 nodes the tangent goes through)
        upper_tangent = self.find_upper_tangent(left_hull.right_node,
                                                right_hull.left_node)
        lower_tangent = self.find_lower_tangent(left_hull.right_node,
                                                right_hull.left_node)

        # Set the upper tangent's left node's next node to the upper tangent's right node.  Then set the upper tangent's
        # right node's previous node to the upper tangent's left node
        upper_tangent[0].next_node = upper_tangent[1]
        upper_tangent[1].previous_node = upper_tangent[0]

        # Set the lower tangent's right node's next node to the lower tangent's left node.  Then set the lower tangent's
        # left node's previous node to the lower tangent's right node
        lower_tangent[1].next_node = lower_tangent[0]
        lower_tangent[0].previous_node = lower_tangent[1]

        # Once the proper node changes have been made, any other unimportant nodes will be garbage collected
        # We can now merge the hulls by creating a new hull that uses the left hull's left node and the right hull's
        # right node
        merged_hull = Hull(left_hull.left_node, right_hull.right_node)

        # Return the merged hull
        return merged_hull
Ejemplo n.º 5
0
'''
Created on Jan 31, 2013

@author: rlundquist3
'''
from Point import *
from Hull import *
import math

copy = Hull()
copy.append(3)
print copy