|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.geom.Point2D java.awt.geom.Point2D.Double jpicedt.graphic.PicPoint jpicedt.graphic.PicVector
public class PicVector
This class encapsulates a geometrical vector (ie it has absolutely no relation with java.util.Vector !). It is based on PicPoint, from where it conveniently inherits formatting methods, yet add some useful vector-calculus related methods, e.g. dot product, norm, etc... Being a subclass of PicPoint is a major benefit where polymorphism is concerned, since instances of this class can be fed as argument to most getters and setters in jpicedt.graphic.model.Element.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class jpicedt.graphic.PicPoint |
---|
PicPoint.XComparator, PicPoint.YComparator |
Nested classes/interfaces inherited from class java.awt.geom.Point2D |
---|
Point2D.Double, Point2D.Float |
Field Summary | |
---|---|
static PicVector |
X_AXIS
the (1,0) unit vector ; this may be used to compute e.g. angles, projections, ... |
static PicVector |
Y_AXIS
the (0,1) unit vector ; this may be used to compute e.g. angles, projections, ... |
Fields inherited from class jpicedt.graphic.PicPoint |
---|
X_COMPARATOR, Y_COMPARATOR |
Fields inherited from class java.awt.geom.Point2D.Double |
---|
x, y |
Constructor Summary | |
---|---|
PicVector()
Construct a null vector. |
|
PicVector(Complex z)
Construct a vector with same coordinate as real part and imaginary part as a complex number. |
|
PicVector(double[] f)
Construct a vector from the first two elements of the given array. |
|
PicVector(double x,
double y)
Construct a vector with coordinates (x,y) |
|
PicVector(float[] f)
Construct a vector from the first two elements of the given array. |
|
PicVector(Line2D line)
Construct a new PicVector from the two end-points of the given Line2D object. |
|
PicVector(Number x,
Number y)
Construct a vector from the given pair of Number (using their double value). |
|
PicVector(PicVector picVec)
Clone the given vector. |
|
PicVector(Point2D pt)
Construct a new PicVector pointing from (0,0) to the given point |
|
PicVector(Point2D pt1,
Point2D pt2)
Construct a new PicVector from the two given points |
|
PicVector(String str)
Construct a point by parsing a String similar to that given by the toString() method, ie (x,y) . |
Method Summary | |
---|---|
PicVector |
add(PicPoint other)
Add the given vector to this vector, which modifies this, and return this for convenience. |
PicVector |
add(PicPoint other,
double a)
Add the given vector scaled by "a" to this vector, which modifies this, and return this for convenience. |
double |
angle(PicVector other)
Return the (CCW oriented) angle, in radians, of the other vector relative to this vector. |
double |
angleDegrees(PicVector other)
Return the (CCW oriented) angle between this vector and the given vector, in degrees. |
PicVector |
cAdd(PicPoint other)
Make the addition the given vector to this vector, without modifying this, and return the result. |
PicVector |
cAdd(PicVector other,
double a)
Make the addition the given other vector scaled by a to this vector, without modifying this nor other, and return the result. |
PicVector |
cIMul()
Rotate this by PI/2 radian, without modifying this, and return the result of this rotation. |
PicVector |
cInverse()
|
PicVector |
cMIMul()
Rotate this by -PI/2 radian, without modifying this, and return the result of this rotation. |
PicVector |
cMul(double s)
Multiplie le vecteur this par s, sans modifier this. |
PicVector |
cSub(PicPoint other)
Make the subtraction the given vector from this vector, without modifying this, and return the result. |
double |
det(PicVector other)
Return the determinant of {{x,y},{other.x,other.y}} ; this is aka vector product, where only the z-coordinate gets returned. |
double |
dot(PicPoint other)
Return the dot product of this vector with the given vector other |
static PicVector |
getDirector(double startPtX,
double startPtY,
double endPtX,
double endPtY,
PicVector dest)
Return a unitary vector pointing from startPt to endPt ; if dest is non-null, it's filled with the result and returned for convenience ; otherwise, a new PicPoint gets allocated. |
static PicVector |
getDirector(PicPoint startPt,
PicPoint endPt)
Return a unitary vector pointing from startPt to endPt |
static PicVector |
getDirector(PicPoint startPt,
PicPoint endPt,
PicVector dest)
Return a unitary vector pointing from startPt to endPt ; if dest is non-null, it's filled with the result and returned for convenience ; otherwise, a new PicPoint gets allocated. |
static PicVector |
getOrthogonal(PicPoint startPt,
PicPoint endPt)
Return a UNITARY vector orthogonal to the vector pointing from startPt to endPt and built by rotating this vector CCW. |
PicVector |
iMul()
Rotate this by PI/2 radian, which modifies this, and return this for convenience. |
PicVector |
inverse()
Change the sign of each coordinate of this vector |
boolean |
isColinear(PicVector other)
Return whether this vector is proportional to the given vector |
boolean |
isNull()
Return true if this vector has a null-norm |
boolean |
isOrthogonal(PicVector other)
Return whether this vector is orthogonal to the given vector |
static void |
main(String[] args)
validation tests |
PicVector |
miMul()
Rotate this by -PI/2 radian, which modifies this, and return this for convenience. |
double |
norm()
Return the norm of this vector |
double |
norm1()
Return the abs(x)+abs(y) norm1 for this vector=(x,y) |
double |
norm2()
Return the squared of the norm of this vector |
PicVector |
normalize()
Normalize this vector so that this becomes a unitary vector Does nothing if this vector is a null-vector. |
static PicVector |
normalize(PicVector src,
PicVector dest)
Return a normalized copy of the given vector. |
PicVector |
rotate(double angle)
Rotate this vector by the given (CCW-oriented) angle in radians. |
static PicVector |
rotate(PicVector src,
PicVector dest,
double angle)
Return a rotated copy of the given vector. |
PicVector |
scale(double a)
Multiply each coordinate of this vector by the given double |
PicVector |
scale(double ax,
double ay)
Multiply each coordinate of this vector by the given pair of double |
static PicVector |
scale(PicVector src,
PicVector dest,
double scale)
Return a scaled copy of the given vector. |
PicVector |
setCoordinates(Line2D line)
Set the coordinates of this vector from the given Line2D object |
PicVector |
setCoordinates(Point2D pt1,
Point2D pt2)
Set the coordinates of this vector from the two given points. |
PicVector |
subtract(PicPoint other)
Subtract the given vector from this vector, which modifies this, and return this for convenience. |
Methods inherited from class jpicedt.graphic.PicPoint |
---|
apply, clone, middle, mirror, mirror, norm1Distance, normInfDistance, project, project, rotate, scale, scale, scale, scale, setCoordinates, setCoordinates, shear, symmetry, symmetry, toComplex, toDoubleArray, toFloatArray, toMm, toMm, toString, translate, translate, translate, translate, translate |
Methods inherited from class java.awt.geom.Point2D.Double |
---|
getX, getY, setLocation |
Methods inherited from class java.awt.geom.Point2D |
---|
distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final PicVector X_AXIS
public static final PicVector Y_AXIS
Constructor Detail |
---|
public PicVector()
public PicVector(PicVector picVec)
public PicVector(double x, double y)
public PicVector(Complex z)
public PicVector(Number x, Number y)
public PicVector(float[] f)
public PicVector(double[] f)
public PicVector(String str) throws NumberFormatException
toString()
method, ie (x,y)
.
NumberFormatException
public PicVector(Point2D pt1, Point2D pt2)
public PicVector(Point2D pt)
public PicVector(Line2D line)
Method Detail |
---|
public PicVector setCoordinates(Point2D pt1, Point2D pt2)
public PicVector setCoordinates(Line2D line)
public PicVector add(PicPoint other)
public PicVector add(PicPoint other, double a)
public PicVector subtract(PicPoint other)
public PicVector cSub(PicPoint other)
public PicVector cAdd(PicPoint other)
public PicVector cAdd(PicVector other, double a)
public PicVector iMul()
rotate(double angle)
,
cIMul()
,
cMIMul()
public PicVector cIMul()
rotate(double angle)
,
iMul()
,
miMul()
,
cMIMul()
public PicVector miMul()
rotate(double angle)
,
cIMul()
public PicVector cMIMul()
rotate(double angle)
,
iMul()
public PicVector cMul(double s)
public double norm()
public double norm2()
public double norm1()
public PicVector normalize()
public double dot(PicPoint other)
other
public boolean isOrthogonal(PicVector other)
public boolean isColinear(PicVector other)
public PicVector scale(double a)
public PicVector scale(double ax, double ay)
ax
- scale factor for the X-coorday
- scale factor for the Y-coord
public PicVector inverse()
public PicVector cInverse()
PicVector
dont le signe des
coordonnées est changé.public boolean isNull()
public double det(PicVector other)
public double angle(PicVector other)
public double angleDegrees(PicVector other)
public PicVector rotate(double angle)
iMul()
,
cIMul()
public static void main(String[] args)
public static PicVector normalize(PicVector src, PicVector dest)
public static PicVector rotate(PicVector src, PicVector dest, double angle)
rotate(double)
public static PicVector scale(PicVector src, PicVector dest, double scale)
rotate(double)
public static PicVector getDirector(PicPoint startPt, PicPoint endPt)
public static PicVector getDirector(PicPoint startPt, PicPoint endPt, PicVector dest)
public static PicVector getDirector(double startPtX, double startPtY, double endPtX, double endPtY, PicVector dest)
public static PicVector getOrthogonal(PicPoint startPt, PicPoint endPt)
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |