MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / create_vector

Function create_vector

maths/points_are_collinear_3d.py:35–49  ·  view source on GitHub ↗

Pass two points to get the vector from them in the form (x, y, z). >>> create_vector((0, 0, 0), (1, 1, 1)) (1, 1, 1) >>> create_vector((45, 70, 24), (47, 32, 1)) (2, -38, -23) >>> create_vector((-14, -1, -8), (-7, 6, 4)) (7, 7, 12)

(end_point1: Point3d, end_point2: Point3d)

Source from the content-addressed store, hash-verified

33
34
35def create_vector(end_point1: Point3d, end_point2: Point3d) -> Vector3d:
36 """
37 Pass two points to get the vector from them in the form (x, y, z).
38
39 >>> create_vector((0, 0, 0), (1, 1, 1))
40 (1, 1, 1)
41 >>> create_vector((45, 70, 24), (47, 32, 1))
42 (2, -38, -23)
43 >>> create_vector((-14, -1, -8), (-7, 6, 4))
44 (7, 7, 12)
45 """
46 x = end_point2[0] - end_point1[0]
47 y = end_point2[1] - end_point1[1]
48 z = end_point2[2] - end_point1[2]
49 return (x, y, z)
50
51
52def get_3d_vectors_cross(ab: Vector3d, ac: Vector3d) -> Vector3d:

Callers 1

are_collinearFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected