예제 #1
0
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            double shift = 0;

            if (!double.TryParse(tbShiftVal.Text, out shift))
            {
                MessageBox.Show("Shift must be a number");
                return;
            }
            if (cbShiftCoord.SelectedIndex < 0)
            {
                MessageBox.Show("Incorrect coordinate for shifting");
                return;
            }
            TransformVector tv = new TransformVector(DVector.GetOrt(cbShiftCoord.SelectedIndex, currentspace.dimnum) * shift);

            tlist.AddLast(tv);
            Draw();
        }
예제 #2
0
        public override TransformDouble ToTrDouble()
        {
            DVector origin = ApplyTo(new DVector(dimnum));

            DVector[] orts = new DVector[dimnum];
            for (int i = 0; i < dimnum; i++)
            {
                orts[i] = ApplyTo(DVector.GetOrt(i, dimnum));
            }
            double[,] mcoords = new double[dimnum, dimnum];
            for (int i = 0; i < dimnum; i++)
            {
                for (int j = 0; j < dimnum; j++)
                {
                    mcoords[i, j] = (orts[j] - origin)[i];
                }
            }
            return(new TransformDouble(new DMatrix(mcoords), origin));
        }
예제 #3
0
        public void Draw(DrawingContext dc, Point center, Transform view, DrawingRules dr, int SelectedPoint = -1, int SelectedEdge = -1)
        {
            List <Point> _2dpoints = new List <Point>();

            foreach (var p in points)
            {
                var newp = view.ApplyTo(p);
                _2dpoints.Add(newp.ConvertTo2D(center));
            }
            for (int i = 0; i < _2dpoints.Count; i++)
            {
                if (i == SelectedPoint)
                {
                    dc.DrawEllipse(dr.SelPointBrush, null, _2dpoints[i], dr.SelPointWidth, dr.SelPointWidth);
                }
                else
                {
                    dc.DrawEllipse(dr.PointBrush, null, _2dpoints[i], dr.PointWidth, dr.PointWidth);
                }
            }
            for (int i = 0; i < edges.Count; i++)
            {
                if (i == SelectedEdge)
                {
                    dc.DrawLine(dr.SelLinePen, _2dpoints[edges[i].point1], _2dpoints[edges[i].point2]);
                }
                else
                {
                    dc.DrawLine(dr.LinePen, _2dpoints[edges[i].point1], _2dpoints[edges[i].point2]);
                }
            }
            foreach (var f in faces)
            {
                PathFigure pf = new PathFigure();
                for (int i = 1; i < f.points.Count; i++)
                {
                    pf.Segments.Add(new LineSegment(_2dpoints[f.points[i]], true));
                }
                pf.StartPoint = _2dpoints[f.points[0]];
                pf.IsClosed   = true;
                PathGeometry g = new PathGeometry(new[] { pf });
                dc.DrawGeometry(dr.FaceBrush, null, g);
            }

            //coordinate lines
            //base
            dc.DrawLine(dr.BaseCoordLinePen, center, new Point(1000 + center.X, center.Y));
            dc.DrawLine(dr.BaseCoordLinePen, center, new Point(center.X, center.Y - 1000));
            //orig
            for (int i = 0; i < dimnum; i++)
            {
                dc.DrawLine(dr.CoordLinePen, (view.ApplyTo(new DVector(dimnum)).ConvertTo2D(center)), (view.ApplyTo(1000 * DVector.GetOrt(i, dimnum))).ConvertTo2D(center));
            }
        }