use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.
the class MathUtils method getLowerLeftCorner.
public static Position getLowerLeftCorner(List<PartialPosition> points) {
UnitUtils.Units units = points.get(0).getUnits();
Position minPos = new Position(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, units);
for (PartialPosition point : points) {
PartialPosition positionInUnits = point.getPositionIn(units);
minPos.setX(Math.min(minPos.getX(), positionInUnits.getX()));
minPos.setY(Math.min(minPos.getY(), positionInUnits.getY()));
minPos.setZ(Math.min(minPos.getZ(), positionInUnits.getZ()));
}
return new Position(minPos.getX(), minPos.getY(), minPos.getZ(), units);
}
use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.
the class MathUtilsTest method orientationWithPointsInCounterClockwiseOrder.
@Test
public void orientationWithPointsInCounterClockwiseOrder() {
PartialPosition p1 = new PartialPosition(0d, 0d, UnitUtils.Units.MM);
PartialPosition p2 = new PartialPosition(-1d, 1d, UnitUtils.Units.MM);
PartialPosition p3 = new PartialPosition(-1d, 0d, UnitUtils.Units.MM);
int orientation = MathUtils.orientation(p1, p2, p3);
assertEquals(MathUtils.COUNTER_CLOCKWISE, orientation);
}
use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.
the class TinyGUtils method generateSetWorkPositionCommand.
/**
* Generates a command for setting the axis to a position in the current coordinate system
*
* @param controllerStatus the current controller status
* @param gcodeState the current gcode state
* @param positions the position to set
* @return a command for setting the position
*/
public static String generateSetWorkPositionCommand(ControllerStatus controllerStatus, GcodeState gcodeState, PartialPosition positions) {
int offsetCode = WorkCoordinateSystem.fromGCode(gcodeState.offset).getPValue();
UnitUtils.Units currentUnits = gcodeState.getUnits();
Position machineCoord = controllerStatus.getMachineCoord().getPositionIn(currentUnits);
PartialPosition.Builder offsets = PartialPosition.builder().setUnits(currentUnits);
for (Map.Entry<Axis, Double> position : positions.getPositionIn(currentUnits).getAll().entrySet()) {
double axisOffset = -(position.getValue() - machineCoord.get(position.getKey()));
offsets.setValue(position.getKey(), axisOffset);
}
return "G10 L2 P" + offsetCode + " " + offsets.build().getFormattedGCode();
}
use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.
the class JogService method adjustManualLocationABC.
/**
* Adjusts the rotation axis location.
* @param a direction.
* @param b direction.
* @param c direction.
*/
public void adjustManualLocationABC(int a, int b, int c) {
try {
double feedRate = getFeedRate();
double stepSize = getStepSizeABC();
Units preferredUnits = getUnits();
Double da = a == 0 ? null : a * stepSize;
Double db = b == 0 ? null : b * stepSize;
Double dc = c == 0 ? null : c * stepSize;
backend.adjustManualLocation(new PartialPosition(null, null, null, da, db, dc, preferredUnits), feedRate);
} catch (Exception e) {
// NotifyDescriptor nd = new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
// DialogDisplayer.getDefault().notify(nd);
}
}
use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.
the class JogService method adjustManualLocationZ.
/**
* Adjusts the Z axis location.
* @param z direction.
*/
public void adjustManualLocationZ(int z) {
try {
double stepSize = getStepSizeZ();
if (!useStepSizeZ()) {
stepSize = getStepSizeXY();
}
double feedRate = getSettings().getJogFeedRate();
Units preferredUnits = getSettings().getPreferredUnits();
backend.adjustManualLocation(new PartialPosition(null, null, z * stepSize, preferredUnits), feedRate);
} catch (Exception e) {
// NotifyDescriptor nd = new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
// DialogDisplayer.getDefault().notify(nd);
}
}
Aggregations