Hi all, im new to c++.
My task is to make function that will rotate radius vector of incident photon when he interact with surface. Its total reflection problem, no transmision (so no refraction, just reflection).
Inputs are components "Ex" and "Ey" or radius vector "r". And outputs are new radius vector "r' " with new components "Ex' " and "Ey' ". Acctually its problem of rotating vector "r" around vector "n". Vector "n" is surface normal vector, since its surface along X axis (its horisontal) its components are (0,1).
I drow little picture of this problem. So inputs are components Ex and Ey of radius vector of photons, next surface normal vector n(0,1), and result should be components Ex' and Ey' of radius vector after reflection. in this case components along X axis will remain same, but Ey components will change.
Here is little picture of this problem: https://root.cern.ch/phpBB3/download/file.php?id=12352&t=1
Mr diddeldidum,
thank You for your response, but this look really complicated, at least for my knowledge of programming.
I can't understand what is happening here, except last line v.x = -v.x()...
althought last line is what I need...
The namespace directive you could omit. With the namespace, you must precede your Vector with 'starke::'
1 2 3 4 5
// example for creating a new Vector:
starke::Vector v = starke::Vector( 3.14, 2.52 );
// example for using the reflection function:
starke::Vector v_2 = starke::reflect_to_x_axis( v );
If the incident ray has components Ex and Ey and the reflected ray has components Ex' and Ey',
then,
Ex' = Ex and Ey' = - Ey which is described in the class Vector method return value (line 3 above).
acctualy my problem is reflection on 4 sides of parallelepiped or square.
I need some "universal formulae" not only for parallelepiped whose two sides is parallel to X axis, and 2 sides parallel to Y axis, but also for parallelepiped that is leaning by some angle to X axis.
I'm glad it helped Starke, all the posts point to the same, believe it or not.
The point you raise about universality is not perfectly clear because the
incident -> reflected ray vector transformation is universal in itself and applies at every interface or reflective surface in the 2D world.
Do you mean a parallelogram (2D) or a parallelepiped (3D object)? Whatever it is the same physics principle applies but you may need to take into account the Ez vector component if it's a 3D object/mirror.
Assuming for simplicity that it is the 2D case you have 2 options:
a) draw a picture similar to the diagram you posted and work it out from there as a single formula.
b) use the transform you have for the single case and model the parallelogram in a program and let the computer work it out.
There are a couple of cases depending on the relative direction the incident ray is travelling. (Maybe someone has a formula if you google it.)
PS Afterthought: You need to correct for any rotation of the reflecting surface in about the Z-axis (ie in the XY plane) - this is where local and global coordinates come into play :)