private void CalculateArrowPoints(Point begin, Point end) { double ARROW_SIZE = 25; double deltaX = begin.X - end.X; double deltaY = begin.Y - end.Y; double length = Math.Sqrt(deltaX * deltaX + deltaY * deltaY); deltaX /= length; deltaY /= length; double leftArrowPointX = 6.5 * deltaX + deltaY; double leftArrowPointY = 6.5 * deltaY - deltaX; double rightArrowPointX = 6.5 * deltaX - deltaY; double rightArrowPointY = 6.5 * deltaY + deltaX; length = Math.Sqrt(leftArrowPointX * leftArrowPointX + leftArrowPointY * leftArrowPointY); leftArrowPointX /= length; leftArrowPointY /= length; rightArrowPointX /= length; rightArrowPointY /= length; LeftArrowPoint = new DoublePoint() { X = leftArrowPointX * ARROW_SIZE, Y = leftArrowPointY * ARROW_SIZE }; RightArrowPoint = new DoublePoint() { X = rightArrowPointX * ARROW_SIZE, Y = rightArrowPointY * ARROW_SIZE }; }
/// <summary>use Flat or flatten calls.</summary> public DoublePoint ScaleTo(DoublePoint point) { if (point.X==X && point.Y==Y) throw new InvalidOperationException("you mucker"); System.Windows.Forms.MessageBox.Show( string.Format("X: {1},Y: {0}",Y/point.Y,X/point.X) ); if (X > point.Y) { // Global.cstat(ConsoleColor.Red,"X is BIGGER"); Debug.Print("X is BIGGER"); } else { Debug.Print("X is SMALLER"); // Global.cstat(ConsoleColor.Red,"X is SMALLER"); } return this; }
public bool IsYLEq(DoublePoint P) { return IsYG(P)&IsYG(P); }
public bool IsYG(DoublePoint P) { return Y>P.Y; }
public bool IsXL(DoublePoint P) { return X<P.X; }
public bool IsXG(DoublePoint P) { return X>P.X; }
public bool IsLEq(DoublePoint p) { return (X<=p.X) && (Y<=p.Y); }
public DoublePoint GetScaledRation(DoublePoint dst) { return this*(dst/this); }
public static DoublePoint Average(params DoublePoint[] xp) { DoublePoint p = new DoublePoint(0); foreach (DoublePoint pt in xp) p += pt; return p/xp.Length; }
public DoubleRect(DoublePoint L, DoublePoint S) : this(L.X, L.Y, S.X, S.Y) { }
public DoubleRect(float x, float y, float width, float height) { Location = new DoublePoint(x, y); Size = new DoublePoint(width, height); }
/// static FromControl Methods (relative to the control) public static DoubleRect FromClientInfo(DoublePoint ClientSize, Padding pad) { return new DoubleRect(DoublePoint.GetPaddingTopLeft(pad), ClientSize - DoublePoint.GetPaddingOffset(pad)); }
public RectangleDoubleUnit(DoublePoint L, DoublePoint S) : this(L.X, L.Y, S.X, S.Y) { }
/// static FromControl Methods (relative to the control) public static RectangleDoubleUnit FromClientInfo(DoublePoint ClientSize, Padding pad) { return new RectangleDoubleUnit(DoublePoint.GetPaddingTopLeft(pad),ClientSize-DoublePoint.GetPaddingOffset(pad)); }
// ======================================================= /// ? AutoScale ? multiplies agains largest point in ?dest / source? public static DoublePoint Fit(DoublePoint dest, DoublePoint source) { return Fit(dest,source,scaleFlags.autoScale); }
/// static FromControl Methods (relative to the control) static public RectangleDoubleUnit FromControl(Control ctl, Padding pad) { return(new RectangleDoubleUnit(DoublePoint.GetPaddingTopLeft(pad), DoublePoint.GetClientSize(ctl) - DoublePoint.GetPaddingOffset(pad))); }
/// ? AutoScale ? Multiplies against largest source size: ( ( source.X | source.Y ) * ( dest / source.X | source.Y ) )<br/>? /// ScaleWidth ( dest * source.X ) public static DoublePoint Fit(DoublePoint dest, DoublePoint source, scaleFlags sf) { DoublePoint HX = dest/source; if (sf== scaleFlags.autoScale) return (HX.Y > HX.X) ? source*HX.X : source * HX.Y; else return (sf== scaleFlags.sWidth) ? source*HX.X : source*HX.Y; }
public bool IsGEq(DoublePoint p) { return (X>=p.X) && (Y>=p.Y); }
/// <summary>same as FlattenPoint overload without boolean</summary> public static DoublePoint FlattenDown(DoublePoint _pin) { return FlattenPoint(_pin); }
public bool IsXEq(DoublePoint P) { return X==P.X; }
public static DoublePoint FlattenPoint(DoublePoint _pin, bool roundUp) { DoublePoint newP = _pin.Clone(); if (newP.X==newP.Y) return newP; if (_pin.X > _pin.Y) { if (roundUp) newP.Y = newP.X; else newP.X = newP.Y; } else { if (!roundUp) newP.Y = newP.X; else newP.X = newP.Y; } return newP; }
public bool IsXGEq(DoublePoint P) { return IsXG(P)&IsXG(P); }
public static DoublePoint FlattenPoint(DoublePoint _pin) { return FlattenPoint(_pin,false); }
public bool IsYEq(DoublePoint P) { return Y==P.Y; }
public static DoublePoint FlattenUp(DoublePoint _pin) { return FlattenPoint(_pin,true); }
public bool IsYL(DoublePoint P) { return Y<P.Y; }
public void CopyPoint(DoublePoint inPoint) { X=inPoint.X; Y=inPoint.Y; }
public DoublePoint Multiply(params float[] P) { if (P.Length==0) throw new ArgumentException("there is no data!"); if (P.Length==1) return new DoublePoint(X,Y)*P[0]; DoublePoint NewPoint = new DoublePoint(X,Y)*P[0]; for (int i = 1; i < P.Length; i++) { NewPoint *= P[i]; } return NewPoint; }
public DoublePoint Divide(params DoublePoint[] P) { if (P.Length==0) throw new ArgumentException("there is no data!"); if (P.Length==1) return new DoublePoint(X,Y)/P[0]; DoublePoint NewPoint = new DoublePoint(X,Y)/P[0]; for (int i = 1; i < P.Length; i++) { NewPoint /= P[i]; } return NewPoint; }
public DoublePoint Translate(DoublePoint offset, DoublePoint zoom) { return (this+offset)*zoom; }
public DoublePoint GetRation(DoublePoint dst) { return dst/this; }
public RectangleDoubleUnit(DoublePoint L, DoublePoint S) : this(L.X,L.Y,S.X,S.Y) { }
/// static FromControl Methods (relative to the control) static public RectangleDoubleUnit FromClientInfo(DoublePoint ClientSize, Padding pad) { return(new RectangleDoubleUnit(DoublePoint.GetPaddingTopLeft(pad), ClientSize - DoublePoint.GetPaddingOffset(pad))); }