@Override public PointList clone() { final PointList p = new PointList(); for (final Point2d point2d : this) { p.points.add(point2d.copy()); } return p; }
private PointList readAMPTSPts(File file) throws IOException { final PointList pl = new PointList(); final BufferedReader br = new BufferedReader(new FileReader(file)); br.readLine(); br.readLine(); br.readLine(); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("}") && line.trim().length() > 0) { final String[] parts = line.split("\\s+"); final float x = Float.parseFloat(parts[0].trim()); final float y = Float.parseFloat(parts[1].trim()); pl.points.add(new Point2dImpl(x, y)); } } br.close(); return pl; }
private PointList readAMPTSPts(File file) throws IOException { final PointList pl = new PointList(); final BufferedReader br = new BufferedReader(new FileReader(file)); br.readLine(); br.readLine(); br.readLine(); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("}") && line.trim().length() > 0) { final String[] parts = line.split("\\s+"); final float x = Float.parseFloat(parts[0].trim()); final float y = Float.parseFloat(parts[1].trim()); pl.points.add(new Point2dImpl(x, y)); } } br.close(); return pl; }
static PointList readPts(File file) throws IOException { PointList pl = new PointList(); BufferedReader br = new BufferedReader(new FileReader(file)); br.readLine(); br.readLine(); br.readLine(); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("}") && line.trim().length() > 0) { String[] parts = line.split("\\s+"); float x = Float.parseFloat(parts[0].trim()); float y = Float.parseFloat(parts[1].trim()); pl.points.add(new Point2dImpl(x, y)); } } br.close(); return pl; }
static PointList readPts(File file) throws IOException { PointList pl = new PointList(); BufferedReader br = new BufferedReader(new FileReader(file)); br.readLine(); br.readLine(); br.readLine(); String line; while ((line = br.readLine()) != null) { if (!line.startsWith("}") && line.trim().length() > 0) { String[] parts = line.split("\\s+"); float x = Float.parseFloat(parts[0].trim()); float y = Float.parseFloat(parts[1].trim()); pl.points.add(new Point2dImpl(x, y)); } } br.close(); return pl; }
final PointList pl = new PointList();
public DragonCurve() { this.startOfDragon = new Point2dImpl(1/3f,0.5f); endOfDragon = new Point2dImpl(2/3f,0.5f); this.currentCurve = new PointList(startOfDragon,endOfDragon); }
public DragonCurve() { this.startOfDragon = new Point2dImpl(1/3f,0.5f); endOfDragon = new Point2dImpl(2/3f,0.5f); this.currentCurve = new PointList(startOfDragon,endOfDragon); }
final PointList pl = new PointList();
/** * Compute the mean of a set of {@link PointList}s. It is assumed that the * number of points in the {@link PointList}s is equal, and that their is a * one-to-one correspondance between the ith point in each list. * * @param shapes * the shapes to average * @return the average shape */ public static PointList computeMean(Collection<PointList> shapes) { final int npoints = shapes.iterator().next().points.size(); final PointList mean = new PointList(); for (int i = 0; i < npoints; i++) mean.points.add(new Point2dImpl()); for (final PointList shape : shapes) { for (int i = 0; i < npoints; i++) { final Point2dImpl pt = (Point2dImpl) mean.points.get(i); pt.x += shape.points.get(i).getX(); pt.y += shape.points.get(i).getY(); } } for (int i = 0; i < npoints; i++) { final Point2dImpl pt = (Point2dImpl) mean.points.get(i); pt.x /= shapes.size(); pt.y /= shapes.size(); } return mean; }
final PointList pl = new PointList(centers); final Polygon hull = pl.calculateConvexHull(); centers.set(skip, temp);
/** * Generate a plausible new shape from the scaling vector. The scaling * vector is constrained by the underlying {@link Constraint} before being * used to generate the model. * * @param scaling * scaling vector. * @return a new shape */ public PointList generateNewShape(double[] scaling) { final PointList newShape = new PointList(); final double[] pts = pc.generate(constraint.apply(scaling, pc.getEigenValues())); for (int i = 0; i < pts.length; i += 2) { final float x = (float) pts[i]; final float y = (float) pts[i + 1]; newShape.points.add(new Point2dImpl(x, y)); } return newShape; }
@Override public IndependentPair<PointList, IMAGE> read(FileObject source) throws IOException { final PointList pl = new PointList(); BufferedReader br = null;
@Override public IndependentPair<PointList, IMAGE> read(FileObject source) throws IOException { final PointList pl = new PointList(); BufferedReader br = null;
/** * {@inheritDoc} * @see org.openimaj.vis.video.VideoBarVisualisation#updateVis(org.openimaj.image.MBFImage) */ @Override public void updateVis( final MBFImage vis ) { final float scalar = vis.getHeight() / this.frameHeight; // Redraw each of the positions. int frame = 0; for( final PointList pos : this.objectPositions ) { final PointList pp = new PointList( pos.points, true ); pp.scale( scalar ); this.drawType.draw( vis, (int)this.getTimePosition( frame ), 0, pp ); frame++; } } }
@Override public IndependentPair<PointList, IMAGE> read(FileObject source) throws IOException { final PointList pl = new PointList(); BufferedReader br = null;
@Override public IndependentPair<PointList, IMAGE> read(FileObject source) throws IOException { final PointList pl = new PointList(); BufferedReader br = null;
PointList newShape = new PointList();
/** * Apply a 3x3 transform matrix to a copy of the {@link PointList} and * return it * * @param transform * 3x3 transform matrix * @return the transformed {@link PointList} */ @Override public PointList transform(Matrix transform) { final List<Point2d> newVertices = new ArrayList<Point2d>(); for (final Point2d p : points) { final Matrix p1 = new Matrix(3, 1); p1.set(0, 0, p.getX()); p1.set(1, 0, p.getY()); p1.set(2, 0, 1); final Matrix p2_est = transform.times(p1); final Point2d out = new Point2dImpl((float) (p2_est.get(0, 0) / p2_est.get(2, 0)), (float) (p2_est.get(1, 0) / p2_est.get(2, 0))); newVertices.add(out); } return new PointList(newVertices); }
PointList newShape = new PointList();