DebugRenderer: Support for drawing Arcs on Spheres

Here’s a screen shot that shows an arc being drawn between two points on the surface of a sphere.
Note the orange arc, drawn between the two purple vectors…
I plan to use it as part of an orientation widget, to help visualize a proposed quaternion-slerp.

Here’s the code:

void DebugRenderer::AddArc(const Sphere& sphere, const Vector3& from, const Vector3& to, const Color& color, int steps, bool depthTest)
    Vector3 prevPoint, nextPoint;

    float omega = Acos(from.DotProduct(to));
    float d = Sin(omega);

    for(float t=0; t<=1.0f; t+=1.0f / (float)steps){
        prevPoint = nextPoint;
        float s0 = Sin((1.0f - t) * omega);
        float s1 = Sin(t * omega);
        nextPoint = (from * s0 + to * s1) / d;
            AddLine(prevPoint*sphere.radius_+sphere.center_, nextPoint*sphere.radius_+sphere.center_, color, depthTest);

The two input vectors are assumed to be direction normals (from origin of sphere to each surface point).

I hope others find this useful :slight_smile: