public RectangleE ScaleCloneBy(double val, PointE about) { RectangleE ans = new RectangleE(this); ans.ScaleSelfBy(val, about); return(ans); }
public double Dist(PointE point) { double x = X - point.X; double y = Y - point.Y; return(Math.Sqrt(x * x + y * y)); }
public RectangleE(PointE location, SizeE size) { m_X = location.X; m_Width = size.Width; m_Y = location.Y; m_Height = size.Height; }
public static PointE operator -(PointE c) { PointE ans = new PointE(); ans.X = -c.X; ans.Y = -c.Y; return(ans); }
public void UpdatePoint(PointE pointE) { if (pointE == null) { return; } m_X = pointE.m_X; m_Y = pointE.m_Y; }
public override bool Equals(object obj) { if (obj.GetType() != this.GetType()) { return(false); } PointE test = obj as PointE; return(test.X == X && test.Y == Y); }
public PointE TransformByRotationAbout(double rotation, PointE center) { PointE t = this - center; // translate to origin // apply rotation matrix cos x -sin x // sin x cos x which rotates about origin double cos = Math.Cos(rotation); double sin = Math.Sin(rotation); t = new PointE(cos * t.X - sin * t.Y, sin * t.X + cos * t.Y); return(t + center); // translate back }
public RectangleE Union(PointE pt) { if (Contains(pt)) { return(CloneRect()); } IntervalE xInt = XInterval.Union(pt.X); RectangleE ans = new RectangleE(xInt, YInterval.Union(pt.Y)); return(ans); }
public bool HasSamePoints(PointE nxtPt, double tol) { if (HasSamePoints(nxtPt)) { return(true); } if (Math.Abs(nxtPt.X - X) > tol) { return(false); } if (Math.Abs(nxtPt.Y - Y) > tol) { return(false); } return(true); //return Calc.GetDist(this, nxtPt) < tol; }
public PointE(PointE pt) : this(pt.X, pt.Y) { }
public PointE TransformByRotationAbout(double rotation, PointE center) { var t = this - center; // translate to origin // apply rotation matrix cos x -sin x // sin x cos x which rotates about origin var cos = Math.Cos(rotation); var sin = Math.Sin(rotation); t = new PointE(cos*t.X - sin*t.Y, sin*t.X + cos*t.Y); return t + center; // translate back }
public SizeE(PointE pt) : this(pt.X, pt.Y) { }
public double Dist(PointE point) { var x = X - point.X; var y = Y - point.Y; return Math.Sqrt(x*x + y*y); }
public static PointE operator -(PointE c) { var ans = new PointE(); ans.X = -c.X; ans.Y = -c.Y; return ans; }
public double Dist(PointE point) { double x = X - point.X; double y = Y - point.Y; return Math.Sqrt(x * x + y * y); }
public PointE ShiftPt(PointE offset) { return(new PointE(X + offset.X, Y + offset.Y)); }
public override IShapeE Shift(PointE point) { return(ShiftRectangle(point)); }
public bool Contains(PointE pt) { return(XInterval.Contains(pt.X) && YInterval.Contains(pt.Y)); }
public double DotProduct(PointE vector) { return(this.X * vector.X + this.Y * vector.Y); }
public virtual bool ContainsPoint(PointE point) { return(false); }
public abstract IShapeE Shift(PointE point);
public RectangleE ShiftRectangle(PointE point) { return(new RectangleE(Location.ShiftPt(point), Size)); }
public static PointE PointBetween(PointE p1, PointE p2, double frac) { return(new PointE(p1.X + (p2.X - p1.X) * frac, p1.Y + (p2.Y - p1.Y) * frac)); }
public override IShapeE Shift(PointE offset) { return(ShiftPt(offset)); }
public static PointE operator +(PointE c) { PointE ans = new PointE(); ans.X = +c.X; ans.Y = +c.Y; return ans; }
public bool HasSamePoints(PointE nxtPt) { return(nxtPt.X == X && nxtPt.Y == Y); }
public double DotProduct(PointE vector) { return this.X * vector.X + this.Y * vector.Y; }
public bool HasSamePoints(PointE nxtPt) { return nxtPt.X == X && nxtPt.Y == Y; }
public PointE AbsDifference(PointE point) { return new PointE(Math.Abs(X - point.X), Math.Abs(Y - point.Y)); }
public override IShapeE Shift(PointE offset) { return ShiftPt(offset); }
public double DotProduct(PointE vector) { return X*vector.X + Y*vector.Y; }
public static RectangleE FromMinMax(PointE minPt, PointE maxPt) { return(new RectangleE(minPt, (SizeE)(maxPt - minPt))); }
public bool HasSamePoints(PointE nxtPt, double tol) { if (HasSamePoints(nxtPt)) { return true; } if (Math.Abs(nxtPt.X - X) > tol) { return false; } if (Math.Abs(nxtPt.Y - Y) > tol) { return false; } return true; // return Calc.GetDist(this, nxtPt) < tol; }
public PointE ShiftPt(PointE offset) { return new PointE(X + offset.X, Y + offset.Y); }
public PointE AbsDifference(PointE point) { return(new PointE(Math.Abs(X - point.X), Math.Abs(Y - point.Y))); }
public override bool ContainsPoint(PointE point) { return(Contains(point)); //--simple wrapper for IShapeE compatibility }
public static PointE PointBetween(PointE p1, PointE p2, double frac) { return new PointE(p1.X + (p2.X - p1.X) * frac, p1.Y + (p2.Y - p1.Y) * frac); }
public void ScaleSelfBy(double val, PointE about) { m_Width = m_Width * val; m_Height = m_Height * val; Location = Calc.PointBetween(about, Location, val); }
public virtual bool ContainsPoint(PointE point) { return false; }