Beispiel #1
0
        public void Track(Point p)
        {
            try
            {
                if (_prevHit != null && _rubikscube.NoOp)
                {
                    if (_angle == null)
                    {
                        _angle    = _rubikscube.TestAngle(p, _prevHit, out _axis);
                        _selected = _rubikscube.Select(_prevHit.HitCubicle, _axis, out _basicOp);
                        if (_selected.SelectMode == SelectMode.Cubies)
                        {
                            foreach (Cubie cubie in _selected.SelectedCubies)
                            {
                                cubie.Save();
                            }
                        }
                        else
                        {
                            _rubikscube.Save();
                        }
                        //Debug.WriteLine(string.Format("selected angle: {0}, axis:{1}", _angle, _axis));
                    }

                    if (_angle != null && (_selected.SelectedCubies != null || _selected.SelectMode == SelectMode.Cube))
                    {
                        double angle = _rubikscube.TestAngle(p, _prevHit, _axis);
                        if (System.Math.Abs(angle) < Angle.DegreesToRadians(90))
                        {
                            if (_selected.SelectMode == SelectMode.Cubies)
                            {
                                foreach (Cubie cubie in _selected.SelectedCubies)
                                {
                                    cubie.Rotate(_axis, angle, true);
                                }
                            }
                            else
                            {
                                _rubikscube.Rotate(_axis, angle, true);
                                //Debug.WriteLine(string.Format("move angle: {0}", _angle));
                            }
                            _angle = angle;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Track Error: " + e.ToString());
            }
        }
Beispiel #2
0
        public CubeSelection Select(Cubicle cubicle, Axis axis, out string basicOp)
        {
            CubeSelection cs = new CubeSelection();

            basicOp = string.Empty;
            //if (cubicle.Name.Length > 1)
            {//not center piece, select cubies
                cs.SelectMode     = SelectMode.Cubies;
                basicOp           = CubeOperation.GetBasicOp(cubicle.Name, axis).Op;
                cs.SelectedCubies = CubeOperation.BasicOps[basicOp].CubicleGroup.Select(c => _cubicles[c].Cubie);
            }

            /*
             * else //center piece
             * {
             *  cs.SelectMode = SelectMode.Cube;
             * }
             */
            return(cs);
        }