English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to write a code (this is just part of the code, but this has me stumped) that calculates the distance from a photon in any location in a circle to the boundary of the circle. Any ideas????

(I am performing this in MATLAB)

2007-03-02 11:30:14 · 3 answers · asked by Laura C 1 in Science & Mathematics Engineering

3 answers

Sounds like perhaps you're leaving out part of the problem? Is there anything special about using a photon?

Calculate the distance from the photon to the center of the circle.
If the photon is at (x, y), and the center of the circle is at (xc, yc),
then:

d = sqrt( (x - xc)^2 + (y - yc)^2)

Then subtract this from the radius of the circle.

dp = radius - d

dp is distance of the photon to the circle.

if d > radius, then use
dp = d - radius

2007-03-02 11:38:44 · answer #1 · answered by morningfoxnorth 6 · 0 0

It doesn't sound very complicated. calculate the tangent line to the circle in a parametric form (the line that passes through the contact point of tangent line and the boundary circle). Also calculate the line passing the photon position and the contact point. Calculate the inner product of these two. wherever it is zero they are perpendicular and the distance is minimum.

2007-03-02 19:47:18 · answer #2 · answered by Banzan 2 · 0 0

Assuming that the center of the circle of radius R is at the origin (0,0), then the minimum distance to the circle is::

Dmin = R - √(x² + y²)

where (x, y) is the coordinate position of the photon.

2007-03-02 20:03:55 · answer #3 · answered by Scythian1950 7 · 0 0

fedest.com, questions and answers