/// Gets whether the given vector is within a rectangle from (0,0) to this /// vector (half-inclusive). public bool contains(VectorBase pos) { var left = Math.Min(0, x); if (pos.x < left) { return(false); } var right = Math.Max(0, x); if (pos.x >= right) { return(false); } var top = Math.Min(0, y); if (pos.y < top) { return(false); } var bottom = Math.Max(0, y); if (pos.y >= bottom) { return(false); } return(true); }
public CircleX(VectorBase center, int radius) { this.center = center; this.radius = radius; if (radius < 0) { throw new ArgumentOutOfRangeException("The radius cannot be negative."); } }
/// Gets whether [pos] is in the outermost edge of the circle. public bool isEdge(VectorBase pos) { var leadingEdge = true; if (radius > 0) { leadingEdge = (pos - center) > CircleUtilities.GetRadiusSquared(radius - 1); } return(leadingEdge); }
public Appearence(string glyph, string backGroundColor, string foreGroundColor, bool isExplored, bool isHidden, bool isInShadow, int x, int y, string slug, AppearenceType type) { _glyph = glyph; BackGroundColor = backGroundColor; ForeGroundColor = foreGroundColor; IsExplored = isExplored; IsHidden = isHidden; IsInShadow = isInShadow; Position = new VectorBase(x, y); Slug = slug; Type = type; }
protected bool Equals(VectorBase other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(x == other.x && y == other.y); }
private VectorBase LineIntersectsLine(VectorBase l1p1, VectorBase l1p2, VectorBase l2p1, VectorBase l2p2) { var intersectingLine = new Los(l1p1, l1p2); var queryingLine = new Los(l2p1, l2p2); foreach (var point in intersectingLine.Points) { if (queryingLine.Points.Contains(point)) { return(point); } } return(null); }
public VectorBase GetIntersect(VectorBase origin) { var center = GetCenter(); VectorBase pointOfIntersection = null; pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x, topLeft.y), new VectorBase(topLeft.x + width, topLeft.y)); if (pointOfIntersection != null) { return(pointOfIntersection); } pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x + width, topLeft.y), new VectorBase(topLeft.x + width, topLeft.y + height)); if (pointOfIntersection != null) { return(pointOfIntersection); } pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x + width, topLeft.y + height), new VectorBase(topLeft.x, topLeft.y + height)); if (pointOfIntersection != null) { return(pointOfIntersection); } pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x, topLeft.y + height), new VectorBase(topLeft.x, topLeft.y)); return(pointOfIntersection); }
public Circle(VectorBase center, int radius) { Center = center; Radius = radius; CalculatePoints(); }
public bool Intersect(VectorBase origin) { return(GetIntersect(origin) != null); }
public Rect(VectorBase position, VectorBase size) { pos = (Vector)position; this.size = (Vector)size; }
/// Scales this VectorBase by [other]. public VectorBase Scale(VectorBase obj, int other) { return(new VectorBase(obj.x * other, obj.y * other)); }