Click here to Skip to main content
15,512,502 members

Comments by Peter_in_2780 (Top 200 by date)

Peter_in_2780 29-Nov-22 4:32am View    
Add/subtract is easy. Mul/div, you need to keep track of scaling. Lots of 16 bit shifts before/after operations. Otherwise it's just like regular integer arithmetic, with the same fun and games around overflow, divide by zero, etc.
Peter_in_2780 23-Nov-22 2:42am View    
If you just want to undo the rotation, find the matrix used in the rotation, invert it and apply that inverse rotation matrix.
Peter_in_2780 21-Nov-22 22:41pm View    
Forget about rotation for a moment. Let's consider a simple orthographic projection along the z axis, so the x and y screen coordinates map to world x and y (with appropriate scaling). What I am saying is that the world points (x,y,0) and (x,y,1) and (x,y,2) etc all map to the same screen point. From the screen coordinates, there is no way to recover the "depth" dimension, in this example the z direction.
In a rotated projection, the same thing applies to whatever the "line of sight" direction happens to be.
Looking at your random cubes example, every point on a visible face of a cube shares a screen point with a point on a hidden face (and an infinite number of others in front and behind along that line of sight).
Peter_in_2780 20-Nov-22 16:41pm View    
If I understand what you're trying to do, it's impossible. You are trying to convert a 2D screen location (x,y) into a 3D world location (x', y', z'). All world points along a line of sight share the same screen location. The initial projection destroyed the "depth" information, and you can never recover it.
Peter_in_2780 25-Oct-22 5:58am View    
The error message is pretty clear: The IV is the wrong length. It should be the size of one algorithm block.