本文整理汇总了Python中vector.Vector.orthogonal_component方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.orthogonal_component方法的具体用法?Python Vector.orthogonal_component怎么用?Python Vector.orthogonal_component使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.orthogonal_component方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vector_projections
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import orthogonal_component [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
示例2: test_orthogonal_component
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import orthogonal_component [as 别名]
def test_orthogonal_component():
"""Test the orthogonal component Vector of the Vector Projection"""
vector1 = Vector([2, 1])
vector2 = Vector([0.825, 2.036])
answer = Vector([1.370, -0.555]).round_coords(3)
orthogonal_vector = vector1.orthogonal_component(vector2).round_coords(3)
assert orthogonal_vector == answer
示例3: test_component_vectors
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import orthogonal_component [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