Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Need clarification for computing  normal of a sphere

Posted on 2008-11-01
Medium Priority
1,189 Views
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)
0
Question by:sph2105
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2
• 2
• +1

LVL 19

Expert Comment

ID: 22860805
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
0

LVL 19

Expert Comment

ID: 22860822
>>(x-xc)^2 + (y-yc)^2 + (z-zc)^2

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

0

LVL 44

Expert Comment

ID: 22861288
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
0

Author Comment

ID: 22861358
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) ?
0

Author Comment

ID: 22861460
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)?
0

LVL 27

Accepted Solution

aburr earned 2000 total points
ID: 22861717
yes
grad f, evaluated at a point P: (x1, y1, z1  is normal the the surface f(x, y, z) = c at P,
0

LVL 27

Expert Comment

ID: 22861769
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)
0

Author Comment

ID: 22861792
Thanks aburr.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month8 days, 14 hours left to enroll