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; }
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; }
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; }
public Cartesian (Cartesian c) : this(c.X,c.Y,c.Z){}
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; }
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); }
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; }
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()); } } } } }
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()); }