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


Python Vector.angle_degrees方法代码示例

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


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

示例1: test_orthogonal_component

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angle_degrees [as 别名]
    def test_orthogonal_component(self):
        basis = Vector([-2.155, -9.353, -9.473])
        v = Vector([-9.88, -3.264, -8.159])
        self.assertVecEqual([-8.35, 3.376, -1.434], v.component_orthogonal_to(basis), 3)
        self.assertEquals(basis.angle_degrees(v.component_orthogonal_to(basis)), 90)

        basis = Vector([6.404, -9.144, 2.759, 8.718])
        v = Vector([3.009, -6.172, 3.692, -2.51])
        self.assertVecEqual([1.04, -3.361, 2.844, -5.19], v.component_orthogonal_to(basis), 3)
        self.assertEquals(basis.angle_degrees(v.component_orthogonal_to(basis)), 90)
开发者ID:calebpowell,项目名称:linear-algebra-py,代码行数:12,代码来源:test_vector.py

示例2: test_angle_in_degrees

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angle_degrees [as 别名]
    def test_angle_in_degrees(self):
        v = Vector([3.183, -7.627])
        w = Vector([-2.668, 5.319])

        self.assertEqual(round(v.angle_degrees(w), 2), 176.01)
        self.assertEqual(v.angle_degrees(w), w.angle_degrees(v))

        v = Vector([7.35, 0.221, 5.188])
        w = Vector([2.751, 8.259, 3.985])

        self.assertEqual(round(v.angle_degrees(w), 3), 60.276)
        self.assertEqual(v.angle_degrees(w), w.angle_degrees(v))
开发者ID:calebpowell,项目名称:linear-algebra-py,代码行数:14,代码来源:test_vector.py

示例3: test_dot_product_and_angle

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angle_degrees [as 别名]
def test_dot_product_and_angle():
    """Quiz 3 calculating the dot product and angle of two Vectors"""
    vector1 = Vector([7.887, 4.138])
    vector2 = Vector([-8.802, 6.776])
    answer1 = Decimal('-41.382')
    assert round(vector1.dot_product(vector2), 3) == answer1

    vector3 = Vector([-5.955, -4.904, -1.874])
    vector4 = Vector([-4.496, -8.755, 7.103])
    answer2 = Decimal('56.397')
    assert round(vector3.dot_product(vector4), 3) == answer2

    vector5 = Vector([3.183, -7.627])
    vector6 = Vector([-2.668, 5.319])
    answer3 = 3.072
    assert round(vector5.angle_radians(vector6), 3) == answer3

    vector7 = Vector([7.35, 0.221, 5.188])
    vector8 = Vector([2.751, 8.259, 3.985])
    answer4 = 60.276
    assert round(vector7.angle_degrees(vector8), 3) == answer4
开发者ID:madhavajay,项目名称:ud953,代码行数:23,代码来源:udacity_test.py

示例4: Vector

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import angle_degrees [as 别名]
v1 = Vector([-5.955, -4.904, -1.874])
v2 = Vector([-4.496, -8.755, 7.103])
print v1.dot_product(v2)

# Angles
v1 = Vector([3.183, -7.627])
v2 = Vector([-2.668, 5.319])
print ''
print 'Angle Radians'
print v1.angle_radians(v2)
print v1.angle_with(v2, False)
v1 = Vector([7.35, 0.221, 5.188])
v2 = Vector([2.751, 8.259, 3.985])
print ''
print 'Angle Degrees'
print v1.angle_degrees(v2)
print v1.angle_with(v2, True)

# Parallel & Orthogonal
print ''
print 'Parallel & Orthogonal'
v1 = Vector([-7.579, -7.88])
v2 = Vector([22.737, 23.64])
print v1
print v2
print 'Parallel: {}'.format(v1.parallel_with(v2))
print 'Orthogonal: {}'.format(v1.orthogonal_with(v2))
print ''
v1 = Vector([-2.029, 9.97, 4.172])
v2 = Vector([-9.231, -6.639, -7.245])
print v1
开发者ID:ehafenmaier,项目名称:twd-udacity-la-refresher,代码行数:33,代码来源:lesson.py


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