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])
}