Reflecting light ray between two curves in Mathematica

In summary, to model a bouncing light ray between two curves in Mathematica, you will need to use the equations of the curves to find the intersection point, slope, and normal at that point. You can then use the law of reflection to calculate the angle or slope of the reflected line. To code this in Mathematica, you will need to familiarize yourself with drawing lines and curves using the Plot and Graphics functions. You can also use the NSolve function to solve for specific values, and use them in your code.
  • #1
interference
7
0
Hello everyone,

I am working on trying to model a bouncing light ray between two curves, and I would like to model it in Mathematica. However, I do not know what syntax or how to go about typing the code in. I tried to find examples on the Mathematica Documentation Centre but the examples there are not to relevant.

For example, I have two curves, let's say two parabolic curves one above the other. I want to simulate these as mirror and bounce a light ray between the two curves. Can anyone give me an idea on what Syntax to do it?

I understand people draw lines using the Line command, but I do not know how to proceed from there, such as how to program the line to reflect and calculate the slope and normal at the point where the light ray hits one curve and so on.

Thanks very much :)
 
Mathematics news on Phys.org
  • #2
I don't know Mathematica, however:

If you have the equation of the line, you can find it's intersection with a parabolic surface. It's just solving a quadratic equation.

Once you have the intersection, you can find the slope of the parabola, and from that the slope of the normal at that point (taking the negative reciprocal).

Finally, since slope is the tangent of the angle of the line or normal, you can use the law of reflection to get the angle or slope of the reflected line. Since you have that slope, and a point on the reflected line, you can get its equation and find where i intersects the other surface.

Hope that helps. Feel free to ask more specific questions about the procedure I outlined here.
 
Last edited:
  • #3
Hi Redbelly98, yes I do know how to find the slope and all but I need help with the syntax with which to write a code so that Mathematica and do it.

Now for example, if I use NSolve to solve for a slope at a particular place, it gives me for example x-> 0.2. Does anyone know how I can use this value to be placed into another equation? Because if I put the NSolve function into a new function to solve, Mathematica cannot do that because it reads the value not as "0.2" but as "x->0.2".

Thanks!
 
  • #4
You need to get familiar with drawing lines and curves and just graphics in general in Mathematica.

First just draw two parabolas. Say for example:

[tex]y1=x^2+2x-1[/tex]

[tex]y2=-3x^2-x+4[/tex]

Then to draw those, I'd code:

myplot=Plot[{x^2+2x-1,-3x^2-x+2},{x,-5,5},PlotRange->{{-5,5},{-5,5},PlotStyle->{Red,Blue}]

That's a good start. Get a print-out of that. Now just practice drawing dots on the parabolas. Say for example, draw a green dot at the point (1,2) on the first one:

mydot1=Graphics[{PointSize[0.008],Green,Point[{1,2}]}];

Show[{myplot,mydot1}]

Draw a dot on the second one:

mydot2=Graphics[{PointSize[0.008],Green,Point[{1,0}]}];

Now draw a straight line between the two points:

myline1=Graphics[{Yellow,Line[{{1,2},{1,0}}];

Now show everything:

Show[{myplot,mydot1,mydot2,myline1}]

Or if you wanted to draw a line with just the function, use:

Plot[m x+b,{x,b1,b2}]

and to dereference that x->2, try this example and then apply it to yours:

myroots = NSolve[(x - 2) (x + 2) == 0, x]
theroots = x /. myroots
firstone = theroots[[1]]
 
Last edited:
  • #5



Hello there,

It sounds like you are trying to model a light ray reflecting between two curves in Mathematica. This is certainly possible, but it may require some knowledge of the language and its syntax.

One way to approach this problem is to use the "ReflectionMatrix" function in Mathematica. This function allows you to calculate the reflection of a light ray at a given point on a curve. You can then use this function within a loop to simulate the bouncing of the light ray between the two curves.

Another approach is to use the "FindCurvePath" function to find the path of the light ray between the two curves. This function will give you a list of points that the light ray will pass through as it reflects between the two curves. You can then use these points to draw a line and simulate the bouncing of the light ray.

It may also be helpful to consult the Mathematica documentation for more information and examples on how to use these functions. With some experimentation and practice, you should be able to successfully model the bouncing light ray between two curves in Mathematica.

Good luck with your project!
 

1. How can I reflect a light ray between two curves in Mathematica?

To reflect a light ray between two curves in Mathematica, you can use the ReflectionTransform function. This function allows you to specify the two curves as well as the angle of incidence and angle of reflection.

2. Can I reflect a light ray between two curves in 3D space?

Yes, you can use the ReflectionTransform function in 3D space as well. You will need to specify the two curves in 3D coordinates and also provide the angles of incidence and reflection in 3D.

3. How do I plot the reflected light ray between two curves in Mathematica?

To plot the reflected light ray between two curves, you can use the Graphics function in Mathematica. This function allows you to specify the curves and the reflected ray as separate objects in the plot.

4. Can I change the color or style of the reflected light ray in the plot?

Yes, you can use the Graphics function to change the color, thickness, or style of the reflected light ray in the plot. Simply specify the desired options in the function call.

5. Is there a way to animate the reflection of the light ray between two curves?

Yes, you can use the Animate function in Mathematica to create an animation of the light ray reflecting between the two curves. You can specify the angles of incidence and reflection as variables and use the Graphics function to plot the animation at each step.

Similar threads

  • Special and General Relativity
Replies
4
Views
302
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Replies
16
Views
2K
  • General Math
Replies
5
Views
2K
  • Introductory Physics Homework Help
Replies
9
Views
849
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Replies
3
Views
1K
  • General Math
Replies
22
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
889
Back
Top