コード例 #1
0
        /// <summary> Initializes a new instance of the <see cref="Rectangle2d"/> class with predefined bounds. </summary>
        /// <param name="x"> Minimum x value (left). </param>
        /// <param name="y"> Minimum y value (bottom). </param>
        /// <param name="width"> Width of the rectangle. </param>
        /// <param name="height"> Height of the rectangle. </param>
        public Rectangle2d(double x, double y, double width, double height)
        {
            _xmin = x;
            _ymin = y;
            _xmax = x + width;
            _ymax = y + height;

            _left   = new LineLinear2d(new Vector2d(_xmin, _ymin), new Vector2d(_xmin, _ymax));
            _right  = new LineLinear2d(new Vector2d(_xmax, _ymin), new Vector2d(_xmax, _ymax));
            _bottom = new LineLinear2d(new Vector2d(_xmin, _ymin), new Vector2d(_xmax, _ymin));
            _top    = new LineLinear2d(new Vector2d(_xmin, _ymax), new Vector2d(_xmax, _ymax));
        }
コード例 #2
0
        public static Vector2d Collide(LineParametric2d ray, LineLinear2d line, double epsilon)
        {
            var collide = LineLinear2d.Collide(ray.CreateLinearForm(), line);

            if (collide.Equals(Vector2d.Empty))
            {
                return(Vector2d.Empty);
            }

            var collideVector = collide - ray.A;

            return(ray.U.Dot(collideVector) < epsilon ? Vector2d.Empty : collide);
        }
コード例 #3
0
 /// <summary> Collision point of two lines. </summary>
 public static Vector2d Collide(LineLinear2d pLine1, LineLinear2d pLine2)
 {
     return(Collide(pLine1.A, pLine1.B, pLine1.C, pLine2.A, pLine2.B, pLine2.C));
 }
コード例 #4
0
 /// <summary> Collision point of two lines. </summary>
 /// <param name="pLine">Line to collision.</param>
 /// <returns>Collision point.</returns>
 public Vector2d Collide(LineLinear2d pLine)
 {
     return(Collide(this, pLine));
 }