stackgl/shader-school — pull request #84 by mdda (2014-08-18 19:30:51+00:00)
Title: 03-intro-3 : Degenerate cases make this very difficult...

The README hint file (with the ascii-art diagram) is kind of misleading : the beautiful (and concise) answer that you're looking for doesn't follow directly from the rubric. Moreover, because your VERIFY field covers the whole of the xy plane, it includes degenerate cases where A is collinear with B (and pointing in the opposite direction). This prevents the following from working (which is more directly derivable from your diagram, etc) :

```
highp float pct = length(a) / (length(a)+length(b));
vec2 c = a + pct * (b-a);
return normalize(c);
```

The attached patch fixes the degenerate case area where A is pointing almost in opposite direction to B. Reasonable solutions will now work. My guess is that was the original intention, since your existing code includes a 0.01 error ball around the expected solution anyway.

Hope this makes sense
Martin
:-)