public void RotateXAngleMinus90Grad() { var r = new Rotate3D(-Math.PI / 2.0, new double[] { 1.0, 0, 0 }); var pt_src = new Point3D(1.0, 2.0, 3.0); var pt_dest = r.Rotate(pt_src); Assert.AreEqual(1.0, Math.Round(pt_dest.X.Value, 5)); Assert.AreEqual(3.0, Math.Round(pt_dest.Y.Value, 5)); Assert.AreEqual(-2.0, Math.Round(pt_dest.Z.Value,5)); }
public void NoRotateAngle0() { var r = new Rotate3D(); var pt_src = new Point3D(1.0, 2.0, 3.0); var pt_dest = r.Rotate(pt_src); Assert.AreEqual(1.0, pt_dest.X.Value); Assert.AreEqual(2.0, pt_dest.Y.Value); Assert.AreEqual(3.0, pt_dest.Z.Value); }
public void RotateZAngle180Grad() { var r = new Rotate3D(Math.PI,new double[] { 0, 0, 1.0 }); var pt_src = new Point3D(1.0, 2.0, 3.0); var pt_dest = r.Rotate(pt_src); Assert.AreEqual(-1.0, Math.Round(pt_dest.X.Value,5)); Assert.AreEqual(-2.0, Math.Round(pt_dest.Y.Value,5)); Assert.AreEqual(3.0, pt_dest.Z.Value); }
private void GCodeUserControl_MouseMove(object sender, MouseEventArgs e) { var mousePos = e.GetPosition(this); var pt = new System.Drawing.PointF((float)mousePos.X, (float)mousePos.Y); var gcoderotated = _bitmapDraw.FromClient(pt,0.0); MouseOverPositionX = Math.Round(gcoderotated.X ?? 0, 3); MouseOverPositionY = Math.Round(gcoderotated.Y ?? 0, 3); switch (_draggingType) { case EDraggingType.NoDragging: return; case EDraggingType.Position: { _bitmapDraw.OffsetX = _mouseDownCNCOffsetX; // faster: do not assign with Dependent Property _bitmapDraw.OffsetY = _mouseDownCNCOffsetY; var c = _bitmapDraw.FromClient(pt); // recalculate with orig offset var newX = _mouseDownCNCOffsetX - (c.X.Value - _mouseDownCNCPos.X.Value); var newY = _mouseDownCNCOffsetY + (c.Y.Value - _mouseDownCNCPos.Y.Value); _bitmapDraw.OffsetX = newX; _bitmapDraw.OffsetY = newY; break; } case EDraggingType.RotateAngle: { var diffX = mousePos.X - _mouseDownPos.X; var diffY = mousePos.Y - _mouseDownPos.Y; var maxdiffX = RenderSize.Width; var maxdiffY = RenderSize.Height; var rotateX = diffX / maxdiffX; var rotateY = diffY / maxdiffY; RotateAngle = 2.0 * Math.PI * (Math.Abs(rotateX) > Math.Abs(rotateY) ? rotateX : rotateY); _rotaryVector[1] = diffX; _rotaryVector[0] = -diffY; _bitmapDraw.Rotate = _rotate = new Rotate3D(RotateAngle, _rotaryVector); break; } } if (_sw.ElapsedMilliseconds > 300) { _sw.Start(); InvalidateVisual(); } }
public void RotateXYZAngle90GradAndBack() { var r1 = new Rotate3D(Math.PI / 2.0, new double[] { 1.0, 1.0, 1.0 }); var r2 = new Rotate3D(-Math.PI / 2.0, new double[] { 1.0, 1.0, 1.0 }); var pt_src = new Point3D(1.0, 2.0, 3.0); var pt_rot = r1.Rotate(pt_src); var pt_dest = r2.Rotate(pt_rot); Assert.AreEqual(1.0, Math.Round(pt_dest.X.Value, 10)); Assert.AreEqual(2.0, Math.Round(pt_dest.Y.Value, 10)); Assert.AreEqual(3.0, Math.Round(pt_dest.Z.Value, 10)); }
public void RotateXYZAngle90Grad() { var r = new Rotate3D(Math.PI / 2.0, new double[] { 1.0, 1.0, 1.0 }); var pt_src = new Point3D(1.0, 2.0, 3.0); var pt_dest = r.Rotate(pt_src); Assert.AreEqual(Math.Round(-2.2200846792814621,10), Math.Round(pt_dest.X.Value, 10)); Assert.AreEqual(Math.Round(-1.8213672050459184, 10), Math.Round(pt_dest.Y.Value, 10)); Assert.AreEqual(Math.Round(2.3987174742355446, 10), Math.Round(pt_dest.Z.Value, 10)); }
public GCodeBitmapDraw() { Rotate = new Rotate3D(); }