Solved

Need clarification for computing  normal of a sphere

Posted on 2008-11-01
8
1,186 Views
Last Modified: 2013-12-26
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
Comment
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
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
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

by:BrianGEFF719
ID: 22860822
>>(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

0
 
LVL 44

Expert Comment

by:Arthur_Wood
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sph2105
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

by:sph2105
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

by:
aburr earned 500 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

by:aburr
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

by:sph2105
ID: 22861792
Thanks aburr.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Article by: Nicole
This is a research brief on the potential colonization of humans on Mars.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
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…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question