Check if three points are collinear or not. 1- Create two vectors AB and AC. 2- Get the cross vector of the two vectors. 3- Calculate the length of the cross vector. 4- If the length is zero then the points are collinear, else they are not. The use of the accuracy paramete
(a: Point3d, b: Point3d, c: Point3d, accuracy: int = 10)
| 94 | |
| 95 | |
| 96 | def are_collinear(a: Point3d, b: Point3d, c: Point3d, accuracy: int = 10) -> bool: |
| 97 | """ |
| 98 | Check if three points are collinear or not. |
| 99 | |
| 100 | 1- Create two vectors AB and AC. |
| 101 | 2- Get the cross vector of the two vectors. |
| 102 | 3- Calculate the length of the cross vector. |
| 103 | 4- If the length is zero then the points are collinear, else they are not. |
| 104 | |
| 105 | The use of the accuracy parameter is explained in is_zero_vector docstring. |
| 106 | |
| 107 | >>> are_collinear((4.802293498137402, 3.536233125455244, 0), |
| 108 | ... (-2.186788107953106, -9.24561398001649, 7.141509524846482), |
| 109 | ... (1.530169574640268, -2.447927606600034, 3.343487096469054)) |
| 110 | True |
| 111 | >>> are_collinear((-6, -2, 6), |
| 112 | ... (6.200213806439997, -4.930157614926678, -4.482371908289856), |
| 113 | ... (-4.085171149525941, -2.459889509029438, 4.354787180795383)) |
| 114 | True |
| 115 | >>> are_collinear((2.399001826862445, -2.452009976680793, 4.464656666157666), |
| 116 | ... (-3.682816335934376, 5.753788986533145, 9.490993909044244), |
| 117 | ... (1.962903518985307, 3.741415730125627, 7)) |
| 118 | False |
| 119 | >>> are_collinear((1.875375340689544, -7.268426006071538, 7.358196269835993), |
| 120 | ... (-3.546599383667157, -4.630005261513976, 3.208784032924246), |
| 121 | ... (-2.564606140206386, 3.937845170672183, 7)) |
| 122 | False |
| 123 | """ |
| 124 | ab = create_vector(a, b) |
| 125 | ac = create_vector(a, c) |
| 126 | return is_zero_vector(get_3d_vectors_cross(ab, ac), accuracy) |
nothing calls this directly
no test coverage detected