Somewhere on the way to porting the camera keypoints processing
This commit is contained in:
parent
a7a25bde6e
commit
abeef72514
@ -7,6 +7,8 @@ namespace LinearAlgebra {
|
|||||||
|
|
||||||
#pragma region Matrix1
|
#pragma region Matrix1
|
||||||
|
|
||||||
|
Matrix1::Matrix1() {}
|
||||||
|
|
||||||
Matrix1::Matrix1(int size) : size(size) {
|
Matrix1::Matrix1(int size) : size(size) {
|
||||||
if (this->size == 0)
|
if (this->size == 0)
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
@ -257,6 +259,37 @@ void Matrix2::UpdateSlice(int rowStart,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix2 Matrix2::DeleteRows(int rowStart, int rowStop) {
|
||||||
|
Matrix2 r = Matrix2(this->nRows - (rowStop - rowStart), this->nCols);
|
||||||
|
|
||||||
|
int resultRowIx = 0;
|
||||||
|
for (int i = 0; i < this->nRows; i++) {
|
||||||
|
if (i >= rowStart && i < rowStop)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int j = 0; j < this->nCols; j++)
|
||||||
|
r.data[resultRowIx * r.nCols + j] = this->data[i * this->nCols + j];
|
||||||
|
|
||||||
|
resultRowIx++;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix2 Matrix2::DeleteColumns(int colStart, int colStop) {
|
||||||
|
Matrix2 r = Matrix2(this->nRows, this->nCols - (colStop - colStart));
|
||||||
|
|
||||||
|
for (int i = 0; i < this->nRows; i++) {
|
||||||
|
int resultColIx = 0;
|
||||||
|
for (int j = 0; j < this->nCols; j++) {
|
||||||
|
if (j >= colStart && j < colStop)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
r.data[i * r.nCols + resultColIx++] = this->data[i * this->nCols + j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Compute the Omega matrix of a 3D vector
|
/// @brief Compute the Omega matrix of a 3D vector
|
||||||
/// @param v The vector
|
/// @param v The vector
|
||||||
/// @return 4x4 Omega matrix
|
/// @return 4x4 Omega matrix
|
||||||
|
@ -12,12 +12,33 @@ class Matrix1 {
|
|||||||
float* data = nullptr;
|
float* data = nullptr;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
|
Matrix1();
|
||||||
Matrix1(int size);
|
Matrix1(int size);
|
||||||
Matrix1(float* data, int size);
|
Matrix1(float* data, int size);
|
||||||
|
|
||||||
static Matrix1 FromQuaternion(Quaternion q);
|
static Matrix1 FromQuaternion(Quaternion q);
|
||||||
Quaternion ToQuaternion();
|
Quaternion ToQuaternion();
|
||||||
|
|
||||||
|
Matrix1 Slice(int start, int stop);
|
||||||
|
|
||||||
|
void Set(unsigned int start, unsigned int stop, float value) {
|
||||||
|
if (stop > this->size)
|
||||||
|
stop = this->size;
|
||||||
|
|
||||||
|
for (unsigned int ix = start; ix < stop; ix++)
|
||||||
|
this->data[ix] = value;
|
||||||
|
}
|
||||||
|
void Set(unsigned int start, unsigned int stop, Matrix1 source) {
|
||||||
|
if (stop > this->size)
|
||||||
|
stop = this->size;
|
||||||
|
if (stop > source.size)
|
||||||
|
stop = source.size;
|
||||||
|
// Do I need to check on start???
|
||||||
|
unsigned int sourceIx = 0;
|
||||||
|
for (unsigned int ix = start; ix < stop; ix++, sourceIx++)
|
||||||
|
this->data[ix] = source.data[sourceIx];
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool externalData = true;
|
bool externalData = true;
|
||||||
};
|
};
|
||||||
@ -96,13 +117,33 @@ class Matrix2 {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix2 GetRows(int from, int to) {
|
||||||
|
if (from < 0 || to >= this->nRows)
|
||||||
|
std::cerr << "Slice index out of range." << "std::endl";
|
||||||
|
|
||||||
|
Matrix2 result = Matrix2(to-from, this->nCols);
|
||||||
|
int resultRowIx = 0;
|
||||||
|
for (int rowIx = from; rowIx < to; rowIx++) {
|
||||||
|
for (int colIx = 0; colIx < this->nCols; colIx++)
|
||||||
|
result.data[resultRowIx * result.nCols + colIx] = this->data[rowIx * this->nCols + colIx];
|
||||||
|
|
||||||
|
resultRowIx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Matrix2 Slice(int rawStart, int rowStop, int colStart, int colStop);
|
Matrix2 Slice(int rawStart, int rowStop, int colStart, int colStop);
|
||||||
|
|
||||||
void UpdateSlice(int rowStart,
|
void UpdateSlice(int rowStart,
|
||||||
int rowStop,
|
int rowStop,
|
||||||
int colStart,
|
int colStart,
|
||||||
int colStop,
|
int colStop,
|
||||||
const Matrix2& m) const;
|
const Matrix2& m) const;
|
||||||
|
|
||||||
|
Matrix2 DeleteRows(int rowStart, int rowStop);
|
||||||
|
Matrix2 DeleteColumns(int colStart, int colStop);
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
// move constructor and move assignment operator
|
// move constructor and move assignment operator
|
||||||
Matrix2(Matrix2&& other) noexcept;
|
Matrix2(Matrix2&& other) noexcept;
|
||||||
|
@ -180,3 +180,13 @@ Vector2 Vector2::Lerp(const Vector2& v1, const Vector2& v2, float f) {
|
|||||||
Vector2 v = v1 + (v2 - v1) * f;
|
Vector2 v = v1 + (v2 - v1) * f;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Vector2Of
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Vector2Of<T>::Vector2Of() {
|
||||||
|
this->horizontal = 0;
|
||||||
|
this->vertical = 0;
|
||||||
|
}
|
||||||
|
#pragma endregion Vector2Of
|
@ -201,6 +201,17 @@ struct Vector2 : Vec2 {
|
|||||||
static Vector2 Lerp(const Vector2& v1, const Vector2& v2, float f);
|
static Vector2 Lerp(const Vector2& v1, const Vector2& v2, float f);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Vector2Of {
|
||||||
|
public:
|
||||||
|
Vector2Of();
|
||||||
|
|
||||||
|
T horizontal = 0;
|
||||||
|
T vertical = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
using Vector2Int = Vector2Of<int>;
|
||||||
|
|
||||||
} // namespace LinearAlgebra
|
} // namespace LinearAlgebra
|
||||||
using namespace LinearAlgebra;
|
using namespace LinearAlgebra;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user