Findning the normal vector to a sphere's surface

In summary, the sphere projects into a circle on the image plane. The sphere's center coordinates x, y are known as well as the radius. The normal vector to the sphere’s surface at a given point(x,y) 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.
  • #1
dadin22
5
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
  • #2
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.
 
  • #3
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?
 
  • #4
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
 
  • #5
help ??
 

Related to Findning the normal vector to a sphere's surface

What is a normal vector?

A normal vector is a vector that is perpendicular to a surface at a specific point. It represents the direction in which the surface is facing.

How is the normal vector to a sphere's surface calculated?

The normal vector to a sphere's surface can be calculated using the gradient function, which takes into account the partial derivatives of the sphere's equation with respect to its variables (x, y, z).

What is the importance of finding the normal vector to a sphere's surface?

The normal vector is important because it helps determine the orientation and curvature of the surface at a specific point. It is also used in various applications such as physics, computer graphics, and engineering.

Can the normal vector to a sphere's surface change at different points?

Yes, the normal vector can change at different points on the surface of a sphere. This is because the surface of a sphere is curved, and the direction of the normal vector depends on the curvature at a specific point.

Are there any alternative methods for finding the normal vector to a sphere's surface?

Yes, there are alternative methods for finding the normal vector to a sphere's surface, such as using cross products or calculating the gradient manually. However, the gradient function is the most efficient and accurate method for finding the normal vector.

Similar threads

Back
Top