76 vec.
x = sourceVector.
x;
77 vec.
y = sourceVector.
y;
83 vec.
x += vectorToAdd.
x;
84 vec.
y += vectorToAdd.
y;
89 vec.
x -= vectorToSubtract.
x;
90 vec.
y -= vectorToSubtract.
y;
95 result.
x = vector1.
x + vector2.
x;
96 result.
y = vector1.
y + vector2.
y;
101 const float sa = sinf(angle);
102 const float ca = cosf(angle);
104 matrix.
r1 = matrix.
r4 = ca;
111 result.
r1 = matrix.
r1 * scalar;
112 result.
r2 = matrix.
r2 * scalar;
113 result.
r3 = matrix.
r3 * scalar;
114 result.
r4 = matrix.
r4 * scalar;
119 const float r1 = matrix1.
r1 * matrix2.
r1 + matrix1.
r2 * matrix2.
r3;
120 const float r2 = matrix1.
r1 * matrix2.
r2 + matrix1.
r2 * matrix2.
r4;
121 const float r3 = matrix1.
r3 * matrix2.
r1 + matrix1.
r4 * matrix2.
r3;
122 result.
r4 = matrix1.
r3 * matrix2.
r2 + matrix1.
r4 * matrix2.
r4;
130 const float temp = matrix.
r1 * vec.
x + matrix.
r2 * vec.
y;
131 result.
y = matrix.
r3 * vec.
x + matrix.
r4 * vec.
y;
137 const float temp = matrix.
r1 * vector1.
x + matrix.
r2 * vector1.
y + vector2.
x;
138 result.
y = matrix.
r3 * vector1.
x + matrix.
r4 * vector1.
y + vector2.
y;
144 result.
x = scalar * vec.
x;
145 result.
y = scalar * vec.
y;
150 result.
x = vector1.
x - vector2.
x;
151 result.
y = vector1.
y - vector2.
y;
157 return vector1.
x * vector2.
x + vector1.
y * vector2.
y;
162 const float length = sqrtf(vec.
x * vec.
x + vec.
y * vec.
y);
173 return sqrtf(vec.
x * vec.
x + vec.
y * vec.
y);
178 return vec.
x * vec.
x + vec.
y * vec.
y;
183 const float x1 = vector1.
x - vector2.
x;
184 const float x2 = vector1.
y - vector2.
y;
186 return sqrtf(x1 * x1 + x2 * x2);
191 const float x1 = vector1.
x - vector2.
x;
192 const float x2 = vector1.
y - vector2.
y;
194 return x1 * x1 + x2 * x2;
199 const float sp = vector1.
x * vector2.
x + vector1.
y * vector2.
y;
200 const float l1 = sqrtf(vector1.
x * vector1.
x + vector1.
y * vector1.
y);
201 const float l2 = sqrtf(vector2.
x * vector2.
x + vector2.
y * vector2.
y);
203 return acosf(sp / (l1 * l2));
208 const float ca = cosf(angle);
209 const float sa = sinf(angle);
211 const float temp = ca * vec.
x - sa * vec.
y;
212 result.
y = sa * vec.
x + ca * vec.
y;
218 const float cx = center.
x;
219 const float cy = center.
y;
230 result.
r1 = matrix.
r1;
231 result.
r4 = matrix.
r4;
233 const float temp = matrix.
r2;
234 result.
r2 = matrix.
r3;
240 const float a = matrix.
r1;
241 const float b = matrix.
r2;
242 const float c = matrix.
r3;
243 const float d = matrix.
r4;
245 float det_inverse = 1 / (a * d - b *
c);
247 result.
r1 = d * det_inverse;
248 result.
r2 = -b * det_inverse;
249 result.
r3 = -c * det_inverse;
250 result.
r4 = a * det_inverse;
260 const float y_ = A.
r4 * p.
x + A.
r5 * p.
y + A.
r6;
261 const float z_ = A.
r7 * p.
x + A.
r8 * p.
y + A.
r9;
263 result.
x = (A.
r1 * p.
x + A.
r2 * p.
y + A.
r3) / z_;
269 result.
x = 0.5f * (vector1.
x + vector2.
x);
270 result.
y = 0.5f * (vector1.
y + vector2.
y);
286 float sum_x = 0.0f, sum_y = 0.0f;
288 for (
int i = 0; i < nVectors; i++)
290 sum_x += pVectors[i].
x;
291 sum_y += pVectors[i].
y;
294 result.
x = sum_x / float(nVectors);
295 result.
y = sum_y / float(nVectors);
300 const float cx = rectangle.
center.
x;
301 const float cy = rectangle.
center.
y;
302 const float width2 = 0.5f * rectangle.
width;
303 const float height2 = 0.5f * rectangle.
height;
304 const float angle = rectangle.
angle;
307 SetVec(resultCornerPoints[0], cx - width2, cy - height2);
308 SetVec(resultCornerPoints[1], cx + width2, cy - height2);
309 SetVec(resultCornerPoints[2], cx + width2, cy + height2);
310 SetVec(resultCornerPoints[3], cx - width2, cy + height2);
314 for (
int i = 0; i < 4; i++)
315 RotateVec(resultCornerPoints[i], rectangle.
center, angle, resultCornerPoints[i]);
void ApplyHomography(const Mat3d &A, const Vec2d &p, Vec2d &result)
float height
The height of the rectangle.
float width
The width of the rectangle.
float Angle(const Vec2d &vector1, const Vec2d &vector2)
void Transpose(const Mat2d &matrix, Mat2d &result)
void Average(const Vec2d &vector1, const Vec2d &vector2, Vec2d &result)
void RotateVec(const Vec2d &vec, float angle, Vec2d &result)
float SquaredDistance(const Vec2d &vector1, const Vec2d &vector2)
Data structure for the representation of a 2D rectangle.
void ComputeRectangleCornerPoints(const Rectangle2d &rectangle, Vec2d resultCornerPoints[4])
float ScalarProduct(const Vec2d &vector1, const Vec2d &vector2)
void MulVecScalar(const Vec2d &vec, float scalar, Vec2d &result)
float Distance(const Vec2d &vector1, const Vec2d &vector2)
Vec2d center
The center of the rectangle.
Data structure for the representation of a 2x2 matrix.
void SetRotationMat(Mat2d &matrix, float angle)
void NormalizeVec(Vec2d &vec)
float angle
The angle of the rectangle.
float Length(const Vec2d &vec)
void SubtractVecVec(const Vec2d &vector1, const Vec2d &vector2, Vec2d &result)
GLubyte GLubyte GLubyte a
void Invert(const Mat2d &matrix, Mat2d &result)
void AddVecVec(const Vec2d &vector1, const Vec2d &vector2, Vec2d &result)
void MulMatMat(const Mat2d &matrix1, const Mat2d &matrix2, Mat2d &result)
void AddToVec(Vec2d &vec, const Vec2d &vectorToAdd)
GLuint GLsizei GLsizei * length
Data structure for the representation of a 2D vector.
void MulMatScalar(const Mat2d &matrix, float scalar, Mat2d &result)
void SetVec(Vec2d &vec, float x, float y)
void SubtractVecVec(const CFloatVector *pVector1, const CFloatVector *pVector2, CFloatVector *pResultVector)
void SubtractFromVec(Vec2d &vec, const Vec2d &vectorToSubtract)
void Mean(const CVec2dArray &vectorList, Vec2d &result)
const T * GetElements() const
Data structure for the representation of a 3x3 matrix.
double Mean(CByteImage *pImage1, CByteImage *pImage2)
Deprecated.
float SquaredLength(const Vec2d &vec)
void MulMatVec(const Mat2d &matrix, const Vec2d &vec, Vec2d &result)