
Tue, 07/15/2025 - 17:02
Hello,
a surface has a parametrization
x = x(u,v)
y = y(u,v)
z = z(u,v)
The position of P on the surface S is
(P-O) = x e_i + y e_y + k e_z
in which e_i, e_j, e_k are the direction vectors in (O,x,y,z).
The first fundamental form describing the metric of S is the square maxtrix
E F
F G
in which
E = d(P-O)/du × d(P-O)/du
F = d(P-O)/du × d(P-O)/dv
G = d(P-O)/dv × d(P-O)/dv
Nothing new.
For a sphere of radius R
x = R cos u cos v
y = R cos u sin v
z = R sin v
so the first fundamental form is
E = R^2
F = 0
G = R^2 sin^2 u
if R = 100, the first fundamental form is
10000 0
0 10000 sin^2 (u)
and depends on u. Again nothing new.
The following simple functions should return the matrix as result, as a function of the input point (u,v) in the parametric space of the input surface
void metricTensor(double u, double v, occHandle(Geom_Surface) surf, double* mt)
{
gp_Pnt P3d;
gp_Vec d1u, d1v;
surf->D1(u,v,P3d,d1u,d1v);
mt[0] = d1u.Dot(d1u);
mt[1] = d1u.Dot(d1v);
mt[2] = d1v.Dot(d1u);
mt[3] = d1v.Dot(d1v);
std::cout<<"******* metric tensor ***********"<<std::endl;
std::cout<<" | "<<mt[0]<<"\t "<<mt[1]<<" |"<<std::endl;
std::cout<<" | "<<mt[2]<<"\t "<<mt[3]<<" |"<<std::endl;
std::cout<<"*********************************"<<std::endl;
}
If I use as input a spherical surface of radius R = 100 (see the attached picture), for a bunch of points P_j, with a certain (u_P_j, v_P_j) the function prints:
******* metric tensor ***********
| 380.602 0 |
| 0 10000 |
*********************************
******* metric tensor ***********
| 842.652 0 |
| 0 10000 |
*********************************
******* metric tensor ***********
| 693.059 0 |
| 0 10000 |
*********************************
******* metric tensor ***********
| 8535.53 1.00974e-28 |
| 1.00974e-28 10000 |
*********************************
The output matrix is transposed. What's wrong?
Thank you very much
Giovanni
Wed, 07/16/2025 - 12:18
Hello. The matrix is not wrong, it is valid. The confusion comes from a difference between the parametrization you might be expecting and the one that OCCT actually uses for a spherical surface.
OCCT expect: u=azimuth, v=elevation.
Geom_SphericalSurface
uses a different convention where the roles ofu
andv
are swapped.Best regards, Dmitrii.
Wed, 07/16/2025 - 16:59
Grazie mille Dimitrii,
I would not have transposed without a motivation.
So, what about the documentation?
Geom_SphericalSurface Class Reference
R is the radius of the sphere. The parametric range of the two parameters is:
[ 0, 2.*Pi ] for u, and
[ - Pi/2., + Pi/2. ] for v.
Have a nice day
Giovanni
Wed, 07/16/2025 - 15:38
Hello Giovanni,
You've found the exact part of the documentation that proves the point. Those parameter ranges are the key.
*u in [ 0, 2.Pi ] is the 360-degree rotation around the sphere's axis, which defines the azimuth (longitude).
v in [ -Pi/2, +Pi/2 ] is the angle from the "south pole" to the "north pole," which defines the elevation (latitude).
This confirms the OCCT convention (
u
=azimuth,v
=elevation) is being used.Best regards, Dmitrii
Thu, 07/17/2025 - 10:53
Please do not open links from spammers (deleted message from bot). The AI generated text + fishing site (the deleted message).