Calculate the unit vector of a given 5D vector @param list vector: A 5D vector @return list: The 5D equivalent of the vector
(vector)
| 209 | |
| 210 | |
| 211 | def calculate_unit_vector(vector): |
| 212 | """ Calculate the unit vector of a given 5D vector |
| 213 | |
| 214 | @param list vector: A 5D vector |
| 215 | @return list: The 5D equivalent of the vector |
| 216 | """ |
| 217 | if len(vector) != 5: |
| 218 | raise makerbot_driver.errors.PointLengthError( |
| 219 | "Expected list of length 5, got length %i" % (len(vector))) |
| 220 | |
| 221 | magnitude = calculate_vector_magnitude(vector) |
| 222 | |
| 223 | # Check if this is a null vector |
| 224 | if magnitude == 0: |
| 225 | return [0, 0, 0, 0, 0] |
| 226 | |
| 227 | unitVector = [] |
| 228 | for val in vector: |
| 229 | unitVector.append(val / magnitude) |
| 230 | |
| 231 | return unitVector |
| 232 | |
| 233 | |
| 234 | def get_safe_feedrate(displacement_vector, max_feedrates, target_feedrate): |
nothing calls this directly
no test coverage detected