Search code examples
javascriptwebglcalculus

Drawing Curves on Surfaces in WebGL


Well, the title pretty much states it. I want to be able to draw a curve on a surface in Web GL. So for example, I'd like to draw a parabola on the surface of a sphere.

x = cos(theta)sin(phi); y = sin(theta)sin(phi); z = cos(phi).

If you make theta = theta(t) and phi = phi(t), you can draw curves on the surface.

I guess lines on shapes is what I need. Anyone know if that's possible in Web GL?


Solution

  • A parabola is the set of point of the plane that have the same distance from a line and a point (called focus). The point here is what do you mean by "line" on a sphere. Remember that a parabola extends to infinity, bu you can't do that on a sphere, unless you define some particular metric on it.

    Anyway, you gave use a parametrization of the sphere, in terms on theta and phi. That's good. If you want to define a curve on the surface, you should have a bind between theta and phi, for example

    phi = theta ^ 2
    

    would draw something that could be defined as a "parabola" in some way, i.e. the projection on the sphere, given by the parametrization, of its representation on a plane.