phil-shenk/curve-generator-opengl

direction of normal inconsistent at inflection points

phil-shenk opened this issue · 2 comments

Each row of triangles is oriented with respect to a vector that is normal to the curve. There are infinitely many vectors that satisfy this condition, and currently it is chosen as the cross product between the 'curvature' vector and the 'tangent' vector at the given point on the curve.
This works for most regions of most curves, but when there is an inflection point in a section of the curve that's contained within a plane (i.e. where the curvature vector only varies within a plane for that section of the curve), the normal vector inverts its direction very abruptly, leading to an ugly twist in the curve. Since this relies on the curvature vector, this approach also breaks for straight segments of curves.

I will implement a different approach to picking the normal vector that doesn't rely on the curvature vector. I will instead project the previous normal vector onto the plane that's orthogonal to the curve at the current point, and use that as the current normal vector. This should provide a smooth transition for all smooth curves, as well as all piecewise-defined curves that have less than a 90 degree cusp.

see "normal_projection_math.png" in screenshot folder

closed by merge of branch #2 Iss1
normals are now calculated by projecting previous normal onto tangent plane