In general, comparing two vectors means getting the length of their difference. If your vectors are normalized, that will still work, but you can do it faster using a dot product. If you replace the line "dist = (vec-targetVector).length()" with "dot = vec * targetVector" above, the largest dot product is the closest vector.
My experience with Maya's Python API 2.0 is that it's as fast or faster than NumPy for dealing with things like MVectorArray or MPointArray, and it's a lot more convenient. I guess I'm missing something here though. Why is dot product not an option? On Wednesday, 22 March 2017 09:35:09 UTC+11, justin hidair wrote: > > No I want to literally find the closest vector , this is not a matter of > length but It's about the vectors components + in my case, all vectors are > normalized so length is not even relevant yes, > but dot product is not an option, It's barely legal to me to just dot > product things for this sake, I'm more interested in solutions like numPy > and sciPy, someone has experience with it ?or had this problem ? > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/90d92a65-617e-4864-8881-95e18ade1a4e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
