1
votes

I am doing ray tracing and I have screen. I want to define it in the world coordinates

MaxPCx = 1;
MaxPCy = 1 / AspectRatio;

x = linspace(0,MaxPCy,Height_proj);
y = linspace(0,MaxPCx,Width_proj);

[CoordsY,CoordsX] = ndgrid(x,y);

% Convert Projector Coordinates To Screen Coordinates
ScreenXCoordinates = (CoordsX .* MaxPCxInv).* SizeX_scr + Screen_OffsetX;
ScreenYCoordinates = (1 - CoordsY .* MaxPCyInv ).* SizeY_scr + Screen_OffsetY;
ScreenZCoordinates = f(x,y) % this function is the same used in my software that I used exactly the same

So my problem now that I got the ScreenXCoordinates ,ScreenYCoordinates and ScreenZCoordinates from the software and I am comparing them with mine so the difference in x and y coordinates are fine in order of 10^-9 but the difference in z direction is really high in order of 10^-4 so Could anybody give me suggestion please.

and then I am applying the rotation matrix and translation vector for the convertion to the world coordinates

is the generation of the projector coordinates at the beginning (CoordsX and CoordsY) correct?

Many thanks in advance

1
This question is very specific, but is missing all of the information that someone would need to help you. What are you comparing against? You say the Z component is off, but don't even show us the code that produces Z. Are CoordsX and CoordsY correct by what definition? - Peter
I am comparing the results that I am getting from my simulation with the results that the software of my setup uses. Second the calculation of the Z is through an equation and it is the same equation that the software uses(Copy paste and I checked it 2 times, it is the same) - Jack_111
I'd say that if ScreenX/YCoordinates match that closely, then your x,y input arguments have to be correct. Which leaves only f(x,y). - Peter
I know it is very weird what's happening with my results and the first thing I checked after getting that close matching between the ScreenX/YCoordinates was the f(x,y) and it was the same. Anyway than you very much - Jack_111
So Please Peter leave your comment as answer to accept it. Thanks - Jack_111

1 Answers

1
votes

I'd say that if ScreenX/YCoordinates match as closely as they do, then your x,y input arguments have to be correct. Which leaves only a possible mismatch between the f(x,y) implementations. There's a possibility there is a numerical difference even if they look the same. Do the precisions match? Could the other software be using integer vs. floating point math?