Shape hellShape = Shape.newBuilder().addAllFloor(hellVertices).build(); Pose hellPosition = Pose.newBuilder().setTranslation(Translation.newBuilder().setX(3).setY(1).setZ(0).build()) .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0).build()).build(); PlacementConfig hellPlacement = PlacementConfig.newBuilder().setPosition(hellPosition).setShape(hellShape).setLocationId(paradiseLocation.getId()).build(); hellLocation = locationRegistry.registerLocationConfig(UnitConfig.newBuilder().setType(UnitType.LOCATION) Shape stairwayShape = Shape.newBuilder().addAllFloor(stairwayVertices).build(); Pose stairwayPosition = Pose.newBuilder().setTranslation(Translation.newBuilder().setX(1).setY(0).setZ(0).build()) .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0).build()).build(); PlacementConfig stairwayPlacement = PlacementConfig.newBuilder().setPosition(stairwayPosition).setShape(stairwayShape).setLocationId(paradiseLocation.getId()).build(); stairwayLocation = locationRegistry.registerLocationConfig(UnitConfig.newBuilder().setType(UnitType.LOCATION) Shape heavenShape = Shape.newBuilder().addAllFloor(heavenVertices).build(); Pose heavenPosition = Pose.newBuilder().setTranslation(Translation.newBuilder().setX(1).setY(1).setZ(0).build()) .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0).build()).build(); PlacementConfig heavenPlacement = PlacementConfig.newBuilder().setPosition(heavenPosition).setShape(heavenShape).setLocationId(paradiseLocation.getId()).build(); heavenLocation = locationRegistry.registerLocationConfig(UnitConfig.newBuilder().setType(UnitType.LOCATION) Shape edenShape = Shape.newBuilder().addAllFloor(edenVertices).build(); Pose edenPosition = Pose.newBuilder().setTranslation(Translation.newBuilder().setX(0).setY(2).setZ(0).build()) .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0).build()).build(); PlacementConfig edenPlacement = PlacementConfig.newBuilder().setPosition(edenPosition).setShape(edenShape).setLocationId(heavenLocation.getId()).build(); locationRegistry.registerLocationConfig(UnitConfig.newBuilder().setType(UnitType.LOCATION)
/** * Updates the placement config based on the minimal coordinates and * dimensions of the bounding box. * * @param placementConfig the PlacementConfig to be updated. * @param minPosition the minimal coordinates of the new bounding box. * @param dimensions the dimensions of the bounding box (x: width, y: depth, * z: height). * @return the updated PlacementConfig including new Position, zero Rotation * and the updated bounding box. */ private static PlacementConfig updatePlacementConfig(PlacementConfig placementConfig, Point3d minPosition, Point3d dimensions) { PlacementConfig.Builder newBuilder = placementConfig.toBuilder(); newBuilder.setShape(newBuilder.getShapeBuilder() .setBoundingBox(AxisAlignedBoundingBox3DFloat.newBuilder() .setLeftFrontBottom(Translation.newBuilder().setX(0).setY(0).setZ(0)) .setWidth((float) dimensions.x) .setDepth((float) dimensions.y) .setHeight((float) dimensions.z))) .setPosition(Pose.newBuilder() .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0)) .setTranslation(Translation.newBuilder() .setX(minPosition.x) .setY(minPosition.y) .setZ(minPosition.z))); return newBuilder.build(); }
/** * Transforms the argument to root coordinates. * * @param rotation rotation that shall be transformed. * @return The <code>rotation</code> argument. */ private Rotation transformRotation(Rotation rotation) { Rotation.Builder transformedRotation = rotation.toBuilder().clone().clearQw().clearQx().clearQy().clearQz(); if (rotation.hasQw() && rotation.hasQx() && rotation.hasQy() && rotation.hasQz()) { Transform3D t = new Transform3D(); t.set(new Quat4d(rotation.getQw(), rotation.getQx(), rotation.getQy(), rotation.getQz())); Transform3D multiply = new Transform3D(); multiply.mul(transform, t); Quat4d result = new Quat4d(); multiply.get(result); transformedRotation.setQw(result.w).setQx(result.x).setQy(result.y).setQz(result.z); } return transformedRotation.build(); } }
/** * Gets the rotation of the unit relative to the root location as a Rotation object. * * @param unitConfig the unit config to refer the unit. * @return rotation relative to the root location * @throws NotAvailableException is thrown if the transformation is not available. */ default RotationType.Rotation getUnitRotationGlobal(final UnitConfig unitConfig) throws NotAvailableException { try { final Quat4d quat = getUnitRotationGlobalQuat4d(unitConfig); return RotationType.Rotation.newBuilder().setQw(quat.w).setQx(quat.x).setQy(quat.y).setQz(quat.z).build(); } catch (final NotAvailableException ex) { throw new NotAvailableException("GlobalRotation", ex); } }
private Pose generateDefaultInstance() { return Pose.newBuilder() .setRotation(Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0)) .setTranslation(Translation.newBuilder().setX(0).setY(0).setZ(0)).build(); } }
public static PlacementConfig getDefaultPlacement(UnitConfig location) { Rotation rotation = Rotation.newBuilder().setQw(1).setQx(0).setQy(0).setQz(0).build(); Translation translation = Translation.newBuilder().setX(0).setY(0).setZ(0).build(); Pose pose = Pose.newBuilder().setRotation(rotation).setTranslation(translation).build(); return PlacementConfig.newBuilder().setPosition(pose).setLocationId(location.getId()).build(); }