|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.emini.physics2D.util.FXVector
public class FXVector
The FXVector class represents a 2D Vector.
2D Vector uses fixpoint-math.
FXUtil
Field Summary | |
---|---|
static FXVector |
M_UNITY
Unity vector. |
float |
xFX
X value of the Vector (FX) |
float |
yFX
Y value of the Vector (FX) |
Constructor Summary | |
---|---|
FXVector()
Empty Constructor. |
|
FXVector(float xFx,
float yFx)
Constructor with x and y coordinates. |
|
FXVector(FXVector other)
Copy constructor. |
Method Summary | |
---|---|
void |
add(FXVector other)
Adds a vector. |
void |
add(FXVector vector,
float scaleFX)
Adds a vector after scaling it. |
void |
add2FX(FXVector other,
float scale2FX)
Adds a vector after scaling it (2FX). |
void |
addFX(float xFX,
float yFX,
float scaleFX)
Adds a vector (given as two coordinates) after scaling it. |
void |
assign(FXVector other)
Copies the values of another vector. |
void |
assignDiff(FXVector v1,
FXVector v2)
Assigns the difference vector between two points/vectors. |
void |
assignFX(float xFX,
float yFX)
Assign values to the vector. |
void |
assignScaledFX(FXVector other,
float scaleFX)
Copies and scaled the values of another vector. |
float |
crossFX(FXVector other)
Computes the cross product of two vectors. |
void |
crossScalar2FX(float val2FX)
Computes cross product with a scalar (2FX). |
void |
crossScalarFX(float valFX)
Computes cross product with a scalar (FX). |
float |
distanceFX(FXVector a,
FXVector b)
Calculates the distance to a line. |
float |
distanceFX(FXVector a,
FXVector b,
FXVector n,
float abDistFX)
Calculates the distance to a line (supplying normal and distance). |
float |
distFX(FXVector other)
Distance to another vector. |
void |
divideBy(int val)
Divides the vector. |
void |
divideByFX(float valFX)
Divides the vector (FX). |
FXVector |
dividedByFX(float valFX)
Creates a copy divided by a factor (FX). |
float |
dotFX(FXVector other)
Computes the dot product of two vectors. |
boolean |
equals(java.lang.Object other)
Equals operator for vectors. |
float |
fastLengthFX()
Calculates the length of the vector (fast). |
static float |
fastLengthFX(float xFX,
float yFX)
Calculates the length of a vector, supplied as x and y coordinates (fast). |
static boolean |
intersect(FXVector a1,
FXVector b1,
FXVector a2,
FXVector b2,
FXVector x)
Intersects two lines. |
boolean |
isInRect(FXVector ul,
FXVector lr)
Checks if vector is within a rectangle. |
boolean |
leftOf(FXVector a,
FXVector b)
Determines the hemisphere of a point with respect to a line. |
float |
lengthFX()
Calculates the length of the vector. |
int |
lengthSquare()
Calculates the square of the length of the vector. |
float |
lengthSquareFX()
Calculates the square of the length of the vector (FX). |
void |
max(FXVector vector)
Maximizes the vector to a reference vector. |
void |
maxFX(float cFX)
Maximizes both x and y component. |
void |
min(FXVector vector)
Minimizes the vector to a reference vector. |
void |
minFX(float cFX)
Minimizes both x and y component. |
void |
mult(int val)
Scales the vector. |
void |
multFX(float valFX)
Scales the vector (FX). |
static FXVector |
newVector(int x,
int y)
Creates a new vector. |
void |
normalize()
Normalizes the vector. |
void |
normalizeFast()
Normalizes the vector (fast). |
void |
normalizePrecise()
Normalizes the vector. |
float |
preciseLengthFX()
Calculates the length of the vector. |
void |
subtract(FXVector vector)
Subtract a vector. |
FXVector |
times(int val)
Creates a copy multiplied by a factor. |
FXVector |
timesFX(float valFX)
Creates a copy multiplied by a factor (FX). |
void |
transpose()
Transposes the vector. |
void |
turnRight()
Turns the vector to the right by 90 degrees. |
int |
xAsInt()
Gets the x coordinate as int. |
int |
yAsInt()
Gets the y coordinate as int. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public float xFX
public float yFX
public static final FXVector M_UNITY
Constructor Detail |
---|
public FXVector()
public FXVector(float xFx, float yFx)
xFx
- x Value of the vector (FX).yFx
- y Value of the vector (FX).public FXVector(FXVector other)
other
- vectorMethod Detail |
---|
public static FXVector newVector(int x, int y)
x
- x Value of the vector.y
- y Value of the vector.
public final void assign(FXVector other)
other
- source vectorpublic final void assignFX(float xFX, float yFX)
xFX
- x Value of the vector (FX).yFX
- y Value of the vector (FX).public final void assignDiff(FXVector v1, FXVector v2)
v1
- end point of the vector.v2
- start point of the vector.public final void assignScaledFX(FXVector other, float scaleFX)
other
- source vectorscaleFX
- the scale factorpublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public final void add(FXVector other)
other
- vector to add.public final void add(FXVector vector, float scaleFX)
vector
- vector to add.scaleFX
- scaling factor of the add Vector (FX).public final void addFX(float xFX, float yFX, float scaleFX)
xFX
- x coordinate (FX) to add.yFX
- y coordinate (FX) to add.scaleFX
- scaling factor of the add Vector.public final void add2FX(FXVector other, float scale2FX)
other
- vector to add.scale2FX
- scaling factor (2FX) of the add Vector.public final void subtract(FXVector vector)
vector
- vector to subtractpublic final void multFX(float valFX)
valFX
- scale factor (FX).public final void mult(int val)
val
- scale factor.public final FXVector timesFX(float valFX)
valFX
- scale factor (FX).public final FXVector times(int val)
val
- scale factorpublic final FXVector dividedByFX(float valFX)
valFX
- divide factor (FX)public final void divideByFX(float valFX)
valFX
- divide factor (FX).public final void divideBy(int val)
val
- scale factor.public final void transpose()
public final void turnRight()
public final int lengthSquare()
public final float lengthSquareFX()
public final float lengthFX()
fastLengthFX()
.
public final float preciseLengthFX()
fastLengthFX()
.
public static final float fastLengthFX(float xFX, float yFX)
xFX
- the x coordinate (FX).yFX
- the y coordinate (FX).
public final float fastLengthFX()
lengthFX()
.
public final float distFX(FXVector other)
other
- other vector.
public final void normalize()
public final void normalizePrecise()
public final void normalizeFast()
fastLengthFX()
).
public final float dotFX(FXVector other)
other
- vector to compute the dot product with.
public final float crossFX(FXVector other)
other
- vector to compute the cross product with.
public final void crossScalarFX(float valFX)
valFX
- scale factor (FX) for the unit vector of the cross product.public final void crossScalar2FX(float val2FX)
val2FX
- scale factor (2FX) for the unit vector of the cross product.public final float distanceFX(FXVector a, FXVector b, FXVector n, float abDistFX)
distanceFX(FXVector, FXVector)
if the normal and distance are available and do not have to be computed.
a
- start point of the line.b
- end point of the line.n
- the normalized vector between a and b (b - a)/|b - a|.abDistFX
- distance between a and b.
public final float distanceFX(FXVector a, FXVector b)
a
- start point of the line.b
- end point of the line.
public final boolean leftOf(FXVector a, FXVector b)
a
- start point of line segment.b
- end point of line segment.
public static boolean intersect(FXVector a1, FXVector b1, FXVector a2, FXVector b2, FXVector x)
a1
- start of line 1.b1
- end of line 1.a2
- start of line 2.b2
- end of line 2.x
- target vector for the intersection point.
public final void maxFX(float cFX)
cFX
- minimum value for each coordinatepublic final void minFX(float cFX)
cFX
- maximum value for each coordinate.public final void max(FXVector vector)
vector
- minimum value for each coordinate.public final void min(FXVector vector)
vector
- maximum value for each coordinate.public final boolean isInRect(FXVector ul, FXVector lr)
ul
- the upper left corner of the rectangle.lr
- the lower right corner of the rectangle.
public final int xAsInt()
public final int yAsInt()
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |