|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgame.physics.GeneralPhysics
A class that defines vector operations and other mathematical/physical computations.
Constructor Summary | |
GeneralPhysics()
|
Method Summary | |
static double |
determinant(double a,
double b,
double c,
double d)
Returns the determinant of a 2x2 matrix of [ (a,b) (c,d) ]. |
static double |
distancePointLine(Vector2D point,
Vector2D i,
Vector2D j)
Returns the minimum distance between a specified point and a line defined by i and j using the formula at http://astronomy.swin.edu.au/pbourke/geometry/pointline/ . |
static void |
getFuturePosition(Vector2D position,
double direction,
Vector2D futurePosition)
Sets a point to 1 unit in a direction from another point. |
static void |
getPointLineLineIntersection(Vector2D a,
Vector2D b,
Vector2D c,
Vector2D d,
Vector2D result)
Sets a point to the intersection of two lines defined by two vectors each. |
static boolean |
isGreaterDistanceToIntersection(Vector2D positionA,
double directionA,
Vector2D positionB,
double directionB)
Returns whether a vector moving in a direction is closer to its point of intersection with another vector moving in another direction than that vector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GeneralPhysics()
Method Detail |
public static double distancePointLine(Vector2D point, Vector2D i, Vector2D j)
point
- the specified point off the linei
- a point on the linej
- a point on the line
public static void getPointLineLineIntersection(Vector2D a, Vector2D b, Vector2D c, Vector2D d, Vector2D result)
a
- a point on line 1b
- a point on line 1c
- a point on line 2d
- a point on line 2result
- the point of intersectionpublic static double determinant(double a, double b, double c, double d)
a
- the element at row 1, column 1b
- the element at row 1, column 2c
- the element at row 2, column 1d
- the element at row 2, column 2
public static boolean isGreaterDistanceToIntersection(Vector2D positionA, double directionA, Vector2D positionB, double directionB)
positionA
- position 1directionA
- direction 1positionB
- position 2directionB
- direction 2
true
if position 1 is closer to the point of
intersection than position 2 false
otherwisepublic static void getFuturePosition(Vector2D position, double direction, Vector2D futurePosition)
position
- the original positiondirection
- the direction of offsetfuturePosition
- the new positionMovingBody#dir
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |