public static int Measure(BasicPath path, Jump jumpFunc, int N, MeasureCriteria criteria) { int result01 = 0; int result02 = 0; for (int i = 0; i < path.NumberOfSteps - 1; i++) { Point2D point = new Point2D(0, 0); Point2D tempPoint = path[i](point, 1); if (criteria(point, tempPoint)) { result01++; } Point2D tempPoint02 = jumpFunc(point, i, path.Height * path.Height, path.Width * path.Width, path); if (criteria(point, tempPoint02)) { result02++; } } int totalCells = N * N; int totalRegions = (N / path.Height) * (N / path.Height); return(totalRegions * result01 + (totalRegions - 1) / (path.NumberOfSteps - 1) * result02); }
public static List <Point3D> HilbertCurve(Point3D startPoint, int size, BasicPath path) { List <Point3D> result = new List <Point3D>(); if (size == 2) { //path.second? return(DoBasicMove(startPoint, path.second)); } moves = new Move[] { MoveSouth, MoveEast, MoveNorth, MoveWest }; Point3D firstStartPoint = startPoint; //List<Point3D> temp01 = HilbertCurve(firstStartPoint, size / 2, Decide(GetPointPosition(firstStartPoint), path.first)); //Point3D secondStartPoint = moves[(int)path.first](temp01[temp01.Count - 1], 1); //List<Point3D> temp02 = HilbertCurve(secondStartPoint, size / 2, Decide(GetPointPosition(secondStartPoint), path.second)); //Point3D thirdStartPoint = moves[(int)path.second](temp02[temp02.Count - 1], 1); //List<Point3D> temp03 = HilbertCurve(thirdStartPoint, size / 2, Decide(GetPointPosition(thirdStartPoint), path.third)); //Point3D fourthStartPoint = moves[(int)path.third](temp03[temp03.Count - 1], 1); ////path.third? //List<Point3D> temp04 = HilbertCurve(fourthStartPoint, size / 2, Decide(GetPointPosition(fourthStartPoint), path.third)); //result.AddRange(temp01); result.AddRange(temp02); result.AddRange(temp03); result.AddRange(temp04); return(result); }
public Path makePath(Vector2 startLocation, PathData pathData) { ILocationEquation locationEquation = getEquation(pathData.equationType); Path p = new BasicPath(locationEquation, startLocation, pathData.angleOffset, pathData.speed); return(p); }
public SpaceFillingCurve(BasicPath basicPath) { this.basicPath = basicPath; this.orderedPoints = new List <Point2D>(); Point2D tempPoint = GetStartPoint(); orderedPoints.Add(tempPoint); for (int i = 0; i < this.basicPath.NumberOfSteps - 1; i++) { tempPoint = basicPath[i](tempPoint, 1); orderedPoints.Add(tempPoint); } }
private static List <Point2D> DoBasicMove(Point2D current, BasicPath path) { List <Point2D> result = new List <Point2D>(); Point2D temp = current; result.Add(temp); for (int i = 0; i < path.NumberOfSteps - 1; i++) { temp = path[i](temp, 1); result.Add(temp); } return(result); }
public static Point2D GetStartPoint(BasicPath path) { Point2D point = new Point2D(0, 0); int deltaX = 0, deltaY = 0; for (int i = 0; i < path.NumberOfSteps - 1; i++) { point = path[i](point, 1); deltaX = Math.Min(point.X, deltaX); deltaY = Math.Min(point.Y, deltaY); } return(new Point2D(-deltaX, -deltaY)); }
public override List <Bullet> makeBullets(Vector2 location, Texture2D bulletTexture, TEAM team, double angleOffset) { List <Bullet> result = new List <Bullet>(); // Path pathLeftDiag = new BasicPath(fireShape, location, Math.PI / 8); // Path pathRightDiag = new BasicPath(fireShape, location, -Math.PI / 8); // Path pathDown = new BasicPath(fireShape, location, 0); Path pathLeftDiag = new BasicPath(left, location, -angleOffset + spread); Path pathRightDiag = new BasicPath(right, location, -spread - angleOffset); Path pathDown = new BasicPath(center, location, -angleOffset); Bullet b = new Bullet(1, pathLeftDiag, bulletTexture, team); prepareBullet(b, team); BHGame.CollisionManager.addToTeam(b, team); result.Add(b); b = new Bullet(1, pathRightDiag, bulletTexture, team); prepareBullet(b, team); BHGame.CollisionManager.addToTeam(b, team); result.Add(b); b = new Bullet(1, pathDown, bulletTexture, team); prepareBullet(b, team); BHGame.CollisionManager.addToTeam(b, team); result.Add(b); // Bullet b = new Bullet(damage, new LinearLocationEquation(direction, .1F), bulletTexture, location, team); // b.SetSize(20,30); // b.Hitbox = new CollidingRectangle(b.Location, new Vector2(0,0), 20, 30); // BHGame.CollisionManager.addToTeam(b, team); // result.Add(b); // b = new Bullet(damage, new LinearLocationEquation(weaponSpread + direction, .11F), this.bulletTexture, location, this.team); // b.SetSize(20,30); // b.Hitbox = new CollidingRectangle(b.Location, new Vector2(0,0), 20, 30); // BHGame.CollisionManager.addToTeam(b, team); // result.Add(b); // b = new Bullet(damage, new LinearLocationEquation(direction - weaponSpread, .11F), this.bulletTexture, location, this.team); // b.SetSize(20,30); // b.Hitbox = new CollidingRectangle(b.Location, new Vector2(0,0), 20, 30); // BHGame.CollisionManager.addToTeam(b, team); // result.Add(b); return(result); }
public void AddPath(IList<ITrimmedCurve> iTrimmedCurves, bool isClosed, double strokeWidth, Color? strokeColor, Color? fillColor) { Path path; if (iTrimmedCurves.Count == 1 && (iTrimmedCurves[0].Geometry is Circle || iTrimmedCurves[0].Geometry is Ellipse) && iTrimmedCurves[0].Bounds.Span == Math.PI * 2) { Ellipse ellipse = iTrimmedCurves[0].Geometry as Ellipse; if (ellipse == null) ellipse = ((Circle) iTrimmedCurves[0].Geometry).AsEllipse(); Debug.Assert(ellipse != null); path = new EllipsePath(xmlWriter, ellipse); } else { path = new BasicPath(xmlWriter, iTrimmedCurves); path.IsClosed = isClosed; } path.StrokeWidth = strokeWidth; path.StrokeColor = strokeColor; path.FillColor = fillColor; paths.Add(path); }
public Pool(BasicPath p) { this.p = p; queue = new Queue(); }
public static List <Point2D> Construct(Point2D startPoint, int height, int width, BasicPath path, Jump jumpFunc) { List <Point2D> result = new List <Point2D>(); if (height * width == path.NumberOfSteps) { return(DoBasicMove(startPoint, path)); } int newHeight = height / path.Height; int newWidth = width / path.Width; Point2D tempPoint = startPoint; for (int i = 0; i < path.NumberOfSteps; i++) { result.AddRange(Construct(tempPoint, newHeight, newWidth, path.DoTransform(i), jumpFunc)); tempPoint = jumpFunc(result[result.Count - 1], i, height, width, path); } return(result); }
public static int MeasureJumps(BasicPath path, Jump jumpFunc, int N) { return(Measure(path, jumpFunc, N, (p1, p2) => (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y) > 1)); }