当前位置: 首页>>代码示例>>Python>>正文


Python lib.GeoMath类代码示例

本文整理汇总了Python中lib.GeoMath的典型用法代码示例。如果您正苦于以下问题:Python GeoMath类的具体用法?Python GeoMath怎么用?Python GeoMath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GeoMath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contain_bounding_box_3D

    def contain_bounding_box_3D(self, bounding_box):
        try:
            if not self.get_prim():
                raise Errors.CantBeNoneError("Prim cant be none", "We need a prim to calculate tbn some steps after")
        except Errors.CantBeNoneError as e:
            Errors.Error.display_exception(e)
            exit()

        inside = True
        if not self.get_rectangle_tangent_space():
            self.convert_3D_to_2D(self.get_prim())
        this_point_relative = self.get_tbn_class().get_point_which_is_relative()
        this_tbn_inverse_matrix = self.get_tbn_class().get_tbn_inverse()
        param_bounding_box_points_in_this_tangent_space = []
        for point in bounding_box.get_points_object_space():
            point_relative = GeoMath.vecSub(point, this_point_relative)
            point_tangent_space = this_tbn_inverse_matrix.mulPoint3ToMatrix3(point_relative)
            param_bounding_box_points_in_this_tangent_space.append(list(point_tangent_space))

        for point in param_bounding_box_points_in_this_tangent_space:
            logging.debug("Rectangle tangent space" + str(self.get_rectangle_tangent_space()))
            inside = GeoMath.pointInPoints(point, self.get_rectangle_tangent_space())
            if not inside:
                break
        return inside
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:25,代码来源:BoundingBox.py

示例2: do

 def do(self):
     #Start pathfinding with backtracking
     logging.debug("Start method do, class PathBackTracking")
     logging.debug("Group partially destroyed: %s", str([p.prim.number() for p in self.partDes]))
     logging.debug("Group totally destroyed: %s", str([p.prim.number() for p in self.totDes]))
     global TimeExecutionFirst
     global TimeExecutionCurrent
     global MAXTIMEFORALLPATHS
     count = 1
     pathAchieved = False
     TimeExecutionFirst = time.time()
     while(not pathAchieved and count < 2):
         self.max_iterations_exceeded = False
         path = []
         pathAchieved = False
         if(count == 1):
             refPrim = self.getBestPrimReference(self.firstPrim)
             angle = GeoMath.angleBetweenPointsByPrim(GeoMath.primBoundingBox(self.lastPrim.prim).center(), GeoMath.primBoundingBox(self.firstPrim.prim).center(), refPrim.prim)
             logging.debug("Main angle, which determine direction: %s", str(angle))
             self.clockWise = angle < 0
         else:
             self.clockWise = not self.clockWise
         path.append(self.firstPrim)
         pathAchieved = self.backTracking(self.firstPrim, path)
         count += 1
     self.path = path
     logging.debug("Last prim: %s, First prim: %s", str(self.lastPrim.prim.number()), str(self.firstPrim.prim.number()))
     if(pathAchieved):
         self.goodPath = True
         logging.debug("End method do, class PathBackTracking. State: good")
     else:
         self.goodPath = False
         logging.debug("End method do, class PathBackTracking. State: No path achieved")
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:33,代码来源:PathBackTracking.py

示例3: intersect_bounding_box_3D

    def intersect_bounding_box_3D(self, bounding_box, DISPLAY=False):
        try:
            if not self.get_prim():
                raise Errors.CantBeNoneError("Prim cant be none", "We need a prim to calculate tbn some steps after")
        except Errors.CantBeNoneError as e:
            Errors.Error.display_exception(e)
            exit()

        if not self.get_points_tangent_space():
            self.create_3D_to_2D_rectangle(self.get_prim())
        this_point_relative = self.get_tbn_class().get_point_which_is_relative()
        this_tbn_inverse_matrix = self.get_tbn_class().get_tbn_inverse()
        param_bounding_box_points_in_this_tangent_space = []
        for point in bounding_box.get_rectangle_object_space():
            point_relative = GeoMath.vecSub(point, this_point_relative)
            this_tbn_inverse_matrix.printAttributes()
            point_tangent_space = this_tbn_inverse_matrix.mulPoint3ToMatrix3(point_relative)
            param_bounding_box_points_in_this_tangent_space.append(point_tangent_space)
        intersections = GeoMath.getIntersectionsBetweenEdges2D(
            GeoMath.getEdgesFromPoints(self.get_rectangle_tangent_space()),
            GeoMath.getEdgesFromPoints(param_bounding_box_points_in_this_tangent_space),
        )
        if DISPLAY:
            # TEMP: exit
            1 / 0
            exit()
            for intersection in intersections:
                this_tbn_matrix = self.get_tbn_class().get_tbn()
                point_object_space = this_tbn_matrix.mulPoint3ToMatrix3(intersection)
                point_absolute = GeoMath.vecPlus(point_object_space, this_point_relative)
                self.to_display_intersections.append(point_absolute)
            self.display_intersections()
        return intersections
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:33,代码来源:BoundingBox.py

示例4: calculatePoints

    def calculatePoints(self):
        # Filter the points, first we get the undermost points, and then,
        # The point which less angle from z+ vector by y+ vector has.
        global epsilon
        vertices = [list(p.point().position()) for p in self.prim.vertices()]
        lessy = vertices[0][1]
        mayPoints = []
        for point in vertices:
            if((point[1] - epsilon) < lessy):
                mayPoints.append(point)
            if(point[1] < (lessy - epsilon)):
                lessy = point[1]
                mayPoints = [point]

        # We construct vectors from points to determine which is leftmost, so we delete 'y' component
        minAngle = 2 * math.pi + epsilon
        for point in mayPoints:
            vec = GeoMath.vecNormalize([point[0], 0, point[2]])
            angle = GeoMath.angleBetweenPointsByVec([0, 0, 1], vec, [0, 1, 0])
            if(angle < minAngle):
                minAngle = angle
                minPoint = point

        index = vertices.index(minPoint)
        previousPoint = vertices[index - 1]
        pointWhichIsRelative = minPoint
        nextPoint = vertices[(index + 1) % len(vertices)]

        self.set_previous_point(previousPoint)
        self.set_point_which_is_relative(pointWhichIsRelative)
        self.set_next_point(nextPoint)
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:31,代码来源:CreateTBN.py

示例5: findSomeGroupRecursively

 def findSomeGroupRecursively(self, prim, setNotDestroyed, setPartiallyDestroyed, setTotDestroyed):
     currentPartiallyDestroyed = list(setPartiallyDestroyed)
     '''
     h = HouInterface.HouInterface()
     h.showPoint(GeoMath.primBoundingBox(prim).center(), name='prim_' + str(prim.number()), color=[1, 0, 0])
     '''
     matchNotDes = prim in setNotDestroyed
     matchTotDes = prim in setTotDestroyed
     if(not matchNotDes):
         findInNotDestroyed = GeoMath.getConnectedPrims(prim, setNotDestroyed)
         matchNotDes = (findInNotDestroyed != [])
     if(not matchTotDes):
         findInTotDestroyed = GeoMath.getConnectedPrims(prim, setTotDestroyed)
         matchTotDes = (findInTotDestroyed != [])
     logging.debug("With prim %s, matchNotDes: %s, matchTotDes: %s", str(prim.number()), str(matchNotDes), str(matchTotDes))
     if(matchNotDes or matchTotDes):
         return matchNotDes, matchTotDes
     else:
         tempfind = []
         findInPartiallyDestroyed = GeoMath.getConnectedPrims(prim, currentPartiallyDestroyed)
         for primInPartiallyDestroyed in findInPartiallyDestroyed:
             if(primInPartiallyDestroyed not in self.path):
                 tempfind.append(primInPartiallyDestroyed)
         findInPartiallyDestroyed = list(tempfind)
         index = 0
         while(index < len(findInPartiallyDestroyed) and not matchNotDes and not matchTotDes):
             curPrim = findInPartiallyDestroyed[index]
             if(curPrim in currentPartiallyDestroyed):
                 logging.debug("with prim %s pass to %s", str(prim.number()), str(curPrim.number()))
                 currentPartiallyDestroyed.remove(curPrim)
                 matchNotDes, matchTotDes = self.findSomeGroupRecursively(curPrim, setNotDestroyed, currentPartiallyDestroyed, setTotDestroyed)
             index += 1
     return matchNotDes, matchTotDes
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:33,代码来源:ValidatePath.py

示例6: calculateDisplacement

 def calculateDisplacement(self, curEdge, nextEdge):
     """
         Edges are correlatives and in wise direction
     """
     curEdgeNor = GeoMath.vecSub(curEdge[1], curEdge[0])
     curEdgeNor = GeoMath.vecNormalize(curEdgeNor)
     nextEdgeNor = GeoMath.vecSub(nextEdge[1], nextEdge[0])
     nextEdgeNor = GeoMath.vecNormalize(nextEdgeNor)
     return GeoMath.vecSub(curEdgeNor, nextEdgeNor)
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:9,代码来源:PrimDivided.py

示例7: goToPrimPattern

    def goToPrimPattern(self, curPoint, nextPoint, pat, tbn, pointWhichIsRelative):
        '''
        TBN aplication
        '''
        global epsilon
        for num in range(len(pat.points)):
            pat.points[num] = tbn.mulPoint3ToMatrix3(pat.points[num])
            pat.points[num] = GeoMath.vecPlus(pointWhichIsRelative, pat.points[num])
        # Transform normal vector also
        logging.debug("Changing normal" + str(pat.getNormal()))
        transformed_normal = tbn.mulPoint3ToMatrix3(pat.getNormal())
        logging.debug("Transformed normal" + str(transformed_normal))
        normalized_normal = GeoMath.vecNormalize(transformed_normal)
        logging.debug("normalized normal" + str(normalized_normal))
        pat.setNormal(normalized_normal)
        logging.debug("normalized normal set?? " + str(pat.getNormal()))
        trans = GeoMath.vecSub(curPoint, pat.getFirstPoint())
        likelyPointF = GeoMath.vecPlus(pat.getLastPoint(), trans)
        if(GeoMath.vecModul(GeoMath.vecSub(likelyPointF, nextPoint)) > epsilon):
            trans = GeoMath.vecSub(curPoint, pat.getLastPoint())

        for num in range(len(pat.getPoints())):
            pat.points[num] = self.translatePointToPrim(pat.points[num], trans)

        if(GeoMath.vecModul(GeoMath.vecSub(likelyPointF, nextPoint)) > epsilon):
            pat.points.reverse()
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:26,代码来源:AutoPattern.py

示例8: display_on

 def display_on(self, name = 'floor', HI = None):
     if(not HI):
         HI = HouInterface.HouInterface()
     # Get the size of the floor using its points
     bounding_box = GeoMath.boundingBox(self.get_absolute_points())
     size = bounding_box.sizevec()
     # Put the size 'y' that user wants the floor to be
     size[1] = self.extract_parm_from_user_restrictions('floor_default_size_y')
     center = GeoMath.centerOfPoints(self.get_absolute_points())
     nodeName = HI.showCube(name, size, center)
     self.associate_nodes = HI.cubes[nodeName]
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:11,代码来源:floor.py

示例9: do

    def do(self):

        angleToSum = abs(GeoMath.angleBetweenPointsByPrim(GeoMath.primBoundingBox(self.curPrim.prim).center(), \
                         GeoMath.primBoundingBox(self.nextPrim.prim).center(), self.refPrim.prim))

        heuristic = self.curPrim.F + 1
        angle = self.curPrim.sumAngle + angleToSum
        logging.debug("Heuristic for prim %s with next prim %s and ref prim %s, angle to sum: %s", str(self.curPrim.prim.number()), str(self.nextPrim.prim.number()), str(self.refPrim.prim.number()), str(angle))
        self.nextPrim.setHeuristic(heuristic, 0)
        self.nextPrim.setSumAngle(angle)
        return self.nextPrim
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:11,代码来源:CalculateHeuristic.py

示例10: pointInTexture

    def pointInTexture(self, point):
        inside = None
        if(self.get_absolute_points_not_erasable()):
            inside = GeoMath.pointInPoints(point, self.get_absolute_points_not_erasable())
        elif(self.get_absolute_points()):
            inside = GeoMath.pointInPoints(point, self.get_absolute_points())

        if(inside == None):
            if(self.get_is_default_texture()):
                inside = True
        return inside
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:11,代码来源:Texture.py

示例11: intersect_bounding_box_with_limits_2D

 def intersect_bounding_box_with_limits_2D(self, bounding_box, DISPLAY=False):
     intersection = GeoMath.getIntersectionBetweenEdgesWithoutLimits2D(
         self.get_edges_object_space(), bounding_box.get_edges_object_edges(), 1
     )
     intersection_bool = intersection or GeoMath.getEdgesBetweenEdges(
         self.get_points_object_space(), bounding_box.get_points_object_space(), 1
     )
     if DISPLAY:
         # TEMP: exit
         1 / 0
         exit()
         self.to_display_intersections.append(intersection)
     return intersection_bool
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:13,代码来源:BoundingBox.py

示例12: getSimNormal

 def getSimNormal(self, pattern):
     horizontal = abs(GeoMath.vecDotProduct(pattern.getNormal(), [1, 0, 0]))
     vertical = abs(GeoMath.vecDotProduct(pattern.getNormal(), [0, 1, 0]))
     oblique = abs(GeoMath.vecDotProduct(pattern.getNormal(), [1, 0, 0]))
     if (horizontal > vertical and horizontal > oblique):
         # return vertical simetry
         return self.simN[1]
     if(vertical > horizontal and vertical > oblique):
         # return horizontal simetry
         return self.simN[0]
     if(oblique > horizontal and oblique > vertical):
         # return oblique simetry
         return self.simN[2]
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:13,代码来源:Data.py

示例13: getSimX

 def getSimX(self, pattern):
     horizontal = abs(GeoMath.vecDotProduct(pattern.getNormal(), [1, 0, 0]))
     vertical = abs(GeoMath.vecDotProduct(pattern.getNormal(), [0, 1, 0]))
     oblique = abs(GeoMath.vecDotProduct(pattern.getNormal(), [1, 0, 0]))
     if (horizontal > vertical and horizontal > oblique):
         # return vertical simetry, but how this is the x and normal... it will be false
         return self.simx[1]
     if(vertical > horizontal and vertical > oblique):
         # return horizontal
         return self.simx[0]
     if(oblique > horizontal and oblique > vertical):
         # return oblique simetry
         return self.simx[2]
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:13,代码来源:Data.py

示例14: calculate_windows_size

    def calculate_windows_size(self):
        global epsilon
        #=======================================================================
        # Get the insert node with windows
        #=======================================================================
        insert_windows = None
        for insert in self.get_inserts():
            for filter_group in insert.parm('filter').evalAsString().split():
                if(filter_group == self.extract_parm_from_user_restrictions('label_window')):
                    insert_windows = insert
                    break
        try:
            if(not insert_windows):
                logging.error('Class BuildingStructure, Label window not found at inserts')
                raise Errors.CantBeNoneError('Window cant be none',
                                             'Label window not found at inserts')
        except Errors.CantBeNoneError as e:
            Errors.Error.display_exception(e)
            exit()

        #=======================================================================
        # Get the size of the geometry of own window primitive
        #=======================================================================
        # We use the parent node because the insertnode has a cooked geometry
        # with windows inserteds.

        previous_node = insert_windows.inputs()[0]
        delete_node = previous_node.createOutputNode('delete')
        delete_node.parm('group').set(self.extract_parm_from_user_restrictions('label_window'))
        delete_node.parm('negate').set('keep')
        some_window = delete_node.geometry().prims()[0]
        window_points = [list(p.point().position()) for p in some_window.vertices()]
        window_bounding_box = GeoMath.boundingBox(window_points)
        window_size = [window_bounding_box.sizevec()[0], window_bounding_box.sizevec()[1]]
        return window_size
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:35,代码来源:buildingstructure.py

示例15: calculate_bounding_box_tangent_space

    def calculate_bounding_box_tangent_space(self):
        # Calculate bounding box in tangent space
        points_tangent_space = self.get_points_tangent_space()
        self.x_min_tangent = points_tangent_space[0][0]
        self.x_max_tangent = points_tangent_space[0][0]
        self.y_min_tangent = points_tangent_space[0][1]
        self.y_max_tangent = points_tangent_space[0][1]
        try:
            if not (
                self.x_max_tangent > 0 and self.y_max_tangent > 0 and self.x_min_tangent > 0 and self.y_min_tangent > 0
            ):
                raise Errors.NegativeValueError(
                    "Size cant be negtive",
                    "We need a positive size to do a" + " correct management of the size" + " after in other functions",
                )
        except Errors.NegativeValueError as e:
            Errors.Error.display_exception(e)
            # MAYFIX:Non negative values?
            # exit()
        for point in points_tangent_space:
            self.x_min_tangent = min(self.x_min_tangent, point[0])
            self.y_min_tangent = min(self.y_min_tangent, point[1])
            self.x_max_tangent = max(self.x_max_tangent, point[0])
            self.y_max_tangent = max(self.y_max_tangent, point[1])

        bounding_box_space_tangent_size = GeoMath.vecSub(
            [self.x_max_tangent, self.y_max_tangent, 0], [self.x_min_tangent, self.y_min_tangent, 0]
        )

        self.set_vector_size_tangent_space(bounding_box_space_tangent_size)
开发者ID:csoriano89,项目名称:BuildingDestruction,代码行数:30,代码来源:BoundingBox.py


注:本文中的lib.GeoMath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。