/** * Translate all points with a translation vector. * * @param trans * the translation vector to apply * @param x * array of points. Point objects will be modified */ public static void translate(Vector3d trans, Point3d[] x) { for (Point3d p : x) { p.add(trans); } }
private void corruptLocationVector(Point3d location) { Vector3d randomVector = RandomTools.generateRandomVector(random, minLocationCorruption, maxLocationCorruption); location.add(randomVector); }
public Point3d getMeanPoint() { Point3d pointMean = new Point3d(); for(int i=0;i<points.size();i++) { pointMean.add(points.get(i)); } pointMean.scale(1.0/points.size()); return pointMean; } }
/** * Move the viewfrustum to the right (according to the view direction). * * @param delta */ public void moveRight( double delta ) { Vector3d deltaVector = new Vector3d( right ); deltaVector.scale( delta ); eye.add( deltaVector ); lookingAt.add( deltaVector ); setCameraParams( eye, lookingAt, up ); }
/** * Move the viewfrustum to the forward (according to the view direction). * * @param delta */ public void moveForward( double delta ) { Vector3d deltaVector = new Vector3d( backward ); deltaVector.scale( -delta ); eye.add( deltaVector ); lookingAt.add( deltaVector ); setCameraParams( eye, lookingAt, up ); }
/** * Calculate the centroid of the point cloud. * * @param x * array of points. Point objects will not be modified * @return centroid as Point3d */ public static Point3d centroid(Point3d[] x) { Point3d center = new Point3d(); for (Point3d p : x) { center.add(p); } center.scale(1.0 / x.length); return center; }
/** * 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 averagePoints(Point3d a, Point3d b) { Point3d average = new Point3d(a); average.add(b); average.scale(0.5); return average; }
public Point3d getAveragePoint() { if (averagePoint == null) { averagePoint = new Point3d(Double.NaN, Double.NaN, Double.NaN); } if (Double.isNaN(averagePoint.getX())) { averagePoint.set(0.0, 0.0, 0.0); int numberOfPoints = points.size(); for (int i = 0; i < numberOfPoints; i++) { averagePoint.add(points.get(i)); } averagePoint.scale(1.0 / ((double) numberOfPoints)); } return averagePoint; }
public static BoundingBox3d createUsingCenterAndPlusMinusVector(Point3d center, Tuple3d plusMinusVector, double epsilon) { Point3d minimumPoint = new Point3d(center); Point3d maximumPoint = new Point3d(center); minimumPoint.sub(plusMinusVector); maximumPoint.add(plusMinusVector); return new BoundingBox3d(minimumPoint, maximumPoint, epsilon); }
/** * Returns the vertices of an n-fold polygon of given radius and center * @return */ public static Point3d[] getPolygonVertices(int n, double radius, Point3d center) { Point3d[] polygon = new Point3d[n]; Matrix3d m = new Matrix3d(); for (int i = 0; i < n; i++) { polygon[i] = new Point3d(0, radius, 0); m.rotZ(i*2*Math.PI/n); m.transform(polygon[i]); polygon[i].add(center); } return polygon; }
@Override public Point3d getGeometricCenter() { run(); Point3d geometricCenter = new Point3d(); Vector3d translation = new Vector3d(); // reverseTransformationMatrix.get(translation); // TODO does this apply to the helic case? // calculate adjustment around z-axis and transform adjustment to // original coordinate frame with the reverse transformation // Vector3d corr = new Vector3d(0,minBoundary.y+getDimension().y, 0); // reverseTransformationMatrix.transform(corr); // geometricCenter.set(corr); reverseTransformationMatrix.transform(translation); geometricCenter.add(translation); return geometricCenter; }
/** * Calculates the Point on the ray that is closest to the center (0, 0, 0). * * @param origin * @param direction * @return the direction vector. */ protected static Point3d getClosestPoint(Point3d origin, Vector3d direction) { Vector3d toCenter = new Vector3d(origin); toCenter.scale(-1); Vector3d projection = getProjection(direction, toCenter); if (projection.dot(direction) < 0) { return null; } Point3d closestPoint = new Point3d(origin); closestPoint.add(projection); return closestPoint; }
private FootstepDataMessage adjustFootstepForAnkleHeight(FootstepDataMessage footstep){ FootstepDataMessage copy = new FootstepDataMessage(footstep); Point3d ankleOffset = new Point3d(0, 0, ankleHeight); RigidBodyTransform footTransform = new RigidBodyTransform(); footTransform.setRotationAndZeroTranslation(copy.getOrientation()); footTransform.transform(ankleOffset); copy.getLocation().add(ankleOffset); return copy; }
/** * Returns the vertices of an n-fold polygon of given radius and center * @return */ @Override public Point3d[] getVertices() { Point3d[] polygon = new Point3d[2*n]; Matrix3d m = new Matrix3d(); Point3d center = new Point3d(0, 0, height/2); for (int i = 0; i < n; i++) { polygon[i] = new Point3d(0, circumscribedRadius, 0); m.rotZ(i*2*Math.PI/n); m.transform(polygon[i]); polygon[n+i] = new Point3d(polygon[i]); polygon[i].sub(center); polygon[n+i].add(center); } return polygon; };
/** * Draws compass at left bottom corner of viewport. * * @param gl * gl * @param viewport * viewport */ public void drawAtLeftBottom(GL2 gl, Viewport viewport) { int distance = 70; Ray3d ray3d = viewport.picking(distance, viewport.getHeight() - distance); Point3d point = ray3d.getPoint(); Vector3d vector = ray3d.getVector(); vector.normalize(); vector.scale(1.5); point.add(vector); draw(gl, point); }
public Point3d get3DCoordinatesForSPLigands(IAtom refAtom, IAtomContainer withCoords, double length, double angle) { //logger.debug(" SP Ligands start "+refAtom.getPoint3d()+" "+(withCoords.getAtomAt(0)).getPoint3d()); Vector3d ca = new Vector3d(refAtom.getPoint3d()); ca.sub((withCoords.getAtom(0)).getPoint3d()); ca.normalize(); ca.scale(length); Point3d newPoint = new Point3d(refAtom.getPoint3d()); newPoint.add(ca); return newPoint; }
public void updateState() { double time = System.currentTimeMillis() / 1000d; double dt = time - lastTime; lastTime = time; vf = calcForwardSpeed(vf, dt, time); vs = calcSideSpeed(vs, dt, time); vu = calcUpSpeed(vu, dt, time); wh = calcHorizontallySpeed(wh, dt, time); Vector3d speed = new Vector3d(vf, vu, vs); speed = PointUtil.rotateZ3d(speed, angle.z); speed = PointUtil.rotateY3d(speed, angle.y); Vector3d dx = speed; dx.scale(dt); point.add(dx); Vector3d angleSpeed = new Vector3d(0, wh, 0); Vector3d dOmega = angleSpeed; dOmega.scale(dt); angle.add(dOmega); }
/** * Gets the center coordinates of the unit's BoundingBox in the unit coordinate system as a Point3d object. * * @param unitConfig the unit config to refer the unit. * @return center coordinates of the unit's BoundingBox relative to unit * @throws NotAvailableException is thrown if the center can not be calculate. */ default Point3d getUnitBoundingBoxCenterPoint3d(final UnitConfig unitConfig) throws NotAvailableException { final AxisAlignedBoundingBox3DFloatType.AxisAlignedBoundingBox3DFloat bb = getUnitShape(unitConfig).getBoundingBox(); final TranslationType.Translation lfc = bb.getLeftFrontBottom(); final Point3d center = new Point3d(bb.getWidth(), bb.getDepth(), bb.getHeight()); center.scale(0.5); center.add(new Point3d(lfc.getX(), lfc.getY(), lfc.getZ())); return center; }
private Point3d getMidFootPoint() { RigidBodyTransform temp = new RigidBodyTransform(); Point3d left = new Point3d(); Point3d avg = new Point3d(); fullRobotModel.getFoot(RobotSide.LEFT).getBodyFixedFrame().getTransformToDesiredFrame(temp, ReferenceFrame.getWorldFrame()); temp.transform(left); fullRobotModel.getFoot(RobotSide.RIGHT).getBodyFixedFrame().getTransformToDesiredFrame(temp, ReferenceFrame.getWorldFrame()); temp.transform(avg); avg.add(left); avg.scale(0.5); return avg; }