2
$\begingroup$

I have the parametric model of an ellipsoid like this:

\begin{cases} x=a_1\,cos \,\eta \:cos\,\omega & -\pi\leq\omega\leq\pi \\𝑦 = 𝑎_2\,cos\,\eta\:sin\,\omega \\ z=a_3\,sin \,\eta & -\frac{\pi}{2}\leq\eta\leq\frac{\pi}{2} \end{cases}

and

\begin{cases} n_x=\frac{1}{a_1}\,cos \,\eta \:cos\,\omega & -\pi\leq\omega\leq\pi \\n_𝑦 = \frac{1}{a_2}\,cos\,\eta\:sin\,\omega \\ n_z=\frac{1}{a_3}\,sin \,\eta & -\frac{\pi}{2}\leq\eta\leq\frac{\pi}{2} \end{cases}

First of all I do not understand the last system of equation what it represents. Shouldn't parameterisation of an ellipsoid be the first system alone?

I have to create a polygon mesh (in webgl) from parametric model of ellipsoid. I can choose dimensions of semiaxes (namely values of $a_1$ $a_2$ and $a_3$) and the sampling step of 2 angles (the parameters). In this way I'm able to create in javascript with a little of code several vertices of ellipsoid. But I can't imagine how to realise the triangulation. Namely given the vertex buffer, I have to create the index buffer but in what way do I choose the indexes of the vertices to tessellate in a correct way ellipsoid surface? Is there a clever/smart way to proceed?

EDIT:

I implemented that myself, in javascript (the code works):

 function degToRad(degrees)
     {
        return degrees * Math.PI / 180.0;
     }

     function calculateVNI()
     {
     var indices = [];
     var vertices = [];
     var normals=[]
     var a1 =10;
     var a2 =5;
     var a3 =7;
     //var pi = Math.PI;

     var step_eta   = 4; //step in degree (choose a divisor of 360)
         var step_omega = 2; //step in degree (choose a divisor of 180)


     var eta,omega;
     var eta_rad,omega_rad;
     var index=0;
     var x=0;
     var y=1;
     var z=2;

     for(eta = -90 ; eta <= 90 ; eta+=step_eta) //I could do the cycle in rad but I can have problems in condition of termination of the cycle (float value)
         {
            eta_rad = degToRad(eta);

            for(omega = -180 ; omega <= 180 ; omega +=step_omega , index+=3)
            {
               omega_rad = degToRad(omega) 
               vertices[index+x]= a1 * Math.cos(eta_rad) * Math.cos(omega_rad);
               vertices[index+y]= a2 * Math.cos(eta_rad) * Math.sin(omega_rad);
               vertices[index+z]= a3 * Math.sin(eta_rad);

                   normals[index+x]= vertices[index+x] /(Math.pow(a1,2.0)) ;
               normals[index+y]= vertices[index+y] /(Math.pow(a2,2.0));
               normals[index+z]= vertices[index+z] /(Math.pow(a3,2.0));
            }
         }

             //Now triangolation. I believe that it needs a counterclockwise specification of vertices (else I have back-face)
     //each triangle is specified with 3 indices (gl.TRIANGLES).

             var num_samples_omega = 360/step_omega ;   //Actually there is another sample that coincides with the first sample.
     var num_samples_eta   = 180/step_eta ;

             var i,j;
     for(i=0,index=0 ; i<num_samples_eta ; i++) //il primo e l'ultimo campionamento coincidono con un solo punto ma va bene uguale
     {
         for(j=0 ; j<num_samples_omega ; j++,index+=6)
         {
            //Si definiscono ad ogni ciclo gli indici dei 2 triangoli del poligono formato da 4 campioni (due per ciascuna sezione di ellisse adiacente)
             indices[index]=i*num_samples_omega +i+j; //I could use index++ but like this is more clear.
                             indices[index+1]=(i+1)*num_samples_omega +2+i+j;
             indices[index+2]=(i+1)*num_samples_omega +1+i+j;

             indices[index+3]=i*num_samples_omega +i+j;
             indices[index+4]=i*num_samples_omega +1 +i+j;
             indices[index+5]=(i+1)*num_samples_omega +2 +i+ j;
         }
     }

  //alert("num vertici"+vertices.length+"\n"+"indice massimo:"+ indices[index-1])


 }
$\endgroup$

1 Answer 1

4
$\begingroup$

If you sample the two parameters $\eta$ and $\omega$ with steps $d\eta$ and $d\omega$, then you'll get a grid of points $v_{ij} = f(i\;d\eta,j\;d\omega)$. Any four adjacent points will define a quadrilateral. To get triangles, you just have to split each quad in two by a diagonal.

enter image description here

So in the example, you'd split the quadrilateral $\{v_{00},v_{01},v_{11},v_{10}\}$ into two triangles $\{v_{00},v_{01},v_{10}\}$ and $\{v_{01},v_{11},v_{10}\}$. You'll want to make sure the points come in the right order so the triangle orientations match (or you'll end up backface-culling half of your triangles.)

Your second equation, for $n_{xyz}$, is finding the normal of each vertex, which you can use for shading.

$\endgroup$
2
  • $\begingroup$ I implemented it but I'm not sure that is correct. However thanks! $\endgroup$
    – Nick
    Commented Mar 20, 2018 at 16:21
  • $\begingroup$ Ok, the code now seems work. Practically I implemented a sort of skinning algorithm following the suggest. $\endgroup$
    – Nick
    Commented Mar 20, 2018 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.