//引数:表示するPuzzle, 支援システムから受け取った多角形 //戻り値:強調表示すべきピースの番号. 該当するものがなければ-1を返す. private int CalcPieceId(Puzzle puzzle, Poly piece) { List <List <Point> > initPieces = new List <List <Point> >(); int i, j; for (i = 0; i < puzzle.initPieceNum; i++) { initPieces.Add(new List <Point>()); } for (i = 0; i < puzzle.wakuLines.Count; i++) { Line line = puzzle.wakuLines[i]; if (line.initPieceId >= 0) { initPieces[line.initPieceId].Add(line.start); } } for (i = 0; i < puzzle.pieces.Count; i++) { if (!puzzle.pieces[i].isExist) { continue; } for (j = 0; j < puzzle.pieces[i].lines.Count; j++) { Line line = puzzle.pieces[i].lines[j]; if (line.initPieceId >= 0) { initPieces[line.initPieceId].Add(line.start); } } } double minA = 11451419; int ret = -1; for (i = 0; i < puzzle.initPieceNum; i++) { initPieces[i].Add(initPieces[i][0]); Poly initPiece = new Poly(initPieces[i], new List <Line>(), true, false); double eval1 = EvalCircleRadiusLog(initPiece.Clone(), piece.Clone()); double eval2 = EvalSumLengthLog(initPiece, piece.Clone()); double a = Math.Max(eval1, eval2); if (minA > a) { minA = a; ret = i; } } return(ret); }
protected override Algebraic Add(Algebraic a) { if (a is Rational) { return(a + this); } if (a is Polynomial) { var p = ( Polynomial )a; if (_v.Equals(p._v)) { int len = Math.Max(Coeffs.Length, p.Coeffs.Length); var csum = new Algebraic[len]; for (int i = 0; i < len; i++) { csum[i] = coefficient(i) + p.coefficient(i); } return((new Polynomial(_v, csum)).Reduce()); } else if (_v.Smaller(p._v)) { return(a + this); } } var _csum = Poly.Clone(Coeffs); _csum[0] = Coeffs[0] + a; return((new Polynomial(_v, _csum)).Reduce()); }
public Vector(Algebraic item) { _items = item is Vector?Poly.Clone(( Vector )item) : new[] { item }; }
public virtual Vector Coeff() { var c = Poly.Clone(Coeffs); return(new Vector(c)); }