Translates a by the negative of a given .
public void ApplyPoint(PointF point) { var offset = point.Subtract(_startPoint); if (points.Count == 0) { points.Add(new GesturePoint { X = offset.X, Y = offset.Y, threshold = 10 }); } else { var last = points.Last(); var lastPoint = new PointF(last.X, last.Y); // first check distance from last point if (lastPoint.DistanceTo(offset) > 10) { var currentAngle = _previousOffset.AngleTo(offset); var previousAngle = lastPoint.AngleTo(_previousOffset); var da = currentAngle - previousAngle; if (da < -Math.PI) da += 2 * Math.PI; if (da > Math.PI) da -= 2 * Math.PI; if (da > 0.1) { AddPoint(_previousOffset); } } } _previousOffset = offset; }
public static float Subtend(this PointF point, PointF a1, PointF a2) { a1 = a1.Subtract(point); a2 = a2.Subtract(point); float angleA = a1.Angle(), angleB = a2.Angle(); if (angleA > angleB) { float swap = angleA; angleA = angleB; angleB = swap; } return (float)((angleB - angleA + (Math.PI * 2)) % (Math.PI * 2)); }
/// <summary>Translates a <see cref="T:System.Drawing.PointF" /> by the negative of a given <see cref="T:System.Drawing.Size" />.</summary> /// <returns>The translated <see cref="T:System.Drawing.PointF" />.</returns> /// <param name="pt">The <see cref="T:System.Drawing.PointF" /> to translate.</param> /// <param name="sz">The <see cref="T:System.Drawing.Size" /> that specifies the numbers to subtract from the coordinates of <paramref name="pt" />.</param> /// <filterpriority>3</filterpriority> public static PointF operator -(PointF pt, Size sz) { return(PointF.Subtract(pt, sz)); }
private bool TestCrossing(GestureQuad quad, PointF p, PointF p2) { var q = quad.C; var q2 = quad.D; var r = p2.Subtract(p); var s = q2.Subtract(q); var qp = q.Subtract(p); var rs = r.Cross(s); // parallel case if (rs == 0) return false; var t = qp.Cross(s) / rs; var u = qp.Cross(r) / rs; return (t >= 0 && t <= 1 && u >= 0 && u <= 1); }
/// <summary> /// Checks if two points are within a certain distance from each other. /// </summary> public static bool Equals(this PointF value, PointF other, double maxDistance) => value.Subtract(other).LengthSquared() < maxDistance * maxDistance;
public static Rectangle FromCenterSize(PointF Center, PointF Size) { Size = Size.Divide(2); return new Rectangle(new Line(Center.Subtract(Size), Center.Add(Size))); }