56 if (i == 0)
return a.
x;
57 if (i == 1)
return a.
y;
67 if (i == 0) a.
x = value;
68 if (i == 1) a.
y = value;
78 long distance = (a.
x * a.
x) + (a.
y * a.
y);
79 distance = Sqrt(distance);
91 long distanceRatio = ((a.
x * 100)/distance);
92 int angle = Acos(distanceRatio);
93 if (angle > 0 && a.
y < 0) angle = 360 - angle;
102 long distance = (a.
x - b.
x) * (a.
x - b.
x) + (a.
y - b.
y) * (a.
y - b.
y);
103 distance = Sqrt(distance);
113 long distanceRatio = (((b.
x - a.
x) * 100)/distance);
114 int angle = Acos(distanceRatio);
115 if (angle > 0 && (b.
y - a.
y) < 0) angle = 360 - angle;
139 a.
x = (distance * Cos(angle))/100;
140 a.
y = (distance * Sin(angle))/100;
165 a.
x = a.
x + ((distance * Cos(angle))/100);
166 a.
y = a.
y + ((distance * Sin(angle))/100);
213 long newX = (vec.
x * Cos(theta) - vec.
y * Sin(theta))/100;
214 long newY = (vec.
x * Sin(theta) + vec.
y * Cos(theta))/100;
228 long newX = (vec.
x * Cos(theta) - vec.
y * Sin(theta))/100;
229 long newY = (vec.
x * Sin(theta) + vec.
y * Cos(theta))/100;
230 vec.
x = newX + pivotX;
231 vec.
y = newY + pivotY;
242 ASSERT(matrix.
rows == 3 && matrix.
cols == 3,
243 "Transformation matrix is not 3x3");
256 void VectorPrint(
Vector &vec,
string name,
int waitPeriod)
258 TextOut(0, LCD_LINE1, name,
true);
259 NumOut(0, LCD_LINE2, vec.
x,
false);
260 NumOut(0, LCD_LINE3, vec.
y,
false);
261 NumOut(0, LCD_LINE4, vec.
theta,
false);
A vector that represents a 2D point by x-y coordinates and a direction angle.
long VectorGet(Vector &a, int i)
Gets the vector members with an index number rather than component names. Useful in a loop...
The matrix class. Don't access the members directly. Use the macros MIJ() or MI() or the methods prov...
long VectorGetDistanceVec(Vector &a, Vector &b)
Gets the distance between given two vectors.
void VectorRotate(Vector &vec, long theta)
Rotates the point in the vector by given angle. The direction component in the vector is not touched...
long VectorGetDistance(Vector &a)
Gets the polar distance of the given vector. It's the distance of its x-y coordicate from origin...
int VectorGetAngle(Vector &a)
Gets the polar angle of the given vectors. It's the angle of its x-y coordinate from origin...
void VectorReduce(Vector &a, long S)
Reduces x and y vector components by the given factor. i.e. a = a / S.
Debugging utility macros.
void VectorSet(Vector &a, int i, long value)
Sets the vector members with an index number rather than component names. Useful in a loop...
void VectorInitBound(Vector &retVec, long x, long y)
Initializes the vector into a bound vector with the point given by x and y. Bound vector is a vector ...
void VectorSubtract(Vector &a, Vector &b)
Subtracts vector b from a. i.e. a -= b.
void VectorInitPolar(Vector &a, long distance, int angle, int theta)
Initializes the vector with given distance and angle polar components.
void VectorRotateAtPoint(Vector &vec, long theta, long pivotX, long pivotY)
Rotates the point in the vector by given angle around the pivot point given by pivotX and pivotY...
Integer matrix implementation. Provides matrix algebra, cofactor, adjugate and inverse computation...
void VectorTranslate(Vector &a, long distance, int angle)
Translate the vector point to a new point moved the given distance towards the given direction angle...
void VectorTransform(Vector &vec, Matrix &matrix, Vector &retVec)
Transforms the given vector with the given transformation matrix and returns the transformed vector i...
void VectorScale(Vector &a, long S)
Scales x and y vector components by the given factor. i.e. a = a * S.
void VectorAdd(Vector &a, Vector &b)
Adds vector b to a. i.e. a += b.
long MatrixGet(Matrix &matrix, int row, int col)
Returns the value of element in matrix given by row x col. This is exactly same as macro MIJ()...
long VectorGetAngleVec(Vector &a, Vector &b)
Gets the angle of the line formed by the given two vectors.
void VectorInit(Vector &a, long x, long y, long theta)
Initializes the vector with given x, y and theta components.