Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to apply a transformation matrix?
    primarykey
    data
    text
    <p>I am trying to get the 2D screen coordinates of a point in 3D space, i.e. I know the location of the camera its pan, tilt and roll and I have the 3D x,y,z coordinates of a point I wish to project.</p> <p>I am having difficulty understanding transformation/projection matrices and I was hoping some intelligent people here could help me along ;)</p> <p>Here is my test code I have thrown together thus far:</p> <pre><code>public class TransformTest { public static void main(String[] args) { // set up a world point (Point to Project) double[] wp = {100, 100, 1}; // set up the projection centre (Camera Location) double[] pc = {90, 90, 1}; double roll = 0; double tilt = 0; double pan = 0; // translate the point vSub(wp, pc, wp); // create roll matrix double[][] rollMat = { {1, 0, 0}, {0, Math.cos(roll), -Math.sin(roll)}, {0, Math.sin(roll), Math.cos(roll)}, }; // create tilt matrix double[][] tiltMat = { {Math.cos(tilt), 0, Math.sin(tilt)}, {0, 1, 0}, {-Math.sin(tilt), 0, Math.cos(tilt)}, }; // create pan matrix double[][] panMat = { {Math.cos(pan), -Math.sin(pan), 0}, {Math.sin(pan), Math.cos(pan), 0}, {0, 0, 1}, }; // roll it mvMul(rollMat, wp, wp); // tilt it mvMul(tiltMat, wp, wp); // pan it mvMul(panMat, wp, wp); } public static void vAdd(double[] a, double[] b, double[] c) { for (int i=0; i&lt;a.length; i++) { c[i] = a[i] + b[i]; } } public static void vSub(double[] a, double[] b, double[] c) { for (int i=0; i&lt;a.length; i++) { c[i] = a[i] - b[i]; } } public static void mvMul(double[][] m, double[] v, double[] w) { // How to multiply matrices? } } </code></pre> <p>Basically, what I need is to get the 2D XY coordinates for a given screen where the 3D point intersects. I am not sure how to use the roll, tilt and pan matrices to transform the world point (wp).</p> <p>Any help with this is greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload