|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrcssjava.VecPosition
public class VecPosition
Implementation of a 2d point/vector.
| Constructor Summary | |
|---|---|
VecPosition()
Default constructor sets point at origin |
|
VecPosition(double vx,
double vy)
Cartesian constructor |
|
VecPosition(double vx,
double vy,
boolean polar)
Cartesian/Polar constructor |
|
VecPosition(VecPosition p)
Copy constructor |
|
| Method Summary | |
|---|---|
VecPosition |
add(double d)
Get new vector with a constant value added to each coordinate |
VecPosition |
add(VecPosition p)
Sum of two vectors |
void |
copy(VecPosition p)
Copy value of another VecPosition into this |
VecPosition |
divide(double d)
Get new vector with each coordinate divided by a constant |
VecPosition |
divide(VecPosition p)
Pairwise quotient of two vectors |
double |
dotProduct(VecPosition p)
Dot (inner) product of two vectors |
double |
getAngleBetweenPoints(VecPosition p1,
VecPosition p2)
Get angle formed between the vectors connecting this point to the given points |
double |
getDirection()
Get direction |
double |
getDistanceTo(VecPosition p)
Get distanct to a given point |
double |
getMagnitude()
Get magnitude |
static VecPosition |
getVecPositionFromPolar(double mag,
double angDeg)
Convert from polar to cartesian coordinates |
double |
getX()
Get x coordinate |
double |
getY()
Get y coordinate |
VecPosition |
globalToRelative(VecPosition origin,
double angDeg)
Convert global coordinates to relative coordinates |
boolean |
isBehind(double d)
Is this behind given x coordinate? |
boolean |
isBehind(VecPosition p)
Is this behind given point? |
boolean |
isBetweenX(double d1,
double d2)
Is the x coordinate between the given x coordinates |
boolean |
isBetweenX(VecPosition p1,
VecPosition p2)
Is the x coordinate between the x coordinates of the given points? |
boolean |
isBetweenY(double d1,
double d2)
Is the y coordinate between the given y coordinates |
boolean |
isBetweenY(VecPosition p1,
VecPosition p2)
Is the y coordinate between the y coordinates of the given points? |
boolean |
isInFrontOf(double d)
Is this in front of given x coordinate? |
boolean |
isInFrontOf(VecPosition p)
Is this in front of given point? |
boolean |
isLeftOf(double d)
Is this left of given y coordinate? |
boolean |
isLeftOf(VecPosition p)
Is this left of given point? |
boolean |
isRightOf(double d)
Is this right of given y coordinate? |
boolean |
isRightOf(VecPosition p)
Is this right of given point? |
VecPosition |
multiply(double d)
Get new vector with each coordinate muliplied by a constant |
VecPosition |
multiply(VecPosition p)
Pairwise product of two vectors |
VecPosition |
negate()
Get new vector which is the negation of this |
VecPosition |
normalize()
Scale to magnitude 1.0 |
VecPosition |
relativeToGlobal(VecPosition origin,
double angDeg)
Convert relative coordinates to global coordinates |
VecPosition |
rotate(double angDeg)
Rotate by angle |
VecPosition |
subtract(double d)
Get new vector with a constant value subtracted from each coordinate |
VecPosition |
subtract(VecPosition p)
Difference of two vectors |
java.lang.String |
toString()
|
VecPosition |
withMagnitude(double d)
Scale to given magnitude |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public VecPosition()
public VecPosition(double vx,
double vy)
vx - value of x coordinatevy - value of y coordinate
public VecPosition(double vx,
double vy,
boolean polar)
vx - x coordinate for cartesian, or magnitude for polarvy - y coordinate for cartesian, or angle in degrees for polarpolar - set to true for polar
interpretation of argumentsgetVecPositionFromPolar(double,double)public VecPosition(VecPosition p)
p - another VecPosition| Method Detail |
|---|
public void copy(VecPosition p)
VecPosition into this
p - another VecPositionpublic double getX()
public double getY()
public double getMagnitude()
public double getDirection()
public double getDistanceTo(VecPosition p)
p - another point
public boolean isInFrontOf(double d)
d - x coordinate
true if this has a greater x coordinatepublic boolean isInFrontOf(VecPosition p)
p - another point
true if this has a greater x coordinatepublic boolean isBehind(double d)
d - x coordinate
true if this has a smaller x coordinatepublic boolean isBehind(VecPosition p)
p - another point
true if this has a smaller x coordinatepublic boolean isLeftOf(double d)
d - y coordinate
true if this has a smaller y coordinatepublic boolean isLeftOf(VecPosition p)
p - another point
true if this has a smaller y coordinatepublic boolean isRightOf(double d)
d - y coordinate
true if this has a greater y coordinatepublic boolean isRightOf(VecPosition p)
p - another point
true if this has a greater y coordinate
public boolean isBetweenX(VecPosition p1,
VecPosition p2)
p1 - back pointp2 - front point
true if in front of back point
and behind front point
public boolean isBetweenX(double d1,
double d2)
d1 - back x coordinated2 - front x coordinate
true if in front of back coordinate
and behind front coordinate
public boolean isBetweenY(VecPosition p1,
VecPosition p2)
p1 - left pointp2 - right point
true if right of left point
and left of right point
public boolean isBetweenY(double d1,
double d2)
d1 - left y coordinated2 - right y coordinate
true if right of left coordinate
and left of right coordinatepublic VecPosition negate()
VecPosition with x and y negatedpublic VecPosition add(double d)
d - value to add to both x and y
VecPosition (x+d,y+d)public VecPosition add(VecPosition p)
p - another vector
public VecPosition subtract(double d)
d - value to subtract from both x and y
VecPosition (x-d,y-d)public VecPosition subtract(VecPosition p)
p - another vector
public VecPosition multiply(double d)
d - value to multiply both x and y by
VecPosition (x*d,y*d)public VecPosition multiply(VecPosition p)
p - another vector
dotProduct(VecPosition)public VecPosition divide(double d)
d - value to divide both x and y by
VecPosition (x/d,y/d)public VecPosition divide(VecPosition p)
p - another vector
public VecPosition withMagnitude(double d)
d - magnitude
VecPosition with given magnitudenormalize()public VecPosition normalize()
VecPosition with magnitude 1.0withMagnitude(double)public VecPosition rotate(double angDeg)
angDeg - angle in degrees
VecPosition rotated by given angle
public VecPosition globalToRelative(VecPosition origin,
double angDeg)
origin - position of relative coordinate systemangDeg - direction of relative coordinate system in degrees
relativeToGlobal(VecPosition,double)
public VecPosition relativeToGlobal(VecPosition origin,
double angDeg)
origin - position of relative coordinate systemangDeg - direction of relative coordinate system in degrees
globalToRelative(VecPosition,double)public double dotProduct(VecPosition p)
p - another vector
multiply(VecPosition)
public double getAngleBetweenPoints(VecPosition p1,
VecPosition p2)
p1 - first pointp2 - second point
public java.lang.String toString()
toString in class java.lang.Object
public static VecPosition getVecPositionFromPolar(double mag,
double angDeg)
mag - magnitudeangDeg - direction in degrees
VecPosition for the given values
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||