Check if vector is equal to (0, 0, 0) or not. Since the algorithm is very accurate, we will never get a zero vector, so we need to round the vector axis, because we want a result that is either True or False. In other applications, we can return a float that represents the coll
(vector: Vector3d, accuracy: int)
| 75 | |
| 76 | |
| 77 | def is_zero_vector(vector: Vector3d, accuracy: int) -> bool: |
| 78 | """ |
| 79 | Check if vector is equal to (0, 0, 0) or not. |
| 80 | |
| 81 | Since the algorithm is very accurate, we will never get a zero vector, |
| 82 | so we need to round the vector axis, |
| 83 | because we want a result that is either True or False. |
| 84 | In other applications, we can return a float that represents the collinearity ratio. |
| 85 | |
| 86 | >>> is_zero_vector((0, 0, 0), accuracy=10) |
| 87 | True |
| 88 | >>> is_zero_vector((15, 74, 32), accuracy=10) |
| 89 | False |
| 90 | >>> is_zero_vector((-15, -74, -32), accuracy=10) |
| 91 | False |
| 92 | """ |
| 93 | return tuple(round(x, accuracy) for x in vector) == (0, 0, 0) |
| 94 | |
| 95 | |
| 96 | def are_collinear(a: Point3d, b: Point3d, c: Point3d, accuracy: int = 10) -> bool: |