Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

**First time visiting? Here are some places to start:**

- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

# Behavior of parallelVectors() function

konstantin_shiriazdanov
Member Posts:

**1,017**✭✭✭✭✭
I noticed that parallelVectors(v1, v2) returns False if one of the vectors is zero vector, if i remember correctly this behavior goes against the strict mathematical properties of zero vector, which should be parallel to any vector.

For example the condition for point "p" lying on the line defined by reference point "refPoint" and direction vector "refVector" is "parallelVectors(p - refPoint, refVector)" but when "p" matches "refPoint" parallelVectors() returns False, which is rather unexpected and unwanted behavior.

For example the condition for point "p" lying on the line defined by reference point "refPoint" and direction vector "refVector" is "parallelVectors(p - refPoint, refVector)" but when "p" matches "refPoint" parallelVectors() returns False, which is rather unexpected and unwanted behavior.

0

## Comments

493In the case you mentioned of parallelVectors(p - refPoint, refVector), I think a zero check outside the function *is* warranted. If (p - refPoint) is very close to (but not precisely) zero, it quite likely

ispointing in some non-parallel direction. If we called that parallel, we'd lose some other important properties, like the property where parallelVectors(K*a, b) returns the same thing for any non-zero K. So for your case, a better check check would be something like:Alternatively, if you (perhaps rightfully) don't want to think about cross products, just do a zero check (via tolerantEquals) and a parallel check separately.

For reference, our implementation is not far from that, but it measures an angular deviation rather than a linear one:

exactlyzero should return true. However, tolerances are tricky, so the fixed version still wouldn't have the property you desire. You care about linear deviation from a parallel line, whereas parallelVectors() cares about angular deviation from parallel angle. These two concepts are two closely related but mathematically distinct once you throw tolerances into the mix!1,017✭✭✭✭✭a little problem with all that built in tolerances is that they are not documented