/** * Specifies the rotation offset from the canonical location using yaw and pitch. * @param yaw Radian from -pi to pi * @param pitch Radian from -pi/2 to pi/2 * @param roll Radian from -pi to pi */ public void setDirection(float yaw, float pitch, float roll ) { ConvertRotation3D_F32.eulerToMatrix(EulerType.YZX,pitch,yaw,roll,R); }
/** * Specifies the rotation offset from the canonical location using yaw and pitch. * @param yaw Radian from -pi to pi * @param pitch Radian from -pi/2 to pi/2 * @param roll Radian from -pi to pi */ public void setDirection(float yaw, float pitch, float roll ) { ConvertRotation3D_F32.eulerToMatrix(EulerType.YZX,pitch,yaw,roll,R); }
@Override public synchronized void mouseDragged(MouseEvent e) { float rotX = 0; float rotY = 0; float rotZ = 0; rotY += (e.getX() - prevX)*0.002; rotX += (prevY - e.getY())*0.002; Se3_F32 rotTran = new Se3_F32(); ConvertRotation3D_F32.eulerToMatrix(EulerType.XYZ,rotX,rotY,rotZ,rotTran.getR()); Se3_F32 temp = worldToCamera.concat(rotTran,null); worldToCamera.set(temp); prevX = e.getX(); prevY = e.getY(); repaint(); }
@Override public void keyPressed(KeyEvent e) { float pitch=0; float yaw=0; float roll=0; switch( e.getKeyCode() ) { case KeyEvent.VK_W: pitch += 0.01f; break; case KeyEvent.VK_S: pitch -= 0.01f; break; case KeyEvent.VK_A: yaw -= 0.01f; break; case KeyEvent.VK_D: yaw += 0.01f; break; case KeyEvent.VK_Q: roll -= 0.01f; break; case KeyEvent.VK_E: roll += 0.01f; break; default: return; } synchronized (imageLock) { FMatrixRMaj R = ConvertRotation3D_F32.eulerToMatrix(EulerType.YZX,yaw,roll,pitch,null); FMatrixRMaj tmp = distorter.getRotation().copy(); CommonOps_FDRM.mult(tmp,R,distorter.getRotation()); distortImage.setModel(distorter); // dirty the transform if (inputMethod == InputMethod.IMAGE) { rerenderPinhole(); } } } });
@Override public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) { synchronized (controlLock) { float deltaX = 2*(v/view.getWidth()); float deltaY = -2*(v1/view.getWidth()); FMatrixRMaj tmp1 = new FMatrixRMaj(3,3); ConvertRotation3D_F32.eulerToMatrix(EulerType.YXZ,deltaX, deltaY, 0,tmp1); FMatrixRMaj tmp2 = workR.copy(); CommonOps_FDRM.mult(tmp2,tmp1,workR); renderView(); } return true; }
@Override public void updatedOrientation(double pitch, double yaw, double roll) { synchronized (distorter) { ConvertRotation3D_F32.eulerToMatrix(EulerType.ZYX, (float)UtilAngle.degreeToRadian(yaw), (float)UtilAngle.degreeToRadian(pitch), (float)UtilAngle.degreeToRadian(roll), distorter.getRotation()); distortImage.setModel(distorter); // let it know the transform has changed if (inputMethod == InputMethod.IMAGE) { renderOutput(inputCopy); } } }
@Override public void updatedOrientation(double pitch, double yaw, double roll) { synchronized (distorter) { ConvertRotation3D_F32.eulerToMatrix(EulerType.ZYX, (float)UtilAngle.degreeToRadian(yaw), (float)UtilAngle.degreeToRadian(pitch), (float)UtilAngle.degreeToRadian(roll), distorter.getRotation()); distortImage.setModel(distorter); // let it know the transform has changed if (inputMethod == InputMethod.IMAGE) { renderOutput(inputCopy); } } }
@Override public void mouseClicked(MouseEvent e) { GeoLL_F32 geo = new GeoLL_F32(); double scale = panelEqui.scale; int x = (int)(e.getX()/scale); int y = (int)(e.getY()/scale); if( !equi.isInBounds(x,y)) return; panelPinhole.grabFocus(); synchronized (imageLock) { distorter.getTools().equiToLatLonFV(x,y,geo); distorter.setDirection(geo.lon,geo.lat,0); // pinhole has a canonical view along +z // equirectangular lon-lat uses +x // this compensates for that // roll rotation is to make the view appear "up" FMatrixRMaj A = ConvertRotation3D_F32.eulerToMatrix(EulerType.YZX, GrlConstants.F_PI/2,0,GrlConstants.F_PI/2,null); FMatrixRMaj tmp = distorter.getRotation().copy(); CommonOps_FDRM.mult(tmp,A,distorter.getRotation()); distortImage.setModel(distorter); // let it know the transform has changed if (inputMethod == InputMethod.IMAGE) { rerenderPinhole(); } } }