find angle between two Vector (self, Vector) >>> Vector([3, 4, -1]).angle(Vector([2, -1, 1])) 1.4906464636572374 >>> Vector([3, 4, -1]).angle(Vector([2, -1, 1]), deg = True) 85.40775111366095 >>> Vector([3, 4, -1]).angle(Vector([2, -1])) Trac
(self, other: Vector, deg: bool = False)
| 173 | return math.sqrt(sum(squares)) |
| 174 | |
| 175 | def angle(self, other: Vector, deg: bool = False) -> float: |
| 176 | """ |
| 177 | find angle between two Vector (self, Vector) |
| 178 | |
| 179 | >>> Vector([3, 4, -1]).angle(Vector([2, -1, 1])) |
| 180 | 1.4906464636572374 |
| 181 | >>> Vector([3, 4, -1]).angle(Vector([2, -1, 1]), deg = True) |
| 182 | 85.40775111366095 |
| 183 | >>> Vector([3, 4, -1]).angle(Vector([2, -1])) |
| 184 | Traceback (most recent call last): |
| 185 | ... |
| 186 | Exception: invalid operand! |
| 187 | """ |
| 188 | num = self * other |
| 189 | den = self.euclidean_length() * other.euclidean_length() |
| 190 | if deg: |
| 191 | return math.degrees(math.acos(num / den)) |
| 192 | else: |
| 193 | return math.acos(num / den) |
| 194 | |
| 195 | |
| 196 | def zero_vector(dimension: int) -> Vector: |
no test coverage detected