diff --git a/src/data/coords/transform/toConvexHull.ts b/src/data/coords/transform/toConvexHull.ts index a3fc45a92449ffb07393a3501b6210c4c13f7203..b6a9d7ebc07c4db39c72e171e590f5c2f948adee 100644 --- a/src/data/coords/transform/toConvexHull.ts +++ b/src/data/coords/transform/toConvexHull.ts @@ -8,7 +8,7 @@ enum Orientation { } /** - * Génère une coque convexe + * Génère un contour convexe * Jarvis’s Algorithm or Wrapping * @see https://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/ */ diff --git a/src/data/coords/transform/toEllipseFitter.ts b/src/data/coords/transform/toEllipseFitter.ts index d3a683b315375c717d860e597a456157c17d6683..ce51ac8a15cc9425b884d669b72952d8d346e78d 100644 --- a/src/data/coords/transform/toEllipseFitter.ts +++ b/src/data/coords/transform/toEllipseFitter.ts @@ -113,7 +113,7 @@ export class ToEllipseFitter implements Transformation<PathCoords, Coords>{ xCenter = this.left + xoffset + 0.5; yCenter = this.top + yoffset + 0.5; - return new EllipseCoords(new paper.Point(xCenter, yCenter), major / 2, minor / 2, angle); + return new EllipseCoords(new paper.Point(xCenter, yCenter), major / 2, minor / 2, -angle); } private computeSums (path : paper.Path) : void { @@ -148,20 +148,19 @@ export class ToEllipseFitter implements Transformation<PathCoords, Coords>{ for (let y = 0; y < this.height; y++) { bitcountOfLine = 0; xSumOfLine = 0; - let offset = Math.round(y * pixelRatio) * this.width * 4; + let offset = Math.round(y * pixelRatio) * raster.width * 4; for (let x=0; x < this.width; x++) { // let point = new paper.Point(x + this.left, y + this.top) // if (point.getDistance(center) < minCenterDist // || path.contains(point)) { - if(data[offset + Math.round(x * pixelRatio) * 4] > 0 ) { + if(data[data.byteOffset + offset + Math.round(x * pixelRatio) * 4] > 0 ) { bitcountOfLine++; xSumOfLine += x; this.x2sum += x * x; } } - this.xsum += xSumOfLine; this.ysum += bitcountOfLine * y; ye = y;