Esempio n. 1
0
    def get_active_regions(self, look_dir, fovy_in_degrees, aspect):
        '''
        Computes the data necessary to determine which regions on the screen
        are active.  This should be produced once per frame and passed to
        the getDataForActiveRegions method of all SkyRegionMap objects to
        get the active regions for each map.
        
        lookDir The direction the user is currently facing.
        fovyInDegrees The field of view (in degrees).
        aspect The aspect ratio of the screen.
        Returns a data object containing data for quickly determining the
        active regions.
        '''
        half_fovy = degrees_to_radians(fovy_in_degrees) / 2.0
        screen_angle = math.asin(math.sin(half_fovy) * math.sqrt(1 + aspect * aspect))
        angle_threshold = screen_angle + self.REGION_COVERAGE_ANGLE_IN_RADIANS
        dot_product_threshold = math.cos(angle_threshold)
        region_center_dot_products = [0] * len(self.REGION_CENTERS32)
        active_standard_regions = []
        
        i = 0
        for i in range(len(self.REGION_CENTERS32)):
            d_product = dot_product(look_dir, self.REGION_CENTERS32[i])
            region_center_dot_products[i] = d_product

            if d_product > dot_product_threshold:
                active_standard_regions.append(i)
            
        return ActiveRegionData(region_center_dot_products, \
                                screen_angle, active_standard_regions)
Esempio n. 2
0
    def get_active_regions(self, look_dir, fovy_in_degrees, aspect):
        '''
        Computes the data necessary to determine which regions on the screen
        are active.  This should be produced once per frame and passed to
        the getDataForActiveRegions method of all SkyRegionMap objects to
        get the active regions for each map.
        
        lookDir The direction the user is currently facing.
        fovyInDegrees The field of view (in degrees).
        aspect The aspect ratio of the screen.
        Returns a data object containing data for quickly determining the
        active regions.
        '''
        half_fovy = degrees_to_radians(fovy_in_degrees) / 2.0
        screen_angle = math.asin(
            math.sin(half_fovy) * math.sqrt(1 + aspect * aspect))
        angle_threshold = screen_angle + self.REGION_COVERAGE_ANGLE_IN_RADIANS
        dot_product_threshold = math.cos(angle_threshold)
        region_center_dot_products = [0] * len(self.REGION_CENTERS32)
        active_standard_regions = []

        i = 0
        for i in range(len(self.REGION_CENTERS32)):
            d_product = dot_product(look_dir, self.REGION_CENTERS32[i])
            region_center_dot_products[i] = d_product

            if d_product > dot_product_threshold:
                active_standard_regions.append(i)

        return ActiveRegionData(region_center_dot_products, \
                                screen_angle, active_standard_regions)
Esempio n. 3
0
 def get_object_region_data(self, gc_coords):
     '''
     returns the region a point belongs in, as well as the dot product of the
     region center and the position.  The latter is a measure of how close it
     is to the center of the region (1 being a perfect match).
     '''
     data = self.ObjectRegionData()
     
     i = 0
     for i in range(len(self.REGION_CENTERS32)):
         d_product = dot_product(self.REGION_CENTERS32[i], gc_coords)
         
         if d_product > data.region_center_dot_product:
             data.region_center_dot_product = d_product
             data.region = i
         
     return data
Esempio n. 4
0
    def get_object_region_data(self, gc_coords):
        '''
        returns the region a point belongs in, as well as the dot product of the
        region center and the position.  The latter is a measure of how close it
        is to the center of the region (1 being a perfect match).
        '''
        data = self.ObjectRegionData()

        i = 0
        for i in range(len(self.REGION_CENTERS32)):
            d_product = dot_product(self.REGION_CENTERS32[i], gc_coords)

            if d_product > data.region_center_dot_product:
                data.region_center_dot_product = d_product
                data.region = i

        return data