Bouncing Photon (Part 2)

There is a photon traveling in the x y xy -plane. At t = 0 t = 0 , it is positioned at ( x , y ) = ( 3 5 , 3 10 ) (x,y) = \left(-\frac{3}{5} ,\frac{3}{10}\right) and it has a velocity ( v x , v y ) = ( 1 2 , 3 2 ) (v_x,v_y) = \left(\frac{1}{2},\frac{\sqrt{3}}{2}\right) .

The photon is surrounded by a circular mirror of unit radius which is centered on the origin. There is no mirrored surface within the angle range ( 5 θ 5 ) (-5^{\circ} \leq \theta \leq 5^{\circ}) , where θ \theta is measured with respect to the + x +x axis.

At what time does the photon exit the region enclosed by the circular mirror (to 1 decimal place)?


Inspiration .


The answer is 275.6.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

First we'll add two type synnonyms to make things simpler:

1
2
type Vector = (Double, Double)
type Time = Double

Now, we define a function that calculates the new position based on the velocity and the travel time:

1
2
travelT :: Vector -> Vector -> Time -> Vector
travelT (rx, ry) (vx, vy) t = (rx + t*vx, ry + t*vy)

Now, we need to calculate when and where a photon collides on the mirror given it's current position and velocity. So, suppose this collission takes time t t and we are currently at ( r x , r y ) (r_x,r_y) with position ( v x , v y ) (v_x, v_y) . Then the new position ( r x + t v x , r y + t v y ) (r_x + t v_x, r_y + t v_y) satisfies ( r x + t v x ) 2 + ( r y + t v y ) 2 = 1 t > 0 (r_x + t v_x)^2 + (r_y + t v_y)^2 = 1 \quad \quad t > 0

1
2
3
4
5
6
7
8
nextCol :: Vector -> Vector -> (Vector, Time)
nextCol (rx, ry) (vx, vy) = ((x,y), t)
    where
        t = let (t1, t2) =  ((- (rx*vx + ry*vy) - sqrt (vx^2 - ry^2 * vx ^ 2 + 2 * rx * ry * vx * vy + vy^2 - rx^2 * vy^2))/(vx^2 + vy^2), (- (rx*vx + ry*vy) + sqrt (vx^2 - ry^2 * vx ^ 2 + 2 * rx * ry * vx * vy + vy^2 - rx^2 * vy^2))/(vx^2 + vy^2)) in
            if t1 > 0 && t2 > 0   then min t1 t2 else
            if t1 > 0            then t1
            else             t2
        (x,y) = travelT (rx, ry) (vx, vy) t

Now, given the velocity vector of a photon, we would like to find the new velocity vector after it bounces. To do that, we extract the component of the velocity in the direction of the normal to the surface at that point and reverse it. And it so happens that the position vector on the unit circle is an unit vector in the opposite direction to that of the normal.

1
2
3
4
5
reflectV :: Vector -> Vector -> Vector
reflectV (ux, uy) (x, y) = (ux - 2*cx, uy - 2*cy) --assuming (x, y) is a unit vector, which it is
    where
        comp = ux * x + uy * y
        (cx, cy) = (comp*x, comp*y)

Now, we will add a function that takes the current position, velocity and time and updates it to that until the next reflection.

1
2
3
4
5
6
update :: (Vector, Vector, Time) -> (Vector, Vector, Time)
update (r, v, t) = (r', v', t')
    where
        (r', t'')   = nextCol r v
        t'          = t + t'' --time is additive, unlike position
        v'          = reflectV v r'

And now, we are ready, we update the state repeatedly until the photon escapes. When it does, we read off the time.

1
2
3
4
5
ans = head $ dropWhile f (iterate update initial)
    where
        initial = ((-0.6,0.3),(0.5,(sqrt 3)/2),0)
        f ((x,y), _, _) = not $ let tanTheta = (y/x) in 
            0 < x && -0.0874887 < tanTheta && tanTheta < 0.0874887 --is in the right half of the plane and is within 5 degrees

Cool, that's very concise code. I'll have to learn more about Haskell. What was your final result? Can you cast a tie-breaking vote in the report that has been submitted for this problem?

Steven Chase - 4 years, 5 months ago

Log in to reply

I submitted my data, it seems to agree with yours to some extent.

Agnishom Chattopadhyay - 4 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...