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


Python Vector.project_to方法代码示例

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


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

示例1: test_vector_projections

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import project_to [as 别名]
def test_vector_projections():
    """Quiz 5 projecting vectors"""
    vector1 = Vector([3.039, 1.879])
    vector2 = Vector([0.825, 2.036])
    answer1 = Vector([1.083, 2.672]).round_coords(3)

    projected_vector1 = vector1.project_to(vector2).round_coords(3)

    assert projected_vector1 == answer1

    vector3 = Vector([-9.88, -3.264, -8.159])
    vector4 = Vector([-2.155, -9.353, -9.473])
    answer2 = Vector([-8.350, 3.376, -1.434]).round_coords(3)

    orthogonal_vector1 = vector3.orthogonal_component(vector4).round_coords(3)
    assert orthogonal_vector1 == answer2

    vector5 = Vector([3.009, -6.172, 3.692, -2.51]).round_coords(3)
    vector6 = Vector([6.404, -9.144, 2.759, 8.718])
    answer3 = Vector([1.969, -2.811, 0.848, 2.680]).round_coords(3)
    answer4 = Vector([1.040, -3.361, 2.844, -5.190]).round_coords(3)

    projected_vector2 = vector5.project_to(vector6).round_coords(3)
    orthogonal_vector2 = vector5.orthogonal_component(vector6).round_coords(3)
    sum_vector = projected_vector2 + orthogonal_vector2

    assert projected_vector2 == answer3
    assert orthogonal_vector2 == answer4
    assert sum_vector == vector5
开发者ID:madhavajay,项目名称:ud953,代码行数:31,代码来源:udacity_test.py

示例2: test_projection

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import project_to [as 别名]
def test_projection():
    """Test the resultant Vector from projecting one vector onto another"""
    vector1 = Vector([2, 1])
    vector2 = Vector([0.825, 2.036])
    answer = Vector([0.630, 1.555]).round_coords(3)

    projected_vector = vector1.project_to(vector2).round_coords(3)
    assert projected_vector == answer
开发者ID:madhavajay,项目名称:ud953,代码行数:10,代码来源:vector_test.py

示例3: test_component_vectors

# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import project_to [as 别名]
def test_component_vectors():
    """Test the component Vectors of a Vector given the Baseline Vector"""
    vector1 = Vector([2, 1]).round_coords(3)
    vector2 = Vector([0.825, 2.036])
    answer = Vector([2, 1]).round_coords(3)

    projected_vector = vector1.project_to(vector2)
    orthogonal_vector = vector1.orthogonal_component(vector2)
    sum_components = projected_vector + orthogonal_vector

    assert sum_components == answer
开发者ID:madhavajay,项目名称:ud953,代码行数:13,代码来源:vector_test.py


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