Findning the normal vector to a sphere's surface

Click For Summary
SUMMARY

The discussion focuses on calculating the normal vector to a sphere's surface at a given point (x, y) using orthographic projection. The sphere's center coordinates and radius are known, and the normal vector is derived from tangent vectors in a 3D coordinate system. Key equations include the use of trigonometric functions to compute angles in radians, specifically for tangent vector components. The importance of correctly implementing these calculations in C++ is emphasized, particularly the use of the math.h library for trigonometric functions.

PREREQUISITES
  • Understanding of 3D coordinate systems and normal vectors
  • Familiarity with trigonometric functions in programming (C++ math.h)
  • Knowledge of Lambertian surfaces and their properties
  • Basic understanding of spherical coordinates and projections
NEXT STEPS
  • Study the implementation of normal vector calculations in 3D graphics
  • Learn about spherical coordinates and their applications in computer graphics
  • Explore the use of radians vs. degrees in trigonometric calculations
  • Investigate the properties of Lambertian surfaces and their rendering techniques
USEFUL FOR

Students in computer graphics, programmers working with 3D modeling, and anyone interested in understanding normal vector calculations for spherical surfaces.

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);
count<<phi;
count<<" "<<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;

count<<brightest_Pixel;
count<<" "<<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 ??
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K