, , , , (, ), - dot === 0, , . :
if (dot === 0) {
// numbers pulled completely out of thin air...
a.vx = 0.5;
a.vy = 0.5;
b.vx = -0.5;
b.vy = -0.5;
}
http://jsfiddle.net/yP7xf/5/
What speed should you give them? This is what you will need to work out. You probably want them to diverge so that you can calculate some vector based on a line from the center of one to the center of the other, and send one in one direction along this vector and the other in the other at any speed that you think is appropriate. But if they lie exactly one above the other (centers at the same point), then you will also have to consider this case.
source
share