public bool isIn(int X, int Y) { int minInd = this.myFigure.getIndMinX(); if (X < this.myFigure[minInd].X) { return(false); } int iUp = minInd; int iDown = minInd; PtUpAndDown myCouplesUpAndDown = new PtUpAndDown(this.myFigure, minInd); int nbBoucles = 0; while (myCouplesUpAndDown.getUp().max().X < X && nbBoucles++ < this.myFigure.Count) { iUp -= myCouplesUpAndDown.downIncrement ? +1 : -1; iUp = Modulo.posModulo(iUp, this.myFigure.Count); myCouplesUpAndDown.setUp(iUp); } if (nbBoucles >= this.myFigure.Count) { return(false); } if (X == -1 && Y == -1) { int rrr = 0; } FtcLine myftcUp = FtcLine.fromPoints(myCouplesUpAndDown.getUp().max().toVector(), myCouplesUpAndDown.getUp().min().toVector()); if (myftcUp.calcY(X) < Y) { return(false); } nbBoucles = 0; while (myCouplesUpAndDown.getDown().max().X < X && nbBoucles++ < this.myFigure.Count) { iDown += myCouplesUpAndDown.downIncrement ? +1 : -1; iDown = Modulo.posModulo(iDown, this.myFigure.Count); myCouplesUpAndDown.setDown(iDown); } if (nbBoucles >= this.myFigure.Count) { return(false); } FtcLine myftcDown = FtcLine.fromPoints(myCouplesUpAndDown.getDown().max().toVector(), myCouplesUpAndDown.getDown().min().toVector()); if (myftcDown.calcY(X) > Y) { return(false); } return(true); }
//return null if ptInFigure not in figure public Point3[] getPtsAround(Point3 ptInFigure, uint precision = 1) { Point3 ptPrev, ptNext; int i = -1; FtcLine ftcLine; float calcY; do { i++; ptPrev = this[i]; ptNext = this[Modulo.posModulo(i + 1, this.Count)]; ftcLine = FtcLine.fromPoints(ptPrev.toVector(), ptNext.toVector()); calcY = ftcLine.calcY(ptInFigure.X); }while (i + 1 < this.Count && (calcY > ptInFigure.Y + precision || calcY < ptInFigure.Y - precision)); if (i + 1 == this.Count) { return(null); } return(new Point3[] { ptPrev, ptNext }); }
static public FtcLine fromVector(FloatVector vector, Point3 point) { return(FtcLine.fromPoints(point.toVector(), point.toVector().add(vector))); }