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


Python Vector.angleBetween方法代码示例

本文整理汇总了Python中vector.Vector.angleBetween方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.angleBetween方法的具体用法?Python Vector.angleBetween怎么用?Python Vector.angleBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vector.Vector的用法示例。


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

示例1: test_angle_between_with_zero_vector

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angleBetween [as 别名]
    def test_angle_between_with_zero_vector(self):
        v1 = Vector([1,2,-1])
        v2 = Vector([0,0,0])

        with self.assertRaises(Exception) as context:
            v1.angleBetween(v2)

        self.assertTrue('Cannot calculate the angle between using a zero vector' in str(context.exception))
开发者ID:aenfield,项目名称:UdacityLinearAlgebra,代码行数:10,代码来源:vector_test.py

示例2: test_angle_between

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angleBetween [as 别名]
    def test_angle_between(self):
        v1 = Vector([1,2,-1])
        v2 = Vector([3,1,0])

        self.assertEqual(v1.angleBetween(v2), 0.869122203007293)
        self.assertEqual(v1.angleBetween(v2, degrees=True), 49.797034113430236)
开发者ID:aenfield,项目名称:UdacityLinearAlgebra,代码行数:8,代码来源:vector_test.py

示例3: estimateOrientations

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angleBetween [as 别名]
    def estimateOrientations(self, bucket_classifications,  estimated_positions):

        combinations = self.colorCombinations()
        estimated_orientations = {}
        # for c in combinations:
        #     estimated_orientations[c] = None, None

        for key, center in estimated_positions.iteritems():
            if center is None:
                estimated_orientations[key] = None
                continue
            side_color, main_color = key
            support_color = self.opposingColor(main_color)


            support_orientation_vector = None
            final_vector = None

            if self.previous_orientations[key].full():
                support_orientation_vector = self.previous_orientations[key].getLeft()

            # bucket_index = self.findBucket(buckets, bucket_classifications, key, num_buckets)
            # if bucket_index == -1:
            #     final_vector = support_orientation_vector
            #     self.updateOrientations(estimated_orientations, final_vector, key)
            #     continue

            bucket_key = bucket_classifications[key]
            if bucket_key is None:
                final_vector = support_orientation_vector
                self.updateOrientations(estimated_orientations, final_vector, key)
                continue


            for bucket_center, bucket_color in bucket_key:
                if bucket_color == support_color:
                    support_orientation_vector = Vector.getDirectionVector( bucket_center, center, 1 )
                    support_orientation_vector.rotate(math.radians(215))

            if support_orientation_vector is None:
                final_vector = None
                self.updateOrientations(estimated_orientations, final_vector, key)
                continue

            centers_main_color = [ x for (x, c) in bucket_key if c == main_color ]
            centers_len = len(centers_main_color)

            midpoints_main_color = []
            for i in range(centers_len - 1):
                for j in range(i+1, centers_len):
                    center_i = centers_main_color[i]
                    center_j = centers_main_color[j]
                    midpoints_main_color.append( meanPoint([center_i, center_j]) )

            dvs_main_color = [ Vector.getDirectionVector(x, center, 10) for x in midpoints_main_color]
            dvs_len = len(dvs_main_color)

            if dvs_len < 2:
                final_vector = support_orientation_vector
                self.updateOrientations(estimated_orientations, final_vector, key)
                continue



            angle_min = 999999
            vector_min = None
            for v in dvs_main_color:

                if support_orientation_vector.toPoint() == (0, 0) or v.toPoint() == (0,0):
                    self.updateOrientations(estimated_orientations, None, key)
                    continue

                angle_tmp = abs(Vector.angleBetween(support_orientation_vector, v))
                if angle_tmp < angle_min:
                    angle_min = angle_tmp
                    vector_min = v

            angle_check = abs(Vector.angleBetween(vector_min, support_orientation_vector))
            if angle_check < 20:
                final_vector = vector_min
            else:
                final_vector = support_orientation_vector

            self.updateOrientations(estimated_orientations, final_vector, key)
            self.previous_orientations[key].insert(final_vector)

        return estimated_orientations
开发者ID:pbsinclair42,项目名称:SDP-2016,代码行数:89,代码来源:tracker.py


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