Esempio n. 1
0
 public Line(PointF p1, VectorF vec)
 {
     P1 = p1;
     P2 = p1 + vec;
     GeometryHelper.CalcABC(P1, P2, out A, out B, out C);
     Type = LineType.Ray;
 }
Esempio n. 2
0
        public PointF?Projection(PointF p)
        {
            var vec = new VectorF(A, B);
            var cps = Cross(new Line(p, vec));

            return(cps);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        public VectorF Transform(VectorF vector)
        {
            VectorF newVector = vector;

            MultiplyVector(ref newVector._x, ref newVector._y);
            return(newVector);
        }
Esempio n. 5
0
 public _Arrow(PointF origin, float height, float width, VectorF direction, Color fillColor)
 {
     _origin    = origin;
     _height    = height;
     _width     = width;
     _direction = direction;
     _fillColor = fillColor;
 }
Esempio n. 6
0
        public void Offset(VectorF offsetVector)
        {
            if (IsEmpty)
            {
                throw new System.InvalidOperationException();
            }

            _x += offsetVector._x;
            _y += offsetVector._y;
        }
Esempio n. 7
0
        public override bool Equals(object o)
        {
            if ((null == o) || !(o is VectorF))
            {
                return(false);
            }

            VectorF value = (VectorF)o;

            return(VectorF.Equals(this, value));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
 public static Float Determinant(VectorF vector1, VectorF vector2)
 {
     return(vector1._x * vector2._y - vector1._y * vector2._x);
 }
Esempio n. 11
0
 public static bool Equals(VectorF vector1, VectorF vector2)
 {
     return(vector1.X.Equals(vector2.X) &&
            vector1.Y.Equals(vector2.Y));
 }
Esempio n. 12
0
 public static VectorF Multiply(VectorF vector, MatrixF matrix)
 {
     return(matrix.Transform(vector));
 }
Esempio n. 13
0
 public static Float Multiply(VectorF vector1, VectorF vector2)
 {
     return(vector1._x * vector2._x + vector1._y * vector2._y);
 }
Esempio n. 14
0
 public static RectF Offset(RectF rect, VectorF offsetVector)
 {
     rect.Offset(offsetVector.X, offsetVector.Y);
     return(rect);
 }
Esempio n. 15
0
 public static VectorF Divide(VectorF vector, Float scalar)
 {
     return(vector * (1.0f / scalar));
 }
Esempio n. 16
0
 public static PointF Add(VectorF vector, PointF point)
 {
     return(new PointF(point._x + vector._x, point._y + vector._y));
 }
Esempio n. 17
0
 public static VectorF Add(VectorF vector1, VectorF vector2)
 {
     return(new VectorF(vector1._x + vector2._x,
                        vector1._y + vector2._y));
 }
Esempio n. 18
0
 public bool Equals(VectorF value)
 {
     return(VectorF.Equals(this, value));
 }
Esempio n. 19
0
 public RectF(PointF point,
              VectorF vector) : this(point, point + vector)
 {
 }
Esempio n. 20
0
 public static PointF Subtract(PointF point, VectorF vector)
 {
     return(new PointF(point._x - vector._x, point._y - vector._y));
 }
Esempio n. 21
0
 public static Float CrossProduct(VectorF vector1, VectorF vector2)
 {
     return(vector1._x * vector2._y - vector1._y * vector2._x);
 }
Esempio n. 22
0
 public void Translate(VectorF vector, bool isRefresh = true)
 {
     Translate(vector.X, vector.Y, isRefresh);
 }
Esempio n. 23
0
 public static VectorF Subtract(VectorF vector1, VectorF vector2)
 {
     return(new VectorF(vector1._x - vector2._x,
                        vector1._y - vector2._y));
 }
Esempio n. 24
0
 public static VectorF Multiply(Float scalar, VectorF vector)
 {
     return(new VectorF(vector._x * scalar,
                        vector._y * scalar));
 }
Esempio n. 25
0
        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);
            }
        }
Esempio n. 26
0
 internal VectorF Transform(VectorF vector)
 {
     return(_matrix.Transform(vector));
 }