/** * Computes if the point is in the region projected onto the world xy-plane. * * @param x x-coordinate of the query. * @param y y-coordinate of the query. * @return true if the point is inside this region, false otherwise. */ public boolean isPointInsideByProjectionOntoXYPlane(double x, double y) { Point3D localPoint = new Point3D(); localPoint.setX(x); localPoint.setY(y); localPoint.setZ(getPlaneZGivenXY(x, y)); fromWorldToLocalTransform.transform(localPoint); return isPointInside(localPoint.getX(), localPoint.getY()); }
@ContinuousIntegrationTest(estimatedDuration = 0.1) @Test(timeout = 30000) public void testYCase() { Random gen = new Random(124L); for (int i = 0; i < 100000; i++) { Point3D point1 = RandomGeometry.nextPoint3D(gen, -1000, -1000, -1000, 1000, 1000, 1000); Point3D point2 = RandomGeometry.nextPoint3D(gen, -1000, -1000, -1000, 1000, 1000, 1000); point2.setY(point1.getY()); double s = RandomNumbers.nextDouble(gen, 0, 1); Point3D temp = new Point3D(point1); temp.scale(1 - s); Point3D point3 = new Point3D(temp); temp.set(point2); temp.scale(s); point3.add(temp); runTest(point1.getX(), point1.getY(), point1.getZ(), point2.getX(), point2.getY(), point2.getZ(), point3.getX(), point3.getY(), point3.getZ()); } }
protected boolean isValidNearScan(Point3D point, Point3D lidarOrigin) { boolean valid = true; valid &= point.getZ() < lidarOrigin.getZ() + parameters.nearScanZMaxAboveHead; Point3D center = new Point3D(lidarOrigin.getX(), lidarOrigin.getY(), point.getZ()); valid &= point.distance(center) < parameters.nearScanRadius; return valid; }
@ContinuousIntegrationTest(estimatedDuration = 0.1) @Test(timeout = 30000) public void testXCase() { Random gen = new Random(124L); for (int i = 0; i < 100000; i++) { Point3D point1 = RandomGeometry.nextPoint3D(gen, -1000, -1000, -1000, 1000, 1000, 1000); Point3D point2 = RandomGeometry.nextPoint3D(gen, -1000, -1000, -1000, 1000, 1000, 1000); point2.setX(point1.getX()); double s = RandomNumbers.nextDouble(gen, 0, 1); Point3D temp = new Point3D(point1); temp.scale(1 - s); Point3D point3 = new Point3D(temp); temp.set(point2); temp.scale(s); point3.add(temp); runTest(point1.getX(), point1.getY(), point1.getZ(), point2.getX(), point2.getY(), point2.getZ(), point3.getX(), point3.getY(), point3.getZ()); } }
@Test public void testOrthogonalProjectionBottom() { double height = 2.0; double radius = 1.0; Cylinder3D cylinder3d = new Cylinder3D(height, radius); Point3D pointToCheckAndPack = new Point3D(0.5, 0.25, -height); Point3D expectedProjection = new Point3D(pointToCheckAndPack.getX(), pointToCheckAndPack.getY(), -1.0); cylinder3d.orthogonalProjection(pointToCheckAndPack); assertPointEquals(expectedProjection, pointToCheckAndPack); }
public static void applyTranform(Transform transform, Point3D pointToTransform) { javafx.geometry.Point3D temporaryVector = transform.transform(pointToTransform.getX(), pointToTransform.getY(), pointToTransform.getZ()); pointToTransform.set(temporaryVector.getX(), temporaryVector.getY(), temporaryVector.getZ()); }
private Point3D computeFinalPosition(Point3D initialPosition, double ballVelocityMagnitude) { tempPoint.set(ballTarget.getX(), ballTarget.getY(), ballTarget.getZ()); double distance = initialPosition.distance(tempPoint); double estimatedCollisionTime = distance / ballVelocityMagnitude; Point3D ret = new Point3D(ballTargetVelocity); ret.scale(estimatedCollisionTime); ret.add(tempPoint); return ret; }
@Override public void handle(MouseEvent event) { PickResult pickResult = event.getPickResult(); Node intersectedNode = pickResult.getIntersectedNode(); if (intersectedNode == null || intersectedNode instanceof SubScene) return; javafx.geometry.Point3D localPoint = pickResult.getIntersectedPoint(); javafx.geometry.Point3D scenePoint = intersectedNode.getLocalToSceneTransform().transform(localPoint); Point3D interception = new Point3D(); interception.setX(scenePoint.getX()); interception.setY(scenePoint.getY()); interception.setZ(scenePoint.getZ()); latestInterception.set(interception); } };
/** * Returns the average of two 3D points. * <p> * WARNING: This method generates garbage. * </p> * * @param a the first 3D point. Not modified. * @param b the second 3D point. Not modified. * @return the computed average. */ public static Point3D averagePoint3Ds(Point3DReadOnly a, Point3DReadOnly b) { Point3D average = new Point3D(a); average.add(b); average.scale(0.5); return average; }
public static EuclideanTrajectoryPointMessage createEuclideanTrajectoryPointMessage(double time, Point3DReadOnly position, Vector3DReadOnly linearVelocity) { EuclideanTrajectoryPointMessage message = new EuclideanTrajectoryPointMessage(); message.setTime(time); message.getPosition().set(new Point3D(position)); message.getLinearVelocity().set(new Vector3D(linearVelocity)); return message; }
@Override public boolean checkIfInside(double x, double y, double z, Point3D intersectionToPack, Vector3D normalToPack) { tempPoint3dForCheckInside.setX(x); tempPoint3dForCheckInside.setY(y); tempPoint3dForCheckInside.setZ(z); boolean isPointInside = planarRegion.isPointOnOrSlightlyBelow(tempPoint3dForCheckInside, allowablePenetrationThickness); if (isPointInside) { if (intersectionToPack != null) { intersectionToPack.set(tempPoint3dForCheckInside); } if (normalToPack != null) { planarRegion.getNormal(normalToPack); } } return isPointInside; }
@Override public boolean isPossibleGround(Point3D point, Point3D lidarOrigin) { Point3D footAvg = getMidFootPoint(); double footZ = footAvg.getZ(); footAvg.setZ(point.getZ()); double maxHeight = parameters.quadTreeZAboveFeet + point.distance(footAvg) * parameters.quadTreeZSlope; if (maxHeight > parameters.quadTreeZMax) { maxHeight = parameters.quadTreeZMax; } return (point.getZ() - footZ) < maxHeight; }
/** * Sets the initial SCS camera position. * @param positionX * @param positionY * @param positionZ */ public void setSCSCameraPosition(double positionX, double positionY, double positionZ) { scsCameraPosition.set(positionX, positionY, positionZ); }
private static List<Point3D> createRandomDataset(Random random, Point3D average, int length, Vector3D maxAmplitude) { List<Point3D> dataset = new ArrayList<>(length); Point3D min = new Point3D(); Point3D max = new Point3D(); min.sub(average, maxAmplitude); max.add(average, maxAmplitude); for (int i = 0; i < length; i++) dataset.add(RandomGeometry.nextPoint3D(random, min, max)); return dataset; }
private static void formStaircaseWithPointsOnAPlane(ArrayList<Point3D> pointsList, double stairSeparation, double oneStairLandingHeight) { for (Point3D point3d : pointsList) { double z = point3d.getZ(); double newZ = Math.floor((z - oneStairLandingHeight) / stairSeparation) * stairSeparation; point3d.setZ(newZ); } }
@Test public void testHashCode() throws Exception { Random random = new Random(621541L); Point3D tuple1 = createEmptyTuple(); tuple1.setX(random.nextDouble()); tuple1.setY(random.nextDouble()); tuple1.setZ(random.nextDouble()); int newHashCode, previousHashCode; newHashCode = tuple1.hashCode(); assertEquals(newHashCode, tuple1.hashCode()); previousHashCode = tuple1.hashCode(); for (int i = 0; i < ITERATIONS; i++) { tuple1.setElement(i % 3, random.nextDouble()); newHashCode = tuple1.hashCode(); assertNotEquals(newHashCode, previousHashCode); previousHashCode = newHashCode; } }