private void CurrentValueChanged(MotionReading e) { // Check to see if the Motion data is valid. if (motion.IsDataValid) { // Show the numeric values for attitude. yawTextBlock.Text = "YAW: " + MathHelper.ToDegrees(e.Attitude.Yaw).ToString("0") + "°"; pitchTextBlock.Text = "PITCH: " + MathHelper.ToDegrees(e.Attitude.Pitch).ToString("0") + "°"; rollTextBlock.Text = "ROLL: " + MathHelper.ToDegrees(e.Attitude.Roll).ToString("0") + "°"; // Set the Angle of the triangle RenderTransforms to the attitude of the device. ((RotateTransform)yawtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Yaw); ((RotateTransform)pitchtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Pitch); ((RotateTransform)rolltriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Roll); // Show the numeric values for acceleration. xTextBlock.Text = "X: " + e.DeviceAcceleration.X.ToString("0.00"); yTextBlock.Text = "Y: " + e.DeviceAcceleration.Y.ToString("0.00"); zTextBlock.Text = "Z: " + e.DeviceAcceleration.Z.ToString("0.00"); // Show the acceleration values graphically. xLine.X2 = xLine.X1 + e.DeviceAcceleration.X * 100; yLine.Y2 = yLine.Y1 - e.DeviceAcceleration.Y * 100; zLine.X2 = zLine.X1 - e.DeviceAcceleration.Z * 50; zLine.Y2 = zLine.Y1 + e.DeviceAcceleration.Z * 50; } }
private void UpdateMotionUI(MotionReading e) { float pitch = e.Attitude.Pitch; float yaw = e.Attitude.Yaw; float roll = e.Attitude.Roll; float accelerometerX = e.DeviceAcceleration.X; float accelerometerY = e.DeviceAcceleration.Y; float accelerometerZ = e.DeviceAcceleration.Z; float gyroscopeX = e.DeviceRotationRate.X; float gyroscopeY = e.DeviceRotationRate.Y; float gyroscopeZ = e.DeviceRotationRate.Z; float gravityX = e.Gravity.X; float gravityY = e.Gravity.Y; float gravityZ = e.Gravity.Z; StringBuilder sb = new StringBuilder(); sb.Append("Motion, raw data pitch: " + pitch); sb.Append("\nMotion, raw data yaw: " + yaw); sb.Append("\nMotion, raw data roll: " + roll); System.Diagnostics.Debug.WriteLine(sb.ToString()); DataValue.Text = sb.ToString(); }
private void CurrentValueChanged(MotionReading e) { // Check to see if the Motion data is valid. if (motion.IsDataValid) { // Show the numeric values for attitude. yawTextBlock.Text = "YAW: " + MathHelper.ToDegrees(e.Attitude.Yaw).ToString("0") + "°"; pitchTextBlock.Text = "PITCH: " + MathHelper.ToDegrees(e.Attitude.Pitch).ToString("0") + "°"; rollTextBlock.Text = "ROLL: " + MathHelper.ToDegrees(e.Attitude.Roll).ToString("0") + "°"; // Set the Angle of the triangle RenderTransforms to the attitude of the device. ((RotateTransform)yawtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Yaw); ((RotateTransform)pitchtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Pitch); ((RotateTransform)rolltriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Roll); // Show the numeric values for acceleration. xTextBlock.Text = "X: " + e.DeviceAcceleration.X.ToString("0.00"); yTextBlock.Text = "Y: " + e.DeviceAcceleration.Y.ToString("0.00"); zTextBlock.Text = "Z: " + e.DeviceAcceleration.Z.ToString("0.00"); // Show the acceleration values graphically. xLine.X2 = xLine.X1 + e.DeviceAcceleration.X * 100; yLine.Y2 = yLine.Y1 - e.DeviceAcceleration.Y * 100; zLine.X2 = zLine.X1 - e.DeviceAcceleration.Z * 50; zLine.Y2 = zLine.Y1 + e.DeviceAcceleration.Z * 50; } }
public MotionSensorReading(MotionReading motionReading) { Attitude = motionReading.Attitude; DeviceAcceleration = motionReading.DeviceAcceleration; DeviceRotationRate = motionReading.DeviceRotationRate; Gravity = motionReading.Gravity; Timestamp = motionReading.Timestamp; }
public MotionSensorReading(MotionReading motionReading) { Attitude = motionReading.Attitude; DeviceAcceleration = motionReading.DeviceAcceleration; DeviceRotationRate = motionReading.DeviceRotationRate; Gravity = motionReading.Gravity; Timestamp = motionReading.Timestamp; }
protected virtual void Update(MotionReading reading) { Device.BeginInvokeOnMainThread(() => { this.XAxis = reading.X; this.YAxis = reading.Y; this.ZAxis = reading.Z; }); }
void ReadMotion() { if (Motion.IsSupported) { MotionReading reading = sensor.CurrentValue; Vector3 gravity = reading.Gravity; gravityX.Text = "" + gravity.X; gravityY.Text = "" + gravity.Y; gravityZ.Text = "" + gravity.Z; AttitudeReading attitude = reading.Attitude; attitudeX.Text = "" + attitude.Pitch; attitudeY.Text = "" + attitude.Roll; attitudeZ.Text = "" + attitude.Yaw; } }
private void motionValue(MotionReading e) { if (motionSensor.IsDataValid) { if (Orientation == PageOrientation.PortraitUp || Orientation == PageOrientation.PortraitDown) { pitch = e.Attitude.Pitch; PitchOut.Text = Convert.ToString(MathHelper.ToDegrees((float)pitch)); } else { pitch = Math.Abs(e.Attitude.Roll); PitchOut.Text = Convert.ToString(MathHelper.ToDegrees((float)pitch)); } } }
public System.Windows.Point? getStrideIfStep(MotionReading reading) { int count = 8; double prevAcc = curAcc; curAcc = Vector3.Dot(reading.Gravity, reading.DeviceAcceleration); accelerations.Enqueue(curAcc); runningAveAcc += curAcc / count; if (accelerations.Count > count) { runningAveAcc -= accelerations.Dequeue() / count; } if (!upswing) { if (curAcc < 0 && curAcc > prevAcc) { minAcc = prevAcc; upswing = true; } } else { if (curAcc > 0 && curAcc < prevAcc) { maxAcc = curAcc; upswing = false; // From Application note AN-602: http://www.analog.com/static/imported-files/application_notes/513772624AN602.pdf double STRIDE = 60 * Math.Sqrt(Math.Sqrt(maxAcc - minAcc)); // Steps take longer than 1/4 second, and the delta acceleration is more than 1/4 g. double stepDuration = ((DateTime.Now - lastStep).TotalSeconds); lastStep = DateTime.Now; if ((stepDuration > 0.25) && (stepDuration < 2) && ((maxAcc - minAcc) > 0.25)) { Vector3 transformed = Vector3.Transform(new Vector3(-1, 0, 0), reading.Attitude.RotationMatrix); double rot = Math.Atan2(transformed.X, transformed.Y); double strideX = -STRIDE * Math.Sin(rot); double strideY = -STRIDE * Math.Cos(rot); return new System.Windows.Point(strideX, strideY); } } } return null; }
private void CurrentValueChanged(MotionReading reading) { if (viewport.Width == 0) { InitializeViewport(); } // Get the RotationMatrix from the MotionReading. // Rotate it 90 degrees around the X axis to put it in xna coordinate system. Matrix attitude = Matrix.CreateRotationX(MathHelper.PiOver2) * reading.Attitude.RotationMatrix; // Loop through the points in the list for (int i = 0; i < points.Count; i++) { // Create a World matrix for the point. Matrix world = Matrix.CreateWorld(points[i], new Vector3(0, 0, 1), new Vector3(0, 1, 0)); // Use Viewport.Project to project the point from 3D space into screen coordinates. Vector3 projected = viewport.Project(Vector3.Zero, projection, view, world * attitude); if (projected.Z > 1 || projected.Z < 0) { // If the point is outside of this range, it is behind the camera. // So hide the TextBlock for this point. textBlocks[i].Visibility = Visibility.Collapsed; } else { // Otherwise, show the TextBlock textBlocks[i].Visibility = Visibility.Visible; // Create a TranslateTransform to position the TextBlock. // Offset by half of the TextBlock's RenderSize to center it on the point. TranslateTransform tt = new TranslateTransform(); tt.X = projected.X - (textBlocks[i].RenderSize.Width / 2); tt.Y = projected.Y - (textBlocks[i].RenderSize.Height / 2); textBlocks[i].RenderTransform = tt; } } }
protected virtual MotionReading ToReading(byte[] readBuffer) { if (!BitConverter.IsLittleEndian) { Array.Reverse(readBuffer, 0, 2); Array.Reverse(readBuffer, 2, 2); Array.Reverse(readBuffer, 4, 2); } var rawX = BitConverter.ToInt16(readBuffer, 0); var rawY = BitConverter.ToInt16(readBuffer, 2); var rawZ = BitConverter.ToInt16(readBuffer, 4); var axisX = (double)rawX / UNITS_PER_G; var axisY = (double)rawY / UNITS_PER_G; var axisZ = (double)rawZ / UNITS_PER_G; var msg = new MotionReading(axisX, axisY, axisZ); return(msg); }
void sensor_CurrentValueChanged(object sender, SensorReadingEventArgs <MotionReading> e) { MotionReading reading = e.SensorReading; Dispatcher.BeginInvoke(() => { Vector3 acceleration = reading.DeviceAcceleration; // height of control = 400; height of postive bar = 200; max value = 3; // set scale at 200/3 = 67 accelX.Value = acceleration.X; accelY.Value = acceleration.Y; accelZ.Value = acceleration.Z; Vector3 gravity = reading.Gravity; // height of control = 400; height of postive bar = 200; max value = 1; // set scale at 200/1 = 200 gravityX.Value = gravity.X; gravityY.Value = gravity.Y; gravityZ.Value = gravity.Z; Vector3 rotation = reading.DeviceRotationRate; // height of control = 400; height of postive bar = 200; reasonable max value = 2pi = 6.25 (1.5 rotation per second) // set scale at 200/6.25 = 32 gyroX.Value = rotation.X; gyroY.Value = rotation.Y; gyroZ.Value = rotation.Z; AttitudeReading attitude = reading.Attitude; attitudeX.Value = attitude.Pitch; // 0->pi 200/3.14 = 64 attitudeY.Value = attitude.Roll; // 0->pi/2 200/1.57 = 128 attitudeZ.Value = attitude.Yaw; // 0->2pi 200/6.28 = 32 Vector3 worldSpacePoint = new Vector3(0.0f, 10.0f, 0.0f); Vector3 bodySpacePoint = Vector3.Transform(worldSpacePoint, attitude.RotationMatrix); point.Text = string.Format("Attitude: Transform of (0.0, 10.0, 0.0) = ({0:F1}, {1:F1}, {2:F1})", bodySpacePoint.X, bodySpacePoint.Y, bodySpacePoint.Z); }); }
private void CurrentValueChanged(MotionReading reading) { /* // If the viewport width is 0, it needs to be initialized. if (viewport.Width == 0) { InitializeViewport(); } // Get the RotationMatrix from the MotionReading. // Rotate it 90 degrees around the X axis to put it in xna coordinate system. Matrix attitude = Matrix.CreateRotationX(MathHelper.PiOver2) * reading.Attitude.RotationMatrix; // Loop through the points in the list for (int i = 0; i < points.Count; i++) { // Create a World matrix for the point. Matrix world = Matrix.CreateWorld(points[i], new Vector3(0, 0, 1), new Vector3(0, 1, 0)); // Use Viewport.Project to project the point from 3D space into screen coordinates. Vector3 projected = viewport.Project(Vector3.Zero, projection, view, world * attitude); if (projected.Z > 1 || projected.Z < 0) { // If the point is outside of this range, it is behind the camera. // So hide the TextBlock for this point. textBlocks[i].Visibility = Visibility.Collapsed; } else { // Otherwise, show the TextBlock textBlocks[i].Visibility = Visibility.Visible; // Create a TranslateTransform to position the TextBlock. // Offset by half of the TextBlock's RenderSize to center it on the point. TranslateTransform tt = new TranslateTransform(); tt.X = projected.X - (textBlocks[i].RenderSize.Width / 2); tt.Y = projected.Y - (textBlocks[i].RenderSize.Height / 2); textBlocks[i].RenderTransform = tt; } } */ }
void plotMotion(MotionReading r) { // If any of the graphs are null, we don't want to do anything if (rGraph == null || gGraph == null || bGraph == null) return; float normalizationTerm; switch (currPlotType) { // 0 => Acceleration case 0: normalizationTerm = 4.0f; rGraph.appendToArray((float)r.DeviceAcceleration.X / normalizationTerm); gGraph.appendToArray((float)r.DeviceAcceleration.Y / normalizationTerm); bGraph.appendToArray((float)r.DeviceAcceleration.Z / normalizationTerm); break; // 1 => Rotation Rate case 1: normalizationTerm = 20.0f; rGraph.appendToArray((float)r.DeviceRotationRate.X / normalizationTerm); gGraph.appendToArray((float)r.DeviceRotationRate.Y / normalizationTerm); bGraph.appendToArray((float)r.DeviceRotationRate.Z / normalizationTerm); break; // 2 => Attitude case 2: normalizationTerm = 2.0f*(float)Math.PI; rGraph.appendToArray((float)r.Attitude.Pitch / normalizationTerm); gGraph.appendToArray((float)r.Attitude.Yaw / normalizationTerm); bGraph.appendToArray((float)r.Attitude.Roll / normalizationTerm); break; } }
private float[] calcFeatureVector(MotionReading r) { float[] fv = new float[2]; float accVecMag = (float)(Math.Pow(r.DeviceAcceleration.X, 2) + Math.Pow(r.DeviceAcceleration.Y, 2) + Math.Pow(r.DeviceAcceleration.Z, 2)); fv[0] = filters[0].filter(accVecMag); fv[1] = filters[1].filter((float)r.Attitude.Yaw); return fv; }
/// <summary> /// Used to update our Reading data /// </summary> /// <param name="e"></param> static void CurrentValueChanged(MotionReading e) { //Get Yaw, Pitch, and Roll Yaw = MathHelper.ToDegrees(e.Attitude.Yaw); Pitch = MathHelper.ToDegrees(e.Attitude.Pitch); Roll = MathHelper.ToDegrees(e.Attitude.Roll); //Get the Acceleration on all 3 vectors Acceleration = new Vector3(e.DeviceAcceleration.X, e.DeviceAcceleration.Y, e.DeviceAcceleration.Z); }
private void CurrentValueChanged(MotionReading e) { //// Check to see if the Motion data is valid. if (MotionManager.Instance.motion.IsDataValid) { //// Show the numeric values for attitude. //yawTextBlock.Text = "YAW: " + MathHelper.ToDegrees(e.Attitude.Yaw).ToString("0") + "°"; //pitchTextBlock.Text = "PITCH: " + MathHelper.ToDegrees(e.Attitude.Pitch).ToString("0") + "°"; //rollTextBlock.Text = "ROLL: " + MathHelper.ToDegrees(e.Attitude.Roll).ToString("0") + "°"; //// Set the Angle of the triangle RenderTransforms to the attitude of the device. //((RotateTransform)yawtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Yaw); //((RotateTransform)pitchtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Pitch); //((RotateTransform)rolltriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Roll); // Show the numeric values for acceleration. //xTextBlock.Text = "X: " + e.DeviceAcceleration.X.ToString("0.00"); //yTextBlock.Text = "Y: " + e.DeviceAcceleration.Y.ToString("0.00"); //zTextBlock.Text = "Z: " + e.DeviceAcceleration.Z.ToString("0.00"); // Show the acceleration values graphically. //xLine.X2 = xLine.X1 + e.DeviceAcceleration.X * 100; //yLine.Y2 = yLine.Y1 - e.DeviceAcceleration.Y * 100; //zLine.X2 = zLine.X1 - e.DeviceAcceleration.Z * 50; //zLine.Y2 = zLine.Y1 + e.DeviceAcceleration.Z * 50; //this.nodderControl.SendDeviationOf( // e.DeviceAcceleration.X, // e.DeviceAcceleration.Y, // e.DeviceAcceleration.Z, // e.DeviceRotationRate.X, // e.DeviceRotationRate.Z); double Angle = 0.0; if (lastOrientation == null) { MainCandle.SetAngle(0.0); } else { switch (lastOrientation) { case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: case PageOrientation.LandscapeRight: Angle = 0.0; break; case PageOrientation.None: case PageOrientation.Portrait: case PageOrientation.PortraitDown: case PageOrientation.PortraitUp: Angle = -1.0 * (double)MathHelper.ToDegrees(e.Attitude.Roll); break; default: break; } } //DebugTextBlock.Text = lastOrientation.ToString()+ " " + Angle.ToString(); MainCandle.SetAngle(Angle); } }
/** * Do something with the motion reading in the UI thread */ public void handleMotionChange(MotionReading e) { if (m.IsDataValid) { // Round a bit int yaw = (int) MathHelper.ToDegrees(e.Attitude.Yaw); int pitch = (int)MathHelper.ToDegrees(e.Attitude.Pitch); int roll = (int)MathHelper.ToDegrees(e.Attitude.Roll); // Output yawTextBlock.Text = "Yaw: " + yaw.ToString("0") + "°"; pitchTextBlock.Text = "Pitch: " + pitch.ToString("0") + "°"; rollTextBlock.Text = "Roll: " + roll.ToString("0") + "°"; // If it's just been started we need to put in a initial position if (startOrientation == DEFAULT_ORIENTATION) { if (startCount < WAIT_SAMPLES) { startCount++; return; } startOrientation = roll; if (roll > 0) { orientation = PageOrientation.LandscapeRight; } else { orientation = PageOrientation.LandscapeLeft; } } // Figure out what state we are going to move to - check u/d then l/r if (roll > startOrientation+ZERO_HEIGHT) { if (orientation == PageOrientation.LandscapeLeft) { if (state != States.FORWARD) { setState(States.FORWARD); } } else { if (state != States.BACKWARD) { setState(States.BACKWARD); } } } else if (roll < startOrientation - ZERO_HEIGHT) { if (orientation == PageOrientation.LandscapeLeft) { if (state != States.BACKWARD) { setState(States.BACKWARD); } } else { if (state != States.FORWARD) { setState(States.FORWARD); } } } else if (pitch > ZERO_WIDTH) { if (orientation == PageOrientation.LandscapeLeft) { if (state != States.RIGHT) { setState(States.RIGHT); } } else { if (state != States.LEFT) { setState(States.LEFT); } } } else if (pitch < -ZERO_WIDTH) { if (orientation == PageOrientation.LandscapeLeft) { if (state != States.LEFT) { setState(States.LEFT); } } else { if (state != States.RIGHT) { setState(States.RIGHT); } } } else { if (state != States.OFF) { setState(States.OFF); } } } }
public void InteractMotion(MotionReading motion, DisplayOrientation orientation) { }
private void CurrentValueChanged(MotionReading reading) { Microsoft.Xna.Framework.Vector3 transformed = Microsoft.Xna.Framework.Vector3.Transform(new Microsoft.Xna.Framework.Vector3(-1, 0, 0), reading.Attitude.RotationMatrix); double rot = Math.Atan2(transformed.X, transformed.Y); if (!prevRot.HasValue || Math.Abs(rot - prevRot.Value) > 0.01) { Dispatcher.BeginInvoke(() => view.SetBaseRotation(rot)); } }
public void CurrentValueChanged(MotionReading e) { // Check to see if the Motion data is valid. }
private void CurrentValueChanged(MotionReading reading) { Vector3 transformed = Vector3.Transform(new Vector3(-1, 0, 0), reading.Attitude.RotationMatrix); double rot = Math.Atan2(transformed.X, transformed.Y); if (!prevRot.HasValue || Math.Abs(rot - prevRot.Value) > 0.01) { Dispatcher.BeginInvoke(() => { // Base rotation around what is currently in the center of the screen. var t = getTransform(funky); prevRot = t.Rotation * 2 * Math.PI / 360; double deltaRot = prevRot.Value - rot; // Get the location of the center in screen coords double centerOffsetX = (t.TranslateX + t.CenterX) - Foo.ActualWidth / 2; double centerOffsetY = (t.TranslateY + t.CenterY) - Foo.ActualHeight / 2; // Compute the movement in the offset due to the rotation double c = Math.Cos(deltaRot); double s = Math.Sin(deltaRot); double newOffsetX = centerOffsetX * c - centerOffsetY * s; double newOffsetY = centerOffsetX * s + centerOffsetY * c; // Shift the center so that the point in the center of the screen didn't move t.TranslateX += centerOffsetX - newOffsetX; t.TranslateY += centerOffsetY - newOffsetY; t.Rotation = rot * 360 / (2 * Math.PI); prevRot = rot; var ar = (CompositeTransform)this.Resources["antiRotation"]; ar.Rotation = -t.Rotation; }); } }
private void CurrentValueChanged(MotionReading e) { //// Check to see if the Motion data is valid. if (MotionManager.Instance.motion.IsDataValid) { //// Show the numeric values for attitude. //yawTextBlock.Text = "YAW: " + MathHelper.ToDegrees(e.Attitude.Yaw).ToString("0") + "°"; //pitchTextBlock.Text = "PITCH: " + MathHelper.ToDegrees(e.Attitude.Pitch).ToString("0") + "°"; //rollTextBlock.Text = "ROLL: " + MathHelper.ToDegrees(e.Attitude.Roll).ToString("0") + "°"; //// Set the Angle of the triangle RenderTransforms to the attitude of the device. //((RotateTransform)yawtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Yaw); //((RotateTransform)pitchtriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Pitch); //((RotateTransform)rolltriangle.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Roll); // Show the numeric values for acceleration. //xTextBlock.Text = "X: " + e.DeviceAcceleration.X.ToString("0.00"); //yTextBlock.Text = "Y: " + e.DeviceAcceleration.Y.ToString("0.00"); //zTextBlock.Text = "Z: " + e.DeviceAcceleration.Z.ToString("0.00"); // Show the acceleration values graphically. //xLine.X2 = xLine.X1 + e.DeviceAcceleration.X * 100; //yLine.Y2 = yLine.Y1 - e.DeviceAcceleration.Y * 100; //zLine.X2 = zLine.X1 - e.DeviceAcceleration.Z * 50; //zLine.Y2 = zLine.Y1 + e.DeviceAcceleration.Z * 50; //this.nodderControl.SendDeviationOf( // e.DeviceAcceleration.X, // e.DeviceAcceleration.Y, // e.DeviceAcceleration.Z, // e.DeviceRotationRate.X, // e.DeviceRotationRate.Z); double Angle = 0.0; if (lastOrientation == null) { MainCandle.SetAngle(0.0); } else { switch (lastOrientation) { case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: case PageOrientation.LandscapeRight: Angle = 0.0; break; case PageOrientation.None: case PageOrientation.Portrait: case PageOrientation.PortraitDown: case PageOrientation.PortraitUp: Angle = -1.0 * (double)MathHelper.ToDegrees(e.Attitude.Roll); break; default: break; } } //DebugTextBlock.Text = lastOrientation.ToString()+ " " + Angle.ToString(); MainCandle.SetAngle(Angle); } }
private void CurrentValueChanged(MotionReading e) { const double arrowWidth = 450.0; const double arrowHeight = 550.0; const double layoutWidth = 450.0; const double layoutHeight = 550.0; // Translate the image along the negative Z-axis such that it occupies 50% of the // vertical field of view. double fovY = Math.PI / 2.0; double translationZ = -arrowHeight * 0.75; // You can create a 3D effect by creating a number of simple // tranformation Matrix3D matrixes and then multiply them together. Matrix3D centerImageAtOrigin = TranslationTransform( -arrowWidth / 2.0, -arrowHeight / 2.0, 0); Matrix3D invertYAxis = CreateScaleTransform(1.0, -1.0, 1.0); Matrix3D translateAwayFromCamera = TranslationTransform(0, 0, translationZ); Matrix3D perspective = PerspectiveTransformFovRH(fovY, layoutWidth / layoutHeight, // aspect ratio 1.0, // near plane 1000.0); // far plane Matrix3D viewport = ViewportTransform(layoutWidth, layoutHeight); Matrix3D m = centerImageAtOrigin * invertYAxis; m = m * _offsetFromNorthMatrix; m = m * XnaMatrixToMatrix3D(e.Attitude.RotationMatrix); m = m * translateAwayFromCamera; m = m * perspective; m = m * viewport; CurrentMatrix = m; MotionDetermined = true; }
private void UpdateMotionUI(MotionReading e) { float pitch = e.Attitude.Pitch; float yaw = e.Attitude.Yaw; float roll = e.Attitude.Roll; float accelerometerX = e.DeviceAcceleration.X; float accelerometerY = e.DeviceAcceleration.Y; float accelerometerZ = e.DeviceAcceleration.Z; float gyroscopeX = e.DeviceRotationRate.X; float gyroscopeY = e.DeviceRotationRate.Y; float gyroscopeZ = e.DeviceRotationRate.Z; float gravityX = e.Gravity.X; float gravityY = e.Gravity.Y; float gravityZ = e.Gravity.Z; StringBuilder sb = new StringBuilder(); sb.Append("Motion, raw data pitch: " + pitch); sb.Append("\nMotion, raw data yaw: " + yaw); sb.Append("\nMotion, raw data roll: " + roll); System.Diagnostics.Debug.WriteLine(sb.ToString()); DataValue.Text = sb.ToString(); }
private void CurrentValueChanged(MotionReading e) { // Check to see if the Motion data is valid. if (motion.IsDataValid) { String q = e.Attitude.Quaternion.ToString(); // Show the numeric values for attitude. qLBL.Text = q; Browser.InvokeScript("motionValues", e.Attitude.Quaternion.X.ToString(), e.Attitude.Quaternion.Y.ToString(), e.Attitude.Quaternion.Z.ToString(), e.Attitude.Quaternion.W.ToString()); // Show the numeric values for acceleration. xLBL.Text = "X: " + e.DeviceAcceleration.X.ToString("0.00"); yLBL.Text = "Y: " + e.DeviceAcceleration.Y.ToString("0.00"); zLBL.Text = "Z: " + e.DeviceAcceleration.Z.ToString("0.00"); } }
private void UpdateUI(MotionReading e) { ((RotateTransform)Star.RenderTransform).Angle = MathHelper.ToDegrees(e.Attitude.Yaw); yawValue.Text = e.Attitude.Yaw.ToString(); }