public class

BaseCollisionChecker

extends Object
java.lang.Object
   ↳ org.andengine.util.algorithm.collision.BaseCollisionChecker
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

(c) 2010 Nicolas Gramlich (c) 2011 Zynga Inc.

Summary

Public Constructors
BaseCollisionChecker()
Public Methods
static boolean checkAxisAlignedRectangleCollision(float pLeftA, float pTopA, float pRightA, float pBottomA, float pLeftB, float pTopB, float pRightB, float pBottomB)
static boolean checkAxisAlignedRectangleContains(float pLeft, float pTop, float pRight, float pBottom, float pX, float pY)
static int relativeCCW(float pX1, float pY1, float pX2, float pY2, float pPX, float pPY)
Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (X2, Y2).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BaseCollisionChecker ()

Public Methods

public static boolean checkAxisAlignedRectangleCollision (float pLeftA, float pTopA, float pRightA, float pBottomA, float pLeftB, float pTopB, float pRightB, float pBottomB)

public static boolean checkAxisAlignedRectangleContains (float pLeft, float pTop, float pRight, float pBottom, float pX, float pY)

public static int relativeCCW (float pX1, float pY1, float pX2, float pY2, float pPX, float pPY)

Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (X2, Y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first endpoint, (X1, Y1), in order to point at the specified point (PX, PY).

A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise.

A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise.

A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.

If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (X1, Y1)" or 1 if the point lies "beyond (X2, Y2)".

Parameters
pX1 , Y1 the coordinates of the beginning of the specified line segment
pX2 , Y2 the coordinates of the end of the specified line segment
pPX , PY the coordinates of the specified point to be compared with the specified line segment
Returns
  • an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.