public void setClockWise(LDPointList form, ClockWise cw) { for (int i = 0; i < size(); i++) { this[i].setClockWise(form, cw); } }
void normalMovement() { if (IsDou) { if (ClockWise.IsMouseDown()) { counter -= Time.deltaTime * movementSpeed; } if (AntiClockWise.IsMouseDown()) { counter += Time.deltaTime * movementSpeed; } } else { if (ClockWise.IsMouseDown()) { counter += Time.deltaTime * movementSpeed; } if (AntiClockWise.IsMouseDown()) { counter -= Time.deltaTime * movementSpeed; } } }
private void Backtrack() { // We want to go back to the last connected pixel we were in. // There can be 2 cases where a new hole pixel was found in: // straight - we will want to go counter clock 2 (+1 of the already advanced _direction) = -3 = +5 // diagonal - we will want to go counter clock 3 (+1 of the already advanced _direction) = -4 = +4 if ((int)_direction % 2 == 1) { // straight - _direction index will be in 1,3,5 or 7 _direction = (ClockWise)((int)(_direction + BACKTRACK_STRAIGHT) % 8); } else { // diagonal - _direction index will be in 2,4,6 or 0 _direction = (ClockWise)((int)(_direction + BACKTRACK_DIAGONAL) % 8); } }
private ClockWise _direction; // index to keep where are we in the clock-wise clock // 0 - w, 1 - nw, 2 - n, 3 - ne, 4 - e, 5 - se, 6 - s, 7 - sw private Pixel GetClockWisePixel(Pixel input, ImageMatrix img) { int newX, newY; do { var x_offset = _directionOffset[(int)_direction, 0]; var y_offset = _directionOffset[(int)_direction, 1]; _direction = (ClockWise)((int)(_direction + 1) % 8); newX = input.X + x_offset; newY = input.Y + y_offset; } // if edge pixels, move to next clockwise while (newX < 0 || newX >= img.LenX || newY < 0 || newY >= img.LenY); return(img.GetArrayElement(newX, newY)); }
public void setClockWise(LDPointList form, ClockWise clockWise) { Debug.Assert(form.length() > m_index1); Debug.Assert(form.length() > m_index2); Debug.Assert(form.length() > m_index3); LDPoint v0 = form.at(m_index1); LDPoint v1 = form.at(m_index2); LDPoint v2 = form.at(m_index3); //行列式で時計回りか判定 //行列式の計算。 QMatrix3x3にはないので手動で作成。 double[,] m = new double[3, 3] { { v0.x(), v0.y(), 1 }, { v1.x(), v1.y(), 1 }, { v2.x(), v2.y(), 1 } }; double determinant = m[0, 0] * m[1, 1] * m[2, 2] + m[0, 1] * m[1, 2] * m[2, 0] + m[0, 2] * m[1, 0] * m[2, 1] - m[0, 2] * m[1, 1] * m[2, 0] - m[0, 0] * m[1, 2] * m[2, 1] - m[0, 1] * m[1, 0] * m[2, 2]; ClockWise current; if (determinant < 0) //CW { current = ClockWise.CW; } else //CCWまたは3点が一直線上など { current = ClockWise.CCW; } if (clockWise != current) //設定した順番と異なる場合 Indexを入れ替える { var p = m_index1; m_index1 = m_index2; m_index2 = p; } }
public void setClockWise(LDPointList form, ClockWise clockWise) { Debug.Assert(form.length() > m_index1); Debug.Assert(form.length() > m_index2); Debug.Assert(form.length() > m_index3); LDPoint v0 = form.at(m_index1); LDPoint v1 = form.at(m_index2); LDPoint v2 = form.at(m_index3); //行列式で時計回りか判定 //行列式の計算。 QMatrix3x3にはないので手動で作成。 double[,] m = new double[3, 3]{{ v0.x(),v0.y(),1 }, { v1.x(),v1.y(),1 }, { v2.x(),v2.y(),1 }}; double determinant = m[0, 0] * m[1, 1] * m[2, 2] + m[0, 1] * m[1, 2] * m[2, 0] + m[0, 2] * m[1, 0] * m[2, 1] - m[0, 2] * m[1, 1] * m[2, 0] - m[0, 0] * m[1, 2] * m[2, 1] - m[0, 1] * m[1, 0] * m[2, 2]; ClockWise current; if (determinant < 0) //CW { current = ClockWise.CW; } else //CCWまたは3点が一直線上など { current = ClockWise.CCW; } if (clockWise != current) //設定した順番と異なる場合 Indexを入れ替える { var p = m_index1; m_index1 = m_index2; m_index2 = p; } }