public Line(PointF p1, VectorF vec) { P1 = p1; P2 = p1 + vec; GeometryHelper.CalcABC(P1, P2, out A, out B, out C); Type = LineType.Ray; }
public bool HitTest(RectF rect, float scale) { if (_height == 0 || _width == 0) { return(false); } var height = _height / scale; var hwidth = _width / (2 * scale); var b = _origin + _direction * height; var hdir = new VectorF(_direction.Y, -_direction.X); var wl = hdir * hwidth; var p1 = b + wl; var p2 = b - wl; var line1 = new Line(_origin, b); var line2 = new Line(p1, p2); if (_Contains(line1, line2, rect.BottomLeft, hwidth, height) || _Contains(line1, line2, rect.BottomRight, hwidth, height) || _Contains(line1, line2, rect.TopLeft, hwidth, height) || _Contains(line1, line2, rect.TopRight, hwidth, height)) { return(true); } return(rect.Contains(_origin) || rect.Contains(p1) || rect.Contains(p2)); }
public static Float AngleBetween(VectorF vector1, VectorF vector2) { Float sin = vector1._x * vector2._y - vector2._x * vector1._y; Float cos = vector1._x * vector2._x + vector1._y * vector2._y; return((Float)(Math.Atan2(sin, cos) * (180 / Math.PI))); }
public VectorF Transform(VectorF vector) { VectorF newVector = vector; MultiplyVector(ref newVector._x, ref newVector._y); return(newVector); }
public PointF?Projection(PointF p) { var vec = new VectorF(A, B); var cps = Cross(new Line(p, vec)); return(cps); }
public _Arrow(PointF origin, float height, float width, VectorF direction, Color fillColor) { _origin = origin; _height = height; _width = width; _direction = direction; _fillColor = fillColor; }
public void Offset(VectorF offsetVector) { if (IsEmpty) { throw new System.InvalidOperationException(); } _x += offsetVector._x; _y += offsetVector._y; }
public override bool Equals(object o) { if ((null == o) || !(o is VectorF)) { return(false); } VectorF value = (VectorF)o; return(VectorF.Equals(this, value)); }
private RectF _GetBounds(float scale) { if (_height == 0 || _width == 0) { return(RectF.Empty); } var height = _height / scale; var hwidth = _width / (2 * scale); var p = _origin + _direction * height; var hdir = new VectorF(_direction.Y, -_direction.X); var wl = hdir * hwidth; var bound = RectF.Empty; bound.Union(new RectF(_origin, p + wl)); bound.Union(new RectF(_origin, p - wl)); return(bound); }
public bool HitTest(PointF p, float sensitive, float scale) { if (_height == 0 || _width == 0) { return(false); } var height = _height / scale; var hwidth = _width / (2 * scale); var b = _origin + _direction * height; var hdir = new VectorF(_direction.Y, -_direction.X); var wl = hdir * hwidth; var p1 = b + wl; var p2 = b - wl; var line1 = new Line(_origin, b); var line2 = new Line(p1, p2); return(_Contains(line1, line2, p, hwidth, height)); }
public void Translate(VectorF vector, bool isRefresh = true) { Translate(vector.X, vector.Y, isRefresh); }
public static PointF Add(VectorF vector, PointF point) { return(new PointF(point._x + vector._x, point._y + vector._y)); }
public static VectorF Subtract(VectorF vector1, VectorF vector2) { return(new VectorF(vector1._x - vector2._x, vector1._y - vector2._y)); }
public static VectorF Add(VectorF vector1, VectorF vector2) { return(new VectorF(vector1._x + vector2._x, vector1._y + vector2._y)); }
public static PointF Subtract(PointF point, VectorF vector) { return(new PointF(point._x - vector._x, point._y - vector._y)); }
public static Float CrossProduct(VectorF vector1, VectorF vector2) { return(vector1._x * vector2._y - vector1._y * vector2._x); }
internal VectorF Transform(VectorF vector) { return(_matrix.Transform(vector)); }
public static bool Equals(VectorF vector1, VectorF vector2) { return(vector1.X.Equals(vector2.X) && vector1.Y.Equals(vector2.Y)); }
public static RectF Offset(RectF rect, VectorF offsetVector) { rect.Offset(offsetVector.X, offsetVector.Y); return(rect); }
public static VectorF Multiply(VectorF vector, MatrixF matrix) { return(matrix.Transform(vector)); }
public static VectorF Divide(VectorF vector, Float scalar) { return(vector * (1.0f / scalar)); }
public static VectorF Multiply(Float scalar, VectorF vector) { return(new VectorF(vector._x * scalar, vector._y * scalar)); }
public void DrawArrow(Color fillColor, PointF origin, float height, float width, VectorF direction, bool isFixedSize) { fillColor = _transform.Transform(fillColor); origin = _transform.Transform(origin); direction = _transform.Transform(-direction); direction.Normalize(); if (isFixedSize) { _primitives.Add(new _Arrow(origin, height, width, direction, fillColor)); } else { var p1 = origin + direction * height; var v = new VectorF(direction.Y, -direction.X); var wd = v * width / 2; var p2 = p1 + wd; p1 -= wd; var geo = new _ComplexGeometry(); var subgeo = new _SimpleGeometry(PenF.NULL, fillColor, origin, false); subgeo.StreamTo(new _Line(origin, p1, PenF.NULL)); subgeo.StreamTo(new _Line(p1, p2, PenF.NULL)); subgeo.StreamTo(new _Line(p2, origin, PenF.NULL)); geo.AddChild(subgeo); geo.Close(); _primitives.Add(geo); } }
public static Float Multiply(VectorF vector1, VectorF vector2) { return(vector1._x * vector2._x + vector1._y * vector2._y); }
public bool Equals(VectorF value) { return(VectorF.Equals(this, value)); }
public RectF(PointF point, VectorF vector) : this(point, point + vector) { }
public static Float Determinant(VectorF vector1, VectorF vector2) { return(vector1._x * vector2._y - vector1._y * vector2._x); }