Get the cross of the two vectors AB and AC. I used determinant of 2x2 to get the determinant of the 3x3 matrix in the process. Read More: https://en.wikipedia.org/wiki/Cross_product https://en.wikipedia.org/wiki/Determinant >>> get_3d_vectors_cross((3, 4, 7), (4,
(ab: Vector3d, ac: Vector3d)
| 50 | |
| 51 | |
| 52 | def get_3d_vectors_cross(ab: Vector3d, ac: Vector3d) -> Vector3d: |
| 53 | """ |
| 54 | Get the cross of the two vectors AB and AC. |
| 55 | |
| 56 | I used determinant of 2x2 to get the determinant of the 3x3 matrix in the process. |
| 57 | |
| 58 | Read More: |
| 59 | https://en.wikipedia.org/wiki/Cross_product |
| 60 | https://en.wikipedia.org/wiki/Determinant |
| 61 | |
| 62 | >>> get_3d_vectors_cross((3, 4, 7), (4, 9, 2)) |
| 63 | (-55, 22, 11) |
| 64 | >>> get_3d_vectors_cross((1, 1, 1), (1, 1, 1)) |
| 65 | (0, 0, 0) |
| 66 | >>> get_3d_vectors_cross((-4, 3, 0), (3, -9, -12)) |
| 67 | (-36, -48, 27) |
| 68 | >>> get_3d_vectors_cross((17.67, 4.7, 6.78), (-9.5, 4.78, -19.33)) |
| 69 | (-123.2594, 277.15110000000004, 129.11260000000001) |
| 70 | """ |
| 71 | x = ab[1] * ac[2] - ab[2] * ac[1] # *i |
| 72 | y = (ab[0] * ac[2] - ab[2] * ac[0]) * -1 # *j |
| 73 | z = ab[0] * ac[1] - ab[1] * ac[0] # *k |
| 74 | return (x, y, z) |
| 75 | |
| 76 | |
| 77 | def is_zero_vector(vector: Vector3d, accuracy: int) -> bool: |