Link to home
Start Free TrialLog in
Avatar of sph2105
sph2105Flag for United States of America

asked on

Need clarification for computing normal of a sphere

I am trying to compute the 3D surface normal for a given point on a sphere, in order to find the direction of a light source. I am given the sphere's orthographic projection on the image plane, which is basically a circle, and I have found the center, radius, and area of this circle.

Given that the equation of a sphere is (x-xc)^2 + (y-yc)^2 + (z-zc)^2 = r^2, where xc,yc, and zc are the coordinates of the centroid of the sphere. I have solved for (z-zc) using this equation. I just want to make sure: if I compute the gradient (2(x-xc), 2(y-yc), 2(z-zc)), it safe to assume that the sphere's gradient will give me the normal vector TO the sphere's surface at the point (x,yz)? (the normal originates at the sphere's center)
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

I've read this question a few times and am not sure what you're asking. But why are you working in Cartesian coordinates anyway? This problem has spherical symmetry you should consider working with spherical coordinates.

Brian
>>(x-xc)^2 + (y-yc)^2 + (z-zc)^2
>>Gradient  (2(x-xc), 2(y-yc), 2(z-zc))

That's not correct.

If your function is f(x,y,z) = (x-xc)^2 + (y-yc)^2 + (z-zc)^2

Then you have:

f(x,y,z) = (x(1-c))^2 + (y(1-c))^2 + (z(1-c))^2
grad f(x,y,z) = (1-c)^2 * (x^2 + y^2 + z^2)
                    = (1-c)^2 + (2x a_x + 2y a_y + 2z a_z)

Another way to look at it:

f(x,y,z) = (x(1-c))^2 + (y(1-c))^2 + (z(1-c))^2

grad f = 2(x(1-c)) * (1 - c) a_x + 2(y(1-c)) * (1 - c) a_y + 2(z(1-c)) * (1-c) a_z

           = (1-c)^2 +(2x a_x + 2y a_y + 2z a_z)


Brian

BrianGEFF719>> xc is NOT x*c, but x(center) etc  so his formula for the coordinates of the surface of the sphere, in Cartesian coordinates (x,y,z) is correct.  The comment about using Spherical coordinates is also the proper way to approach this problem.

AW
Avatar of sph2105

ASKER

Sorry for being unclear, as I typed this question in a rush. Let me try to clarify:

xc, yc, and zc are indeed x(center), y(center), and z(center). as suggested by Arthur.

The reason I want to stick with Cartesian coordinates is because I am working with an image which I will have to process later, so rather than switching back and forth between Cartesian and polar, I would rather just stay in Cartesian.

What I am basically asking is: does using the gradient formula I stated give me the normal from originating from the center of the sphere to the point (x,y,z) ?
Avatar of sph2105

ASKER

wow, let mer retype that, since I cant edit posts

does that gradient  2*(x-xc), 2*(y-yc) 2*(z-zc) give the normal originating at the center of the sphere to point (x,y,z)?
ASKER CERTIFIED SOLUTION
Avatar of aburr
aburr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can also calculte the equation of a line from the center to (and through) your point from
(x-x1)/(x1-x2) = (y-y1)/y1-y2)=(z-z1)/(z1-z2)
where x1,y1,z1 and x2,y2,z2 are two points (center and surface points)
Avatar of sph2105

ASKER

Thanks aburr.