The align method might not have the most self-explanatory name. What it does is to return true if the angle between the vectors is less than 90 degrees. I think it is doing this correctly. It’s comparing the dot-product with zero.
I personally wouldn’t find that function very useful - since it’s just testing between one perpendicular and the other. I would be interested in:
a) a being able to test a more specific range of alignment (ie, between 0.9 and 1)
b) being able to test the opposite, ie, are the vectors facing toward each other – this is useful for flocking, for example, where you could have objects test if they can “see” each other.
I guess the more specific you could get with the test, the better – the problem is that it’s a little bit hard to wrap your head around the dot product, and it’s simpler to want to ask the question, are they within 10 degrees of each other, etc, are they within 20 degrees of being 180 degrees from each other, etc. I remember the first time I started to work with flocking I has trouble wrapping my head around altering that variable since it wasn’t in degrees at all.
hope that’s useful input -
at any rate, thanks for all the additions to ofVectorMath !!
ps one tricky thing about the dot product I think is that is assumes that the vectors are the same size (same length) – in order for the suggestion I threw up above to work you’d want to normalize them before you do the dot product, otherwise doing the dot product bteween two vectors pointing in the same direction but one being small, would be close to 0, even if they share the same angle. The applet you posted online is a good way to check that.