/// <summary> /// Adds all of the points in the polygon to this instance. /// </summary> /// <param name="polygon">The Polygon</param> public void Add(Polygon polygon) { foreach (var point in polygon.Points) { this.Points.Add(point); } }
public static Polygon ToPolygon(this List<IntPoint> v) { var polygon = new Polygon(); foreach (var point in v) { polygon.Add(new Vector2(point.X, point.Y)); } return polygon; }
// perform xor public static Paths ClipperXor(this Polygon clip, Polygon subject) { var subj = new Paths(); subj.Add(subject.ToClipperPath()); var clp = new Paths(); clp.Add(clip.ToClipperPath()); var result = new Paths(); var c = new Clipper(); c.Execute(ClipType.ctXor, result, PolyFillType.pftPositive, PolyFillType.pftPositive); return result; }
public static Polygon PathsToPolygon(this Paths paths) { var result = new Polygon(); foreach (var path in paths) { foreach (var point in path) { result.Add(new Vector2(point.X, point.Y)); } } return result; }
internal override void UpdatePolygon() { Polygon = new Polygon(); var angle = 60; var edge1 = (this.EndPosition - this.Caster.ServerPosition.ToVector2()).Rotated( -angle / 2 * (float)Math.PI / 180); var edge2 = edge1.Rotated(angle * (float)Math.PI / 180); var positions = new List<Vector2>(); //detect syndra q which havent exploded yet var explodingQ = Tracker.DetectedSkillshots.FirstOrDefault(p => p.SData.SpellName == "SyndraQ"); if (explodingQ != null) positions.Add(explodingQ.EndPosition); //detect syndra qs which have already exploded var seeds = ObjectManager.Get<Obj_AI_Minion>().Where(p => p.Name == "Seed" && !p.IsDead && p.Team == this.Caster.Team).Select(q => q.ServerPosition.ToVector2()); foreach (var seed in seeds) positions.Add(seed); foreach (var position in positions) { var v = position - this.Caster.ServerPosition.ToVector2(); if (edge1.CrossProduct(v) > 0 && v.CrossProduct(edge2) > 0 && position.Distance(this.Caster.ServerPosition) < 800) { var start = position; var end = this.Caster.ServerPosition.ToVector2() .Extend( position, this.Caster.Distance(position) > 200 ? 1300 : 1000); Polygon.Add(new RectanglePoly(start, end, this.SData.Width)); } } this.UpdatePath(); }
public static bool IsOutside(this Vector2 point, Polygon poly) { var p = new IntPoint(point.X, point.Y); return Clipper.PointInPolygon(p, poly.ToClipperPath()) != 1; }
public Polygon ToPolygon(int offset = 0) { var result = new Polygon(); var outRadius = (offset + Radius + RingRadius) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); var innerRadius = Radius - RingRadius - offset; for (var i = 0; i <= CircleLineSegmentN; i++) { var angle = i * 2 * Math.PI / CircleLineSegmentN; var point = new Vector2( Center.X - outRadius * (float)Math.Cos(angle), Center.Y - outRadius * (float)Math.Sin(angle)); result.Add(point); } for (var i = 0; i <= CircleLineSegmentN; i++) { var angle = i * 2 * Math.PI / CircleLineSegmentN; var point = new Vector2( Center.X + innerRadius * (float)Math.Cos(angle), Center.Y - innerRadius * (float)Math.Sin(angle)); result.Add(point); } return result; }
public Polygon ToPolygon(int offset = 0, float overrideWidth = -1) { var result = new Polygon(); var outRadius = overrideWidth > 0 ? overrideWidth : (offset + Radius) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); for (var i = 1; i <= CircleLineSegmentN; i++) { var angle = i * 2 * Math.PI / CircleLineSegmentN; var point = new Vector2( Center.X + outRadius * (float)Math.Cos(angle), Center.Y + outRadius * (float)Math.Sin(angle)); result.Add(point); } return result; }
public static Polygon ToPolygon(this List<IntPoint> v) { var polygon = new Polygon(); v.ForEach(i => polygon.Add(new Vector2(i.X, i.Y))); return polygon; }
public Polygon ToPolygon(int offset = 0) { var result = new Polygon(); var outRadius = (this.Radius + offset) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); result.Add(this.Center); var side1 = this.Direction.LSRotated(-this.Angle * 0.5f); for (var i = 0; i <= CircleLineSegmentN; i++) { var cDirection = side1.LSRotated(i * this.Angle / CircleLineSegmentN).LSNormalized(); result.Add( new Vector2(this.Center.X + outRadius * cDirection.X, this.Center.Y + outRadius * cDirection.Y)); } return result; }
public Polygon ToPolygon(int offset = 0, float overrideWidth = -1) { var result = new Polygon(); result.Add( this.RStart + (overrideWidth > 0 ? overrideWidth : this.Width + offset) * this.Perpendicular - offset * this.Direction); result.Add( this.RStart - (overrideWidth > 0 ? overrideWidth : this.Width + offset) * this.Perpendicular - offset * this.Direction); result.Add( this.REnd - (overrideWidth > 0 ? overrideWidth : this.Width + offset) * this.Perpendicular + offset * this.Direction); result.Add( this.REnd + (overrideWidth > 0 ? overrideWidth : this.Width + offset) * this.Perpendicular + offset * this.Direction); return result; }
public Polygon ToPolygon(int offset = 0, float overrideWidth = -1) { var result = new Polygon(); var outRadius = overrideWidth > 0 ? overrideWidth : (offset + this.Radius) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); const double Step = 2 * Math.PI / CircleLineSegmentN; var angle = (double)this.Radius; for (var i = 0; i <= CircleLineSegmentN; i++) { angle += Step; var point = new Vector2( this.Center.X + outRadius * (float)Math.Cos(angle), this.Center.Y + outRadius * (float)Math.Sin(angle)); result.Add(point); } return result; }
public Polygon ToPolygon(int offset = 0) { offset += this.HitBox; var result = new Polygon(); var innerRadius = -0.1562f * this.Distance + 687.31f; var outerRadius = 0.35256f * this.Distance + 133f; outerRadius = outerRadius / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); var innerCenters = this.Start.CircleCircleIntersection(this.End, innerRadius, innerRadius); var outerCenters = this.Start.CircleCircleIntersection(this.End, outerRadius, outerRadius); var innerCenter = innerCenters[0]; var outerCenter = outerCenters[0]; Render.Circle.DrawCircle(innerCenter.ToVector3(), 100, Color.White); var direction = (this.End - outerCenter).LSNormalized(); var end = (this.Start - outerCenter).LSNormalized(); var maxAngle = (float)(direction.AngleBetween(end) * Math.PI / 180); var step = -maxAngle / CircleLineSegmentN; for (var i = 0; i < CircleLineSegmentN; i++) { var angle = step * i; var point = outerCenter + (outerRadius + 15 + offset) * direction.LSRotated(angle); result.Add(point); } direction = (this.Start - innerCenter).LSNormalized(); end = (this.End - innerCenter).LSNormalized(); maxAngle = (float)(direction.AngleBetween(end) * Math.PI / 180); step = maxAngle / CircleLineSegmentN; for (var i = 0; i < CircleLineSegmentN; i++) { var angle = step * i; var point = innerCenter + Math.Max(0, innerRadius - offset - 100) * direction.LSRotated(angle); result.Add(point); } return result; }
public Polygon ToPolygon(int offset = 0) { var result = new Polygon(); var outRadius = (Radius + offset) / (float)Math.Cos(2 * Math.PI / CircleLineSegmentN); result.Add(Center); var Side1 = Direction.Rotated(-Angle * 0.5f); for (var i = 0; i <= CircleLineSegmentN; i++) { var cDirection = Side1.Rotated(i * Angle / CircleLineSegmentN).Normalized(); result.Add(new Vector2(Center.X + outRadius * cDirection.X, Center.Y + outRadius * cDirection.Y)); } return result; }
public static bool IsInside(this Vector2 point, Polygon polygon) { return !polygon.IsOutside(point); }
public static bool IsInside(this Vector3 position, Polygon polygon) { return position.ToVector2().IsInside(polygon); }