Example #1
0
        public static DVector GetOrt(int dim, int dimnum)
        {
            DVector res = new DVector(dimnum);

            res[dim] = 1;
            return(res);
        }
Example #2
0
 //Func<DVector, double> equation { get { } }
 public Plane(DVector p1, DVector p2, DVector p3)
 {
     dimnum    = p1.DimNumber;
     basepoint = p1 * 1;
     parvect1  = p2 - p1;
     parvect2  = p3 - p1;
 }
Example #3
0
        public override DVector ApplyTo(DVector v)
        {
            DVector res = v * 1;

            foreach (var t in transforms)
            {
                res = t.ApplyTo(res);
            }
            return(res);
        }
Example #4
0
        public static DVector operator *(double b, DVector a)//multiplication by scalar
        {
            DVector res = new DVector(a.DimNumber);

            for (int i = 0; i < a.DimNumber; i++)
            {
                res[i] = a[i] * b;
            }
            return(res);
        }
Example #5
0
        public static DMatrix GetDiagMatrix(DVector diagelems)
        {
            DMatrix res = DMatrix.Get1Matrix(diagelems.DimNumber);

            for (int i = 0; i < res.DimNumber; i++)
            {
                res[i, i] = diagelems[i];
            }
            return(res);
        }
Example #6
0
        public static DVector operator +(DVector a, DVector b)
        {
            if (a.DimNumber != b.DimNumber)
            {
                throw new ArgumentException();
            }
            DVector res = new DVector(a.DimNumber);

            for (int i = 0; i < a.DimNumber; i++)
            {
                res[i] = a[i] + b[i];
            }
            return(res);
        }
        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();
        }
Example #8
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));
        }
Example #9
0
 public abstract DVector ApplyTo(DVector v);
Example #10
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));
            }
        }
 public override DVector ApplyTo(DVector v)
 {
     return(transmatr * v + transvect);
 }
 public TransformDouble(DMatrix transmatr, DVector transvect)
 {
     this.transmatr = transmatr;
     this.transvect = transvect;
 }
Example #13
0
        public static Point ConvertTo2D(this DVector vect, Point center, bool InvertY = true)
        {
            Point p = new Point(vect[0] + center.X, (InvertY ? -1 : 1) * vect[1] + center.Y);

            return(p);
        }
 public TransformVector(DVector transvect)
 {
     this.transvect = transvect;
 }
 public override DVector ApplyTo(DVector v)
 {
     return(transvect + v);
 }