Пример #1
0
		public Cylindrical(Cartesian v)
		{
            _r = Math.Round(Math.Sqrt(v.X * v.X + v.Y * v.Y), DP);
            _a = Pol(v.X, v.Y);
            _d = Math.Round(v.Z, DP);
			Angle += v.WindingNumber * 360.0f;
		}
Пример #2
0
		public bool Equals (Cartesian v)
		{
			
			double e =  1.0 / Math.Pow(10,DP);
			double vx = Math.Round(Math.Abs(_x - v._x),DP);
			double vy = Math.Round(Math.Abs(_y - v._y),DP);
			double vz = Math.Round(Math.Abs(_z - v._z),DP);
					
			bool same = (vx < e) && (vy < e) && (vz < e);
			return same;
		}
Пример #3
0
		public static Cartesian Linterp(Cartesian c1, double b, Cartesian c2)
		{
			Cartesian v = new Cartesian();
			v.X = b * c1.X + (1 - b) * c2.X;
			v.Y = b * c1.Y + (1 - b) * c2.Y;
			v.Z = b * c1.Z + (1 - b) * c2.Z;
			return v;
		}
Пример #4
0
		public Cartesian (Cartesian c)
            : this(c.X,c.Y,c.Z){}
Пример #5
0
 public void Update(Cartesian p)
 {
     if (p.X > MaxX)
         MaxX = p.X;
     else if (p.X < MinX)
         MinX = p.X;
     if (p.Y > MaxY)
         MaxY = p.Y;
     else if (p.Y < MinY)
         MinY = p.Y;
 }
Пример #6
0
		public Spherical (Cartesian c)
        {
            _radius = c.Length;
            _theta = OTWB.BasicLib.ToRadians * Math.Atan(c.Y / c.X);
            _thi = OTWB.BasicLib.ToRadians * Math.Acos(c.Z / _radius);
        }
Пример #7
0
 private PathFragment OffsetList(PathFragment p)
 {
     PathFragment offsets = new PathFragment();
     for (int indx = 1; indx < p.Count; indx++)
     {
         Cartesian pc = p[indx] as Cartesian;
         Cartesian pc1 = p[indx - 1] as Cartesian;
         Cartesian pnt = new Cartesian(pc.X - pc1.X,
                                  pc.Y - pc1.Y,
                                  pc.Z - pc1.Z);
        offsets.Add(pnt);
     }
     return offsets;
 }
Пример #8
0
        void GenerateSubFromPath(ref StringBuilder sb, Windows.UI.Xaml.Shapes.Path path)
        {
            CurrentPathIndex = (int)path.Tag;
            Bind(ref sb, PathStartTemplate());
            PathFragment points = new PathFragment();
            if (path.Data is GeometryGroup)
            {
                GeometryGroup gg = path.Data as GeometryGroup;
                foreach (PathGeometry pg in gg.Children)
                {
                    foreach (PathFigure pf in pg.Figures)
                    {
                                            
                        // now deal with all lines in this figure
                        foreach (PathSegment ps in pf.Segments)
                        { 
                            if (ps is LineSegment)
                            {
                                _currentPoint = _context.FirstPoint = new Cartesian(pf.StartPoint);
                                Bind(ref sb, _context.Templates.FirstPointTemplate);
                                LineSegment ls = ps as LineSegment;
                                _currentPoint = _context.LastPoint = new Cartesian(ls.Point);
                                BindableCodeTemplate tmpl = (_context.UseRotaryTable)
                                     ? _context.Templates.RA_Point_Template
                                     : _context.Templates.XY_Point_Template;
                                Bind(ref sb, tmpl);
                                Bind(ref sb, _context.Templates.LastPointTemplate);
                            }
                            if (ps is PolyLineSegment)
                            {
                                PolyLineSegment pls = ps as PolyLineSegment;
                                BindableCodeTemplate tmpl = (_context.UseRotaryTable)
                                        ? _context.Templates.RA_Point_Template
                                        : _context.Templates.XY_Point_Template;

                                _context.FirstPoint = new Cartesian(pls.Points.First());
                                _context.LastPoint = new Cartesian(pls.Points.Last());
                                foreach (Point p in pls.Points)
                                {
                                    _currentPoint = new Cartesian(p);
                                    if (_currentPoint == _context.FirstPoint)
                                    {
                                         Bind(ref sb, _context.Templates.FirstPointTemplate);
                                    }
                                    else if (_currentPoint == _context.LastPoint)
                                    {
                                        Bind(ref sb, _context.Templates.LastPointTemplate);
                                    }
                                    else
                                        Bind(ref sb, tmpl);
                                }
                               
                            }
                            Bind(ref sb, PathEndTemplate());
                        }
                    }
                }
            }
        }
Пример #9
0
        void GenerateSubFromPolygon(ref StringBuilder sb, Polygon poly)
        {
            BindableCodeTemplate tmpl;
            CurrentPathIndex = (int)poly.Tag;

            // add start of path 
            Bind(ref sb, PathStartTemplate());
            PathFragment points = new PathFragment(poly.Points);

            if (!_context.UseAbsoluteMoves)
                points = OffsetList(points);
            // loop round points in list
            _currentPoint =  _context.FirstPoint = points[0];
           
            tmpl = _context.Templates.FirstPointTemplate;
            Bind(ref sb, tmpl);

            for (int i = 1; i < points.Count - 1 ; i++)
            {
                _currentPoint = points[i];
                tmpl = (_context.UseRotaryTable)
                     ? _context.Templates.RA_Point_Template
                     : _context.Templates.XY_Point_Template;
                Bind(ref sb, tmpl);
            }
            _currentPoint =  _context.LastPoint = points[points.Count - 1];
            tmpl = _context.Templates.LastPointTemplate;
            Bind(ref sb, tmpl);
            // add end of path
            Bind(ref sb, PathEndTemplate());
        }