private void CalcArrowEdgeVec(Point p1, Point p2, out MyVector topEdgeVec, out MyVector bottomEdgeVec) { //sin(-θ)=-sinθ //cos(-θ)=cosθ var lineVec = new MyVector(p1.X - p2.X, p1.Y - p2.Y); lineVec.Normalize(); lineVec.MultplyLen((float)ArrowEdgeLength); var rad = ArrowEdgeAngle / 2 * (Math.PI / 180); var sinθ = Math.Sin(rad); var cosθ = Math.Cos(rad); var topRotateMatrix = new MyMaxtrix(cosθ, sinθ, -sinθ, cosθ, 0, 0); var bottomRotateMatrix = new MyMaxtrix(cosθ, -sinθ, sinθ, cosθ, 0, 0); topEdgeVec = lineVec.MutliplyMatrix(topRotateMatrix); bottomEdgeVec = lineVec.MutliplyMatrix(bottomRotateMatrix); }
public static Point SubVec(this Point point, MyVector vec) { return(new Point(point.X - vec.X, point.Y - vec.Y)); }
public static Point AddVec(this Point point, MyVector vec) { return(new Point(point.X + vec.X, point.Y + vec.Y)); }
public static Point SubVec(this Point point, MyVector vec) { return new Point(point.X - vec.X, point.Y - vec.Y); }
public static Point AddVec(this Point point, MyVector vec) { return new Point(point.X + vec.X, point.Y + vec.Y); }
private void CalcArrowEdgeVec(Point p1, Point p2, out MyVector topEdgeVec, out MyVector bottomEdgeVec) { //sin(-θ)=-sinθ //cos(-θ)=cosθ var lineVec = new MyVector(p1.X - p2.X, p1.Y - p2.Y); lineVec.Normalize(); lineVec.MultplyLen((float)ArrowEdgeLength); var rad = ArrowEdgeAngle / 2 * (Math.PI / 180); var sinθ = Math.Sin(rad); var cosθ = Math.Cos(rad); var topRotateMatrix = new MyMaxtrix(cosθ, sinθ, -sinθ, cosθ, 0, 0); var bottomRotateMatrix = new MyMaxtrix(cosθ, -sinθ, sinθ, cosθ, 0, 0); topEdgeVec = lineVec.MutliplyMatrix(topRotateMatrix); bottomEdgeVec = lineVec.MutliplyMatrix(bottomRotateMatrix); }