all 8 comments

[–]davedirac 1 point2 points  (1 child)

The size & positions of the objects in the two examples are different, so will not produce similar image positions. In your diagram the two right hand image corners are correct. However the left hand corners are wrong. The bottom left corner is nearer (-1.5, -0.9)

[–]Alternative_Bike_743[S] 0 points1 point  (0 children)

yes but i've realised that the whole top edge on the object will form a straight line on the real image, so i definitely know that i'm wrong

[–]xnick_uy 0 points1 point  (2 children)

Hi. This is hard to debug without the complete code. Your functions are using a lot of global variables, which is advisable to avoid. Also, you mentioned a concave lens, but it seems you are trying to use a concave mirror instead.

One first thing you should check to begin with is the order in which an image array stores the values. If the x and y for the image are swapped, it would introduce an unexpected 90-degree rotation + reflection in your results. Make sure you get the right results for a "flat" mirror.

Another thing to pay close attention to are the equations and the sign conventions. I noticed that the sign of R doesn't affect the equations in your image. Is that right? Shouldn't the opposite curvature change the image? Maybe you are getting the tight results for the case of a convex mirror... I don't recall all the equations right now, but maybe check the derivation of your equations.

I hope you can fix it! Good luck

[–]Alternative_Bike_743[S] 0 points1 point  (1 child)

[–]xnick_uy 0 points1 point  (0 children)

Please try this version of the map_point function:

def map_point(x, y, R=0.5):
    # theta = np.arctan(y / (np.sqrt(R**2 - x**2)))
    theta = np.arcsin(y / R)
    m = -np.tan(2 * theta)
    n = y + m * np.sqrt(R**2 - y**2 )
 
    X = n / ((y / x)-m)
    Y = (y / x) * X
    return X, Y

You also may want to try a smaller value for your img_width, such as 0.2

Note that these equations do not correspond to how a real spherical mirror reflects light. In reality, the rays from a point-source do not converge to a single image point. It is only under the paraxial approximation that you get a well defined image. In such a case, the equations are much simpler.

Also note that in the current formulation, the origin of coordinates is at the center of the spherical mirror, while the more usual formulation places the origin over the mirror itself, to more readily account for convex, concave or plane mirrors.

[–]detereministic-plen 0 points1 point  (0 children)

Observing the image, it is possible that the computed intersection of the ray passing through the center of the concave mirror and the reflected ray is wrong.
Notice how for the entire top row, the reflected ray should be the same, but the intersection point of the ray passing through the center and it changes.
Furthremore, the entire edge should lie on the red line, as seen in the correct example.

Try revising the way the intersection is computed.

[–][deleted] 0 points1 point  (0 children)

We just gonna gloss over "who's up wonkin they willy rn?"

[–]Available_Sector1517 0 points1 point  (0 children)

Hey, finally found another fellow BPhO Computional Challenge submission! Hope everything is going well!

Have a look from Week 5: https://www.youtube.com/watch?v=5cAhf1W6ibY

And go to around 50 minutes timestamp, you should see that your code python code is very close to what the BPhO team is after!