Findning the normal vector to a sphere's surface

AI Thread Summary
To compute the normal vector to a sphere's surface at a given point, the center coordinates and radius of the sphere are essential. The normal vector originates from the sphere's center and must align with an orthonormal right-hand coordinate system. The discussion highlights the importance of using radians for trigonometric functions in calculations and addresses issues with tangent vector components. Participants express confusion over the correct computation of angles and the relationship between spherical coordinates and the normal vector. Clarification on the definitions of θ, φ, and ρ is requested to aid in solving the problem effectively.
dadin22
Messages
4
Reaction score
0

Homework Statement



Assuming an orthographic projection, the sphere projects into a circle on the image plane.
compute the normal vector to the sphere’s surface at a given point(x,y). The Sphere's center coordinates x,y are known as well as the radius. The resulting normal is in 3d coordinate system. the origin of vector is in sphere's center. its x-axis and y-axis parallel to the image's x-axis and y-axis. z-axis should be as such to form a orthonormal right-hand coordinate system.

Homework Equations



Our surface is a Lambertian surface.

The Attempt at a Solution



double phi=atan(yp/xp);
cout<<phi;
cout<<" "<<xp<<" "<<yp;//
double zp=90*cos(phi);

double z = sqrt((r*r)-(x*x)-(y*y));

// (xp-x)^2 + (yp-y)^2 + (zp-z)^2 = R



/* tangent vector with respect to image plane */
double tx = -sin(phi);
double ty = cos(phi);
double tz = 0;

/* tangent vector with respect to sphere */
double sx = cos(phi)*(-sin(90));
double sy = sin(phi)*(-sin(90));
double sz = cos(90);

/* normal is cross-product of tangents */
double nx = ty*sz - tz*sy;
double ny = tz*sx - tx*sz;
double nz = tx*sy - ty*sx;

/* normalize normal */
double length = sqrt(nx*nx + ny*ny + nz*nz);
nx /= length;
ny /= length;
nz /= length;

cout<<brightest_Pixel;
cout<<" "<<length;
 
Physics news on Phys.org
Are you having problems with this? You didn't say.

One thing that jumps out at me are your calculations for the tangent vector components tx, ty, and tz.
Code:
double sx = cos(phi)*(-sin(90));
double sy = sin(phi)*(-sin(90));
double sz = cos(90);
The trig functions in math.h take arguments in radians, not degrees. The sin(90) and cos(90) expressions make me think you're not aware of that.
 
Thanks for your reply mark,

I do having problems with it. I can't figure our the way to compute the normal vector.

I know I need to use theta angle and u and v vectors. I also can use the radius and the sphere's center. However I really not so good with the physics part of the problem.

I completely not sure about the code i wrote and if it even makes sense. Thanks for your observation regarding use of radians with math.h

can you maybe give me an head start for the problem or explain it in a clearer way?
 
I am not sure what are the values of my θ, φ and ρ where

ρ - distance from the origin.
φ - the angle from the z-axis
θ - is the angle from the x-axis
 
help ??
 
Back
Top