use of java.awt.geom.Path2D in project BoofCV by lessthanoptimal.
the class VisualizeShapes method fillPolygon.
public static void fillPolygon(Polygon2D_F64 polygon, double scale, Graphics2D g2) {
BoofSwingUtil.antialiasing(g2);
Path2D path = new Path2D.Double();
Point2D_F64 p = polygon.get(0);
path.moveTo(p.x * scale, p.y * scale);
for (int i = 1; i <= polygon.size(); i++) {
p = polygon.get(i % polygon.size());
path.lineTo(p.x * scale, p.y * scale);
}
g2.fill(path);
}
use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.
the class FourierDescriptor method makeFourierPairsReconstruction.
/**
* Reconstructs the shape obtained from FD-pairs 0,...,Mp as a polygon (path).
*
* @param Mp number of Fourier coefficient pairs
* @return reconstructed shape
*/
public Path2D makeFourierPairsReconstruction(int Mp) {
int M = G.length;
Mp = Math.min(Mp, M / 2);
int recPoints = Math.max(minReconstructionSamples, G.length * 3);
Path2D path = new Path2D.Float();
for (int i = 0; i < recPoints; i++) {
double t = (double) i / recPoints;
// assumes that coefficient 0 is never scaled
Complex pt = new Complex(getCoefficient(0));
// calculate a particular reconstruction point
for (int m = 1; m <= Mp; m++) {
Complex ep = getEllipsePoint(getCoefficient(-m), getCoefficient(m), m, t);
pt = pt.add(ep.multiply(reconstructionScale));
}
double xt = pt.re;
double yt = pt.im;
if (i == 0) {
path.moveTo(xt, yt);
} else {
path.lineTo(xt, yt);
}
}
path.closePath();
return path;
}
use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.
the class FourierDescriptor method makeEllipse.
// -----------------------------------------------------------------------
public Path2D makeEllipse(Complex G1, Complex G2, int m, double xOffset, double yOffset) {
Path2D path = new Path2D.Float();
int recPoints = Math.max(minReconstructionSamples, G.length * 3);
for (int i = 0; i < recPoints; i++) {
double t = (double) i / recPoints;
Complex p1 = this.getEllipsePoint(G1, G2, m, t);
double xt = p1.re;
double yt = p1.im;
if (i == 0) {
path.moveTo(xt + xOffset, yt + yOffset);
} else {
path.lineTo(xt + xOffset, yt + yOffset);
}
}
path.closePath();
return path;
}
use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.
the class HoughLineOverlay method markPoint.
public void markPoint(double xc, double yc, Color color) {
double markerSize = 2.0;
Path2D path = new Path2D.Double();
path.moveTo(xc - markerSize, yc);
path.lineTo(xc + markerSize, yc);
path.moveTo(xc, yc - markerSize);
path.lineTo(xc, yc + markerSize);
ShapeRoi cross = new ShapeRoi(path);
cross.setStrokeWidth(0.3);
cross.setStrokeColor(color);
this.addRoi(cross, true);
}
use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.
the class SiftOverlay method makeRoi.
@Override
public Roi makeRoi(SiftDescriptor sd) {
double x = sd.getX();
double y = sd.getY();
double scale = featureScale * sd.getScale();
double orient = sd.getOrientation() + DisplayAngleOffset;
double sin = Math.sin(orient);
double cos = Math.cos(orient);
Path2D poly = new Path2D.Double();
poly.moveTo(x + (sin - cos) * scale, y - (sin + cos) * scale);
poly.lineTo(x + (sin + cos) * scale, y + (sin - cos) * scale);
poly.lineTo(x, y);
poly.lineTo(x - (sin - cos) * scale, y + (sin + cos) * scale);
poly.lineTo(x - (sin + cos) * scale, y - (sin - cos) * scale);
poly.closePath();
return new ShapeRoi(poly);
}
Aggregations