示例#1
0
        public static bool pointInBox2D(Vector2 point, Box2D box)
        {
            Vector2 pointInBoxSpace = MarsMath.rotate(
                point, -box.getRigidbody2D().getRotation(),
                box.getRigidbody2D().getPosition()
                );
            AABB aabbBox = new AABB(box.size, box.getRigidbody2D().getPosition());

            return(pointInAABB(pointInBoxSpace, aabbBox));
        }
示例#2
0
        public static bool lineInBox2D(LineSegment line, Box2D box)
        {
            Box2D       thisBox  = box;
            LineSegment thisLine = line;

            float   theta  = -thisBox.getRigidbody2D().getRotation();
            Vector2 center = thisBox.getRigidbody2D().getPosition();

            Vector2 rotatedStartLine = MarsMath.rotate(thisLine.getStart(), theta, center);
            Vector2 rotatedEndLine   = MarsMath.rotate(thisLine.getEnd(), theta, center);

            AABB        aabb             = new AABB(thisBox.size, thisBox.getRigidbody2D().getPosition());
            LineSegment localRotatedLine = new LineSegment(rotatedStartLine, rotatedEndLine);

            return(lineInAABB(localRotatedLine, aabb));
        }