private double ConvertPositionToDouble(AccelerometerPoint position) { double pDouble = 0.0; if (position == null) { return(pDouble); } if (GetQuarter(position) == Quarter.TopRight) { pDouble = 40 - (position.Z * 10); } else if (GetQuarter(position) == Quarter.TopLeft) { pDouble = -(position.Z * 10); } else if (GetQuarter(position) == Quarter.DownLeft) { pDouble = 20 - (-(position.Z * 10)); } else if (GetQuarter(position) == Quarter.DownRight) { pDouble = 20 + (position.Z * 10); } return(pDouble); }
private void NavigateRightLeftHandler(AccelerometerPoint position) { if (position.X < -0.2) { _panDirection = Directions.West; } else if (position.X > 0.2) { _panDirection = Directions.East; } }
private void ValuesHandler(AccelerometerReading reading) { //Set current position if (reading != null) { _currentPosition = new AccelerometerPoint(reading.AccelerationX, reading.AccelerationY, reading.AccelerationZ); } if (_isFirstTime) { if (_currentPosition != null) { _basePosition = _currentPosition; } _baseQuarter = GetQuarter(_basePosition); _portrateFreeZonePoint = new StopZoneDouble(); _portrateFreeZonePoint.From = ConvertPositionToDouble(_basePosition) + 2; _portrateFreeZonePoint.TO = ConvertPositionToDouble(_basePosition) - 2; _portrateStopZonePoint = new StopZoneDouble(); _portrateStopZonePoint.From = ConvertPositionToDouble(_portrateStopZone.From); _portrateStopZonePoint.TO = ConvertPositionToDouble(_portrateStopZone.To); _isFirstTime = false; } _panDirection = Directions.None; _currentPositionPoint = ConvertPositionToDouble(_currentPosition); NavigateRightLeftHandler(_currentPosition); NavigateUpDownHandler(_currentPositionPoint); PanTo(_panDirection); RunStoryBoard(_panDirection); }
private Quarter GetQuarter(AccelerometerPoint position) { Quarter quarter = new Quarter(); if (position.Z < 1 && position.Z > 0 && position.Y < 0 && position.Y > -1) { quarter = Quarter.TopRight; } else if (position.Z < 0 && position.Z > -1 && position.Y < 0 && position.Y > -1) { quarter = Quarter.TopLeft; } else if (position.Z < 0 && position.Z > -1 && position.Y > 0 && position.Y < 1) { quarter = Quarter.DownLeft; } else if (position.Z < 1 && position.Z > 0 && position.Y > 0 && position.Y < 1) { quarter = Quarter.DownRight; } return(quarter); }