List of usage examples for org.apache.commons.math.linear MatrixUtils createRealVector
public static RealVector createRealVector(double[] data)
From source file:gda.spring.propertyeditors.RealVectorPropertyEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { try {/* w w w . ja v a 2 s . com*/ // remove spaces text = text.replace(" ", ""); // remove leading/trailing braces text = text.replace("{", "").replace("}", ""); String[] valueStrings = text.split(","); double[] values = new double[valueStrings.length]; for (int j = 0; j < valueStrings.length; j++) { values[j] = Double.valueOf(valueStrings[j]); } RealVector vector = MatrixUtils.createRealVector(values); setValue(vector); } catch (Throwable e) { throw new IllegalArgumentException( "Could not convert " + StringUtils.quote(text) + " to a RealVector", e); } } else { setValue(null); } }
From source file:gda.images.camera.SampleMovementServiceBase.java
@Override public void moveSampleByMicronsAlongStandardAxes(double h, double v, double b) throws DeviceException { logger.debug(String.format("move in microns (standard axes): (h=%.2f, v=%.2f, b=%.2f)", h, v, b)); RealVector originalMovement = MatrixUtils.createRealVector(new double[] { h, v, b }); RealVector beamlineMovement = axisOrientationMatrix.operate(originalMovement); moveSampleByMicronsAlongBeamlineAxes(beamlineMovement.getEntry(0), beamlineMovement.getEntry(1), beamlineMovement.getEntry(2)); }
From source file:gda.images.camera.SampleMovementServiceBase.java
@Override public void moveSampleByMicronsAlongBeamlineAxes(double x, double y, double z) throws DeviceException { logger.debug(String.format("move in microns (beamline axes): (x=%.2f, y=%.2f, z=%.2f)", x, y, z)); double[] currentPos = getPosition(); RealVector currentPosVector = MatrixUtils.createRealVector(currentPos); logger.debug(String.format("current position is %s", currentPosVector)); RealVector move = MatrixUtils.createRealVector(new double[] { x, y, z }); RealVector newPosition = currentPosVector.add(move); logger.debug(String.format("new position is %s", newPosition)); setPosition(newPosition.getData()); }