mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-28 20:55:19 +00:00
TITANIC: Remove DVector and DAffine files from build and folder
This commit is contained in:
parent
1160b88d06
commit
d55406b642
@ -434,8 +434,6 @@ MODULE_OBJS := \
|
||||
star_control/base_stars.o \
|
||||
star_control/camera_auto_mover.o \
|
||||
star_control/camera_mover.o \
|
||||
star_control/daffine.o \
|
||||
star_control/dvector.o \
|
||||
star_control/fmatrix.o \
|
||||
star_control/fpoint.o \
|
||||
star_control/fpose.o \
|
||||
|
@ -1,232 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/star_control/daffine.h"
|
||||
#include "titanic/star_control/fmatrix.h" // includes FVector
|
||||
#include "titanic/star_control/matrix_inv.h"
|
||||
#include "titanic/star_control/matrix_transform.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
DAffine::DAffine() :
|
||||
_col1(0.0, 0.0, 0.0), _col2(0.0, 0.0, 0.0), _col3(0.0, 0.0, 0.0), _col4(0.0, 0.0, 0.0) {
|
||||
}
|
||||
|
||||
DAffine::DAffine(int mode, const DVector &src) {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
_col1._x = 1.0;
|
||||
_col2._y = 1.0;
|
||||
_col3._z = 1.0;
|
||||
_col4 = src;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_col1._x = src._x;
|
||||
_col2._y = src._y;
|
||||
_col3._z = src._z;
|
||||
break;
|
||||
|
||||
default:
|
||||
_col1._x = 1.0;
|
||||
_col2._y = 1.0;
|
||||
_col3._z = 1.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DAffine::DAffine(Axis axis, double angleDeg) {
|
||||
setRotationMatrix(axis, angleDeg);
|
||||
}
|
||||
|
||||
DAffine::DAffine(const FMatrix &src) {
|
||||
_col1 = src._row1;
|
||||
_col2 = src._row2;
|
||||
_col3 = src._row3;
|
||||
}
|
||||
|
||||
void DAffine::clear() {
|
||||
_col1._x = 0.0;
|
||||
_col1._y = 0.0;
|
||||
_col1._z = 0.0;
|
||||
_col2._x = 0.0;
|
||||
_col2._y = 0.0;
|
||||
_col2._z = 0.0;
|
||||
_col3._x = 0.0;
|
||||
_col3._y = 0.0;
|
||||
_col3._z = 0.0;
|
||||
_col4._x = 0.0;
|
||||
_col4._y = 0.0;
|
||||
_col4._z = 0.0;
|
||||
}
|
||||
|
||||
// Source: https://en.wikipedia.org/wiki/Rotation_matrix
|
||||
void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
|
||||
clear();
|
||||
|
||||
double sinVal = sin(angleDeg * Deg2Rad);
|
||||
double cosVal = cos(angleDeg * Deg2Rad);
|
||||
|
||||
switch (axis) {
|
||||
case X_AXIS:
|
||||
_col1._x = 1.0;
|
||||
_col2._y = cosVal;
|
||||
_col2._z = sinVal;
|
||||
_col3._y = -sinVal;
|
||||
_col3._z = cosVal;
|
||||
break;
|
||||
|
||||
case Y_AXIS:
|
||||
_col1._x = cosVal;
|
||||
_col1._z = -sinVal;
|
||||
_col2._y = 1.0;
|
||||
_col3._x = sinVal;
|
||||
_col3._z = cosVal;
|
||||
break;
|
||||
|
||||
case Z_AXIS:
|
||||
_col1._x = cosVal;
|
||||
_col1._y = sinVal;
|
||||
_col2._x = -sinVal;
|
||||
_col2._y = cosVal;
|
||||
_col3._z = 1.0;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DAffine::rotVectAxisY(double angleDeg) {
|
||||
_col1.rotVectAxisY(angleDeg);
|
||||
_col2.rotVectAxisY(angleDeg);
|
||||
_col3.rotVectAxisY(angleDeg);
|
||||
_col4.rotVectAxisY(angleDeg);
|
||||
}
|
||||
|
||||
DAffine DAffine::inverseTransform() const {
|
||||
DAffine m;
|
||||
|
||||
// Create a 4x4 matrix so that the column 4
|
||||
// for the inverse can be obtained,
|
||||
// it is not simply -inv(R)*_col4
|
||||
// Load input matrix
|
||||
double A[16]={_col1._x,_col1._y,_col1._z, 0.0,
|
||||
_col2._x,_col2._y,_col2._z, 0.0,
|
||||
_col3._x,_col3._y,_col3._z, 0.0,
|
||||
_col4._x,_col4._y,_col4._z, 1.0};
|
||||
// Inverse matrix
|
||||
double B[16]={};
|
||||
|
||||
// B contains inverse of A
|
||||
matrix4Inverse<double>(A,B);
|
||||
|
||||
// Inverse of rotation matrix is the transpose
|
||||
// While B contains the inverse of the rotation
|
||||
// this method is more numerically accurate
|
||||
m._col1._x = _col1._x;
|
||||
m._col2._x = _col1._y;
|
||||
m._col3._x = _col1._z;
|
||||
m._col1._y = _col2._x;
|
||||
m._col2._y = _col2._y;
|
||||
m._col3._y = _col2._z;
|
||||
m._col1._z = _col3._x;
|
||||
m._col2._z = _col3._y;
|
||||
m._col3._z = _col3._z;
|
||||
|
||||
m._col4._x = B[12];
|
||||
m._col4._y = B[13];
|
||||
m._col4._z = B[14];
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
//TODO: Check math and provide source
|
||||
void DAffine::loadTransform(const CMatrixTransform &src) {
|
||||
double total = src.fn1();
|
||||
double factor = (total <= 0.0) ? 0.0 : 2.0 / total;
|
||||
DVector temp1V = src._vector * factor;
|
||||
DVector temp2V = temp1V * src._vector;
|
||||
|
||||
double val1 = temp1V._y * src._vector._x;
|
||||
double val2 = temp1V._z * src._vector._x;
|
||||
double val3 = temp1V._z * src._vector._y;
|
||||
double val4 = temp1V._x * src._field0;
|
||||
double val5 = temp1V._y * src._field0;
|
||||
double val6 = temp1V._z * src._field0;
|
||||
|
||||
_col1._x = 1.0 - (temp2V._z + temp2V._y);
|
||||
_col1._y = val1 + val6;
|
||||
_col1._z = val2 - val5;
|
||||
_col2._x = val1 - val6;
|
||||
_col2._y = 1.0 - (temp2V._z + temp2V._x);
|
||||
_col2._z = val3 + val4;
|
||||
_col3._x = val2 + val5;
|
||||
_col3._y = val3 - val4;
|
||||
_col3._z = 1.0 - (temp2V._y + temp2V._x);
|
||||
_col4._x = 0;
|
||||
_col4._y = 0;
|
||||
_col4._z = 0;
|
||||
}
|
||||
|
||||
//TODO: Check math and provide source
|
||||
DAffine DAffine::compose(const DAffine &m) {
|
||||
DAffine dm;
|
||||
dm._col1._x = m._col3._x * _col1._z + m._col2._x * _col1._y
|
||||
+ m._col1._x * _col1._x;
|
||||
dm._col1._y = _col1._x * m._col1._y + m._col3._y * _col1._z
|
||||
+ m._col2._y * _col1._y;
|
||||
dm._col1._z = _col1._x * m._col1._z + m._col3._z * _col1._z
|
||||
+ m._col2._z * _col1._y;
|
||||
dm._col2._x = m._col1._x * _col2._x + _col2._y * m._col2._x
|
||||
+ _col2._z * m._col3._x;
|
||||
dm._col2._y = _col2._y * m._col2._y + _col2._z * m._col3._y
|
||||
+ m._col1._y * _col2._x;
|
||||
dm._col2._z = m._col1._z * _col2._x + _col2._y * m._col2._z
|
||||
+ _col2._z * m._col3._z;
|
||||
dm._col3._x = m._col1._x * _col3._x + _col3._y * m._col2._x
|
||||
+ _col3._z * m._col3._x;
|
||||
dm._col3._y = _col3._y * m._col2._y + _col3._z * m._col3._y
|
||||
+ m._col1._y * _col3._x;
|
||||
dm._col3._z = m._col2._z * _col3._y + m._col3._z * _col3._z
|
||||
+ m._col1._z * _col3._x;
|
||||
dm._col4._x = m._col1._x * _col4._x + _col4._y * m._col2._x
|
||||
+ _col4._z * m._col3._x + m._col4._x;
|
||||
dm._col4._y = _col4._z * m._col3._y + _col4._y * m._col2._y
|
||||
+ _col4._x * m._col1._y + m._col4._y;
|
||||
dm._col4._z = _col4._y * m._col2._z + _col4._x * m._col1._z
|
||||
+ _col4._z * m._col3._z + m._col4._z;
|
||||
|
||||
return dm;
|
||||
}
|
||||
|
||||
DAffine DAffine::compose2(const DAffine &m) {
|
||||
DAffine dm;
|
||||
dm._col1 = _col1.dAffMatrixProdVec(m);
|
||||
dm._col2 = _col2.dAffMatrixProdVec(m);
|
||||
dm._col3 = _col3.dAffMatrixProdVec(m);
|
||||
dm._col4 = _col4.dAffMatrixProdVec(m);
|
||||
|
||||
return dm;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
@ -1,94 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_DAFFINE_H
|
||||
#define TITANIC_DAFFINE_H
|
||||
|
||||
#include "titanic/star_control/dvector.h"
|
||||
#include "titanic/star_control/fvector.h" // definition of Axis enum
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class FMatrix;
|
||||
class CMatrixTransform;
|
||||
|
||||
/**
|
||||
* Affine transformation.
|
||||
*
|
||||
* Handles transformation functions between affine spaces,
|
||||
* which preserves points, straight lines and planes
|
||||
*/
|
||||
class DAffine {
|
||||
private:
|
||||
static DAffine *_static;
|
||||
public:
|
||||
DVector _col1;
|
||||
DVector _col2;
|
||||
DVector _col3;
|
||||
DVector _col4;
|
||||
public:
|
||||
DAffine();
|
||||
// TODO: consider making mode an enum since that is more helpful when it is used in code
|
||||
DAffine(int mode, const DVector &src);
|
||||
DAffine(Axis axis, double angleDeg);
|
||||
DAffine(const FMatrix &src);
|
||||
|
||||
/**
|
||||
* Sets all elements to zero
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Sets up an affine matrix for rotating on a given axis by an amount in degrees
|
||||
*/
|
||||
void setRotationMatrix(Axis axis, double angleDeg);
|
||||
|
||||
/**
|
||||
* Rotate this DAffine about the Y axis
|
||||
*/
|
||||
void rotVectAxisY(double angleDeg);
|
||||
|
||||
/**
|
||||
* Return the Inverse of this Daffine
|
||||
*/
|
||||
DAffine inverseTransform() const;
|
||||
|
||||
/**
|
||||
* Change this Daffine to have its first three columns be some mapping from src matrix
|
||||
* and the 4rth column to be (three) zeros. The mapping is not as simple as replacing
|
||||
* matching row/colmn indices
|
||||
*/
|
||||
void loadTransform(const CMatrixTransform &src);
|
||||
|
||||
/**
|
||||
* Do the affine product between this Daffine on the right
|
||||
* and the m Daffine matrix on the left. This product is NOT the same
|
||||
* as multiplying two matrices of dimensions 3x4.
|
||||
*/
|
||||
DAffine compose(const DAffine &m);
|
||||
|
||||
DAffine compose2(const DAffine &m);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_DAFFINE_H */
|
@ -1,113 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/star_control/dvector.h"
|
||||
#include "titanic/star_control/daffine.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool DVector::normalize(double & hyp) {
|
||||
hyp = sqrt(_x * _x + _y * _y + _z * _z);
|
||||
if (hyp==0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_x *= 1.0 / hyp;
|
||||
_y *= 1.0 / hyp;
|
||||
_z *= 1.0 / hyp;
|
||||
return true;
|
||||
}
|
||||
|
||||
double DVector::getDistance(const DVector &src) {
|
||||
return sqrt((src._x - _x) * (src._x - _x) + (src._y - _y) * (src._y - _y) + (src._z - _z) * (src._z - _z));
|
||||
}
|
||||
|
||||
DVector DVector::dAffMatrixProdVec(const DAffine &m) {
|
||||
DVector dest;
|
||||
dest._x = m._col1._x * _x
|
||||
+ m._col2._x * _y + m._col3._x * _z
|
||||
+ m._col4._x;
|
||||
|
||||
dest._y = m._col1._y * _x
|
||||
+ m._col2._y * _y + m._col3._y * _z
|
||||
+ m._col4._y;
|
||||
|
||||
dest._z = m._col1._z * _x
|
||||
+ m._col2._z * _y + m._col3._z * _z
|
||||
+ m._col4._z;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void DVector::rotVectAxisY(double angleDeg) {
|
||||
double sinVal = sin(angleDeg * Deg2Rad);
|
||||
double cosVal = cos(angleDeg * Deg2Rad);
|
||||
double x = cosVal * _x - sinVal * _z;
|
||||
double z = cosVal * _z + sinVal * _x;
|
||||
|
||||
_x = x;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
DVector DVector::getAnglesAsVect() const {
|
||||
DVector vector = *this;
|
||||
DVector dest;
|
||||
|
||||
if (!vector.normalize(dest._x)) {
|
||||
// Makes this vector have magnitude=1, put the scale amount in dest._x,
|
||||
// but if it is unsuccessful, crash
|
||||
assert(dest._x);
|
||||
}
|
||||
|
||||
dest._y = acos(vector._y); // radian distance/angle that this vector's y component is from the +y axis,
|
||||
// result is restricted to [0,pi]
|
||||
dest._z = atan2(vector._x,vector._z); // result is restricted to [-pi,pi]
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
DAffine DVector::getFrameTransform(const DVector &v) {
|
||||
DAffine matrix1, matrix2, matrix3, matrix4;
|
||||
|
||||
DVector vector1 = getAnglesAsVect();
|
||||
matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
|
||||
matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg);
|
||||
matrix3 = matrix1.compose(matrix2);
|
||||
matrix4 = matrix3.inverseTransform();
|
||||
|
||||
vector1 = v.getAnglesAsVect();
|
||||
matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
|
||||
matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg);
|
||||
matrix3 = matrix1.compose(matrix2);
|
||||
|
||||
return matrix4.compose(matrix3);
|
||||
}
|
||||
|
||||
DAffine DVector::formRotXY() const {
|
||||
DVector v1 = getAnglesAsVect();
|
||||
DAffine m1, m2;
|
||||
m1.setRotationMatrix(X_AXIS, v1._y * Rad2Deg);
|
||||
m2.setRotationMatrix(Y_AXIS, v1._z * Rad2Deg);
|
||||
return m1.compose(m2);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
@ -1,136 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_DVECTOR_H
|
||||
#define TITANIC_DVECTOR_H
|
||||
|
||||
#include "titanic/star_control/fvector.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class DAffine;
|
||||
|
||||
/**
|
||||
* Double based vector class.
|
||||
* @remarks TODO: See if it can be merged with FVector
|
||||
*/
|
||||
class DVector {
|
||||
public:
|
||||
double _x, _y, _z;
|
||||
public:
|
||||
DVector() : _x(0), _y(0), _z(0) {}
|
||||
DVector(double x, double y, double z) : _x(x), _y(y), _z(z) {}
|
||||
DVector(const FVector &v) : _x(v._x), _y(v._y), _z(v._z) {}
|
||||
|
||||
/**
|
||||
* Attempts to normalizes the vector so the length from origin equals 1.0
|
||||
* Return value is whether or not it was successful in normalizing
|
||||
* First argument is scale value that normalizes the vector
|
||||
* TODO: split this function into 2. One that calculates the normalization
|
||||
* and another that does the normalization. The 2nd would assert if a
|
||||
* normalization of one was requested. This is cleaner than the current
|
||||
* implementation.
|
||||
*/
|
||||
bool normalize(double &);
|
||||
|
||||
/**
|
||||
* Returns the distance between this vector and the passed one
|
||||
*/
|
||||
double getDistance(const DVector &src);
|
||||
|
||||
/**
|
||||
* Returns the matrix product with this vector and
|
||||
* also does a z translations. Doesn't change this vector
|
||||
*/
|
||||
DVector dAffMatrixProdVec(const DAffine &m);
|
||||
|
||||
/**
|
||||
* Rotate this vector about the Y axis
|
||||
*/
|
||||
void rotVectAxisY(double angleDeg);
|
||||
|
||||
/**
|
||||
* Returns a vector, v, that represents a magnitude, and two angles in radians
|
||||
* 1. Scale this vector to be unit magnitude and store scale in x component of v
|
||||
* 2. X rotation angle from +y axis of this vector is put in y component of v
|
||||
* 3. z component output of v is the 4-quadrant angle that z makes with x (Y axis rotation)
|
||||
*/
|
||||
DVector getAnglesAsVect() const;
|
||||
|
||||
/**
|
||||
* Returns a matrix that contains the frame rotation based on this vector and
|
||||
* a vector rotation based on input vector v
|
||||
*/
|
||||
DAffine getFrameTransform(const DVector &v);
|
||||
|
||||
/**
|
||||
* Constructs an affine matrix that does a x then a y axis frame rotation
|
||||
* based on the orientation of this vector
|
||||
*/
|
||||
DAffine formRotXY() const;
|
||||
|
||||
/**
|
||||
* Returns true if the passed vector equals this one
|
||||
*/
|
||||
bool operator==(const DVector &src) const {
|
||||
return _x == src._x && _y == src._y && _z == src._z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the passed vector does not equal this one
|
||||
*/
|
||||
bool operator!=(const DVector &src) const {
|
||||
return _x != src._x || _y != src._y || _z != src._z;
|
||||
}
|
||||
|
||||
DVector operator+(const DVector &delta) const {
|
||||
return DVector(_x + delta._x, _y + delta._y, _z + delta._z);
|
||||
}
|
||||
|
||||
DVector operator-(const DVector &delta) const {
|
||||
return DVector(_x - delta._x, _y - delta._y, _z - delta._z);
|
||||
}
|
||||
|
||||
void operator+=(const DVector &delta) {
|
||||
_x += delta._x;
|
||||
_y += delta._y;
|
||||
_z += delta._z;
|
||||
}
|
||||
|
||||
void operator-=(const DVector &delta) {
|
||||
_x -= delta._x;
|
||||
_y -= delta._y;
|
||||
_z -= delta._z;
|
||||
}
|
||||
|
||||
const DVector operator*(double right) const {
|
||||
return DVector(_x * right, _y * right, _z * right);
|
||||
}
|
||||
|
||||
const DVector operator*(const DVector &right) const {
|
||||
return DVector(_x * right._x, _y * right._y, _z * right._z);
|
||||
}
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_DVECTOR_H */
|
@ -51,22 +51,12 @@ FMatrix::FMatrix(const FVector &row1, const FVector &row2, const FVector &row3)
|
||||
_row3 = row3;
|
||||
}
|
||||
|
||||
/*FMatrix::FMatrix(const DAffine &src) {
|
||||
copyFrom(src);
|
||||
}*/
|
||||
|
||||
FMatrix::FMatrix(const FMatrix &src) {
|
||||
_row1 = src._row1;
|
||||
_row2 = src._row2;
|
||||
_row3 = src._row3;
|
||||
}
|
||||
|
||||
/*void FMatrix::copyFrom(const DAffine &src) {
|
||||
_row1 = src._col1;
|
||||
_row2 = src._col2;
|
||||
_row3 = src._col3;
|
||||
}*/
|
||||
|
||||
void FMatrix::load(SimpleFile *file, int param) {
|
||||
_row1._x = file->readFloat();
|
||||
_row1._y = file->readFloat();
|
||||
@ -115,12 +105,6 @@ void FMatrix::set(const FVector &row1, const FVector &row2, const FVector &row3)
|
||||
_row3 = row3;
|
||||
}
|
||||
|
||||
/*void FMatrix::set(const DVector &row1, const DVector &row2, const DVector &row3) {
|
||||
_row1 = row1;
|
||||
_row2 = row2;
|
||||
_row3 = row3;
|
||||
}*/
|
||||
|
||||
void FMatrix::set(const FVector &v) {
|
||||
_row3 = v;
|
||||
_row2 = _row3.swapComponents();
|
||||
|
@ -27,20 +27,13 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
//class DAffine;
|
||||
//class DVector;
|
||||
class SimpleFile;
|
||||
|
||||
/**
|
||||
* Floating point matrix class.
|
||||
* @remarks TODO: See if it can be merged with DAffine
|
||||
|
||||
*/
|
||||
class FMatrix {
|
||||
private:
|
||||
/**
|
||||
* Copys data from a given source
|
||||
*/
|
||||
//void copyFrom(const DAffine &src);
|
||||
public:
|
||||
FVector _row1;
|
||||
FVector _row2;
|
||||
@ -48,7 +41,6 @@ public:
|
||||
public:
|
||||
FMatrix();
|
||||
FMatrix(const FVector &, const FVector &, const FVector &);
|
||||
//FMatrix(const DAffine &src);
|
||||
FMatrix(const FMatrix &src);
|
||||
|
||||
/**
|
||||
@ -81,11 +73,6 @@ public:
|
||||
*/
|
||||
void set(const FVector &row1, const FVector &row2, const FVector &row3);
|
||||
|
||||
/**
|
||||
* Sets the data for the matrix
|
||||
*/
|
||||
//void set(const DVector &row1, const DVector &row2, const DVector &row3);
|
||||
|
||||
/**
|
||||
* Sets the data for the matrix from a vector
|
||||
*/
|
||||
|
@ -21,8 +21,6 @@
|
||||
*/
|
||||
|
||||
#include "titanic/star_control/fvector.h"
|
||||
//#include "titanic/star_control/dvector.h"
|
||||
//#include "titanic/star_control/daffine.h"
|
||||
#include "titanic/star_control/fpose.h"
|
||||
//#include "common/algorithm.h"
|
||||
//#include "common/textconsole.h"
|
||||
@ -131,7 +129,6 @@ FPose FVector::getFrameTransform(const FVector &v) {
|
||||
FVector vector1 = getAnglesAsVect();
|
||||
matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
|
||||
matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg);
|
||||
//matrix3 = matrix1.compose(matrix2);
|
||||
fposeProd(matrix1,matrix2,matrix3);
|
||||
matrix4 = matrix3.inverseTransform();
|
||||
|
||||
@ -139,20 +136,11 @@ FPose FVector::getFrameTransform(const FVector &v) {
|
||||
matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
|
||||
matrix2.setRotationMatrix(Y_AXIS, vector1._z * Rad2Deg);
|
||||
fposeProd(matrix1,matrix2,matrix3);
|
||||
//matrix3 = matrix1.compose(matrix2);
|
||||
fposeProd(matrix4,matrix3,matrix1);
|
||||
|
||||
return matrix1; //matrix4.compose(matrix3);
|
||||
return matrix1;
|
||||
}
|
||||
|
||||
/*DAffine FVector::formRotXY() const {
|
||||
FVector v1 = getAnglesAsVect();
|
||||
DAffine m1, m2;
|
||||
m1.setRotationMatrix(X_AXIS, v1._y * Rad2Deg);
|
||||
m2.setRotationMatrix(Y_AXIS, v1._z * Rad2Deg);
|
||||
return m1.compose(m2);
|
||||
}*/
|
||||
|
||||
FPose FVector::formRotXY() const {
|
||||
FVector v1 = getAnglesAsVect();
|
||||
FPose m1, m2;
|
||||
|
@ -32,8 +32,6 @@ const double Deg2Rad = 1.0 / Rad2Deg;
|
||||
enum Axis { X_AXIS, Y_AXIS, Z_AXIS };
|
||||
|
||||
class FPose;
|
||||
//class DVector;
|
||||
//class DAffine;
|
||||
|
||||
/**
|
||||
* Floating point vector class.
|
||||
@ -45,7 +43,6 @@ public:
|
||||
public:
|
||||
FVector() : _x(0), _y(0), _z(0) {}
|
||||
FVector(float x, float y, float z) : _x(x), _y(y), _z(z) {}
|
||||
//FVector(const DVector &src);
|
||||
|
||||
/**
|
||||
* Clears the vector
|
||||
@ -123,7 +120,6 @@ public:
|
||||
* Constructs an affine matrix that does a x then a y axis frame rotation
|
||||
* based on the orientation of this vector
|
||||
*/
|
||||
//DAffine formRotXY() const;
|
||||
FPose formRotXY() const;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,6 @@ private:
|
||||
CMatrixTransform resize(double factor) const;
|
||||
public:
|
||||
double _field0;
|
||||
//DVector _vector;
|
||||
FVector _vector;
|
||||
public:
|
||||
CMatrixTransform() : _field0(1.0) {}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "titanic/star_control/star_camera.h"
|
||||
#include "titanic/debugger.h"
|
||||
#include "titanic/star_control/camera_mover.h"
|
||||
#include "titanic/star_control/daffine.h"
|
||||
#include "titanic/star_control/fmatrix.h"
|
||||
#include "titanic/star_control/fpoint.h"
|
||||
#include "titanic/star_control/marked_camera_mover.h"
|
||||
@ -324,21 +323,18 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
|
||||
FVector mrow1, mrow2, mrow3;
|
||||
FVector tempV1, diffV, multV, multV2, tempV3, tempV7;
|
||||
|
||||
//DAffine subX(0, _lockedStarsPos._row1);
|
||||
FPose subX(0, _lockedStarsPos._row1);
|
||||
FPose subY(Y_AXIS, angles._y);
|
||||
//DAffine subY(Y_AXIS, angles._y);
|
||||
|
||||
tempV1 = _lockedStarsPos._row2 - _lockedStarsPos._row1;
|
||||
diffV = tempV1;
|
||||
m1 = diffV.formRotXY();
|
||||
FPose m11;
|
||||
fposeProd(m1,subX,m11);
|
||||
//m1 = m1.compose(subX);
|
||||
|
||||
subX = m11.inverseTransform();
|
||||
FPose m12;
|
||||
fposeProd(subX,subY,m12);
|
||||
//subX = subX.compose(subY);
|
||||
|
||||
FMatrix m3 = _viewport.getOrientation();
|
||||
tempV2 = _viewport._position;
|
||||
@ -524,15 +520,11 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
|
||||
|
||||
_isInLockingProcess = true;
|
||||
FVector firstStarPosition = _lockedStarsPos._row1;
|
||||
//DAffine m2(0, firstStarPosition); // Identity matrix and col4 as the 1st stars position
|
||||
FPose m3(0, firstStarPosition); // Identity matrix and row4 as the 1st stars position
|
||||
FVector starDelta = secondStarPosition - firstStarPosition;
|
||||
//DAffine m1 = starDelta.formRotXY();
|
||||
FPose m10 = starDelta.formRotXY();
|
||||
FPose m11;
|
||||
fposeProd(m10,m3,m11);
|
||||
//m1 = m1.compose(m2);
|
||||
//m2 = m1.inverseTransform();
|
||||
|
||||
float A[16]={m11._row1._x,m11._row1._y,m11._row1._z, 0.0,
|
||||
m11._row2._x,m11._row2._y,m11._row2._z, 0.0,
|
||||
@ -549,11 +541,6 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
|
||||
m10._vector._z=B[14];
|
||||
|
||||
FVector oldPos = _viewport._position;
|
||||
//DAffine m5;
|
||||
//m5._col1 = viewport->_position;
|
||||
//m5._col2 = FVector(0.0, 0.0, 0.0);
|
||||
//m5._col3 = FVector(0.0, 0.0, 0.0);
|
||||
//m5._col4 = FVector(0.0, 0.0, 0.0);
|
||||
|
||||
FPose m4;
|
||||
m4._row1 = viewport->_position;
|
||||
@ -589,10 +576,7 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
|
||||
m4._vector = tempV3;
|
||||
|
||||
|
||||
//FVector viewPosition = oldPos.MatProdColVect(m2);
|
||||
FVector viewPosition2 = oldPos.MatProdRowVect(m10);
|
||||
//m4 = m4.compose2(m2);
|
||||
//fposeProd(m4,m10,m3);
|
||||
m3 = m4.compose2(m10);
|
||||
|
||||
float minDistance;
|
||||
@ -602,9 +586,7 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
|
||||
float minDegree = calcAngleForMinDist(x1,x2,minDistance);
|
||||
|
||||
m3.rotVectAxisY((double)minDegree);
|
||||
//m4 = m4.compose2(m1);
|
||||
FPose m13;
|
||||
//fposeProd(m3,m11,m13);
|
||||
m13 = m3.compose2(m11);
|
||||
|
||||
m13._row3 -= m13._row1;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "titanic/star_control/unmarked_camera_mover.h"
|
||||
#include "titanic/debugger.h"
|
||||
#include "titanic/star_control/base_stars.h" // includes class CStarVector
|
||||
//#include "titanic/star_control/dvector.h"
|
||||
#include "titanic/star_control/fpose.h"
|
||||
#include "titanic/star_control/error_code.h"
|
||||
#include "titanic/star_control/fmatrix.h" // includes class FVector
|
||||
@ -54,7 +53,6 @@ void CUnmarkedCameraMover::transitionBetweenOrientations(const FVector &v1, cons
|
||||
FVector vector2 = v2;
|
||||
FPose matrix1 = vector2.getFrameTransform(vector1);
|
||||
FPose matrix2 = matrix1.compose(m);
|
||||
//fposeProd(matrix1,m,matrix2);
|
||||
|
||||
_autoMover.setOrientations(m, matrix2);
|
||||
incLockCount();
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
* Applys a rotation matrix to the current
|
||||
* orientation
|
||||
*/
|
||||
void changeOrientation(const FMatrix &matrix);\
|
||||
void changeOrientation(const FMatrix &matrix);
|
||||
|
||||
FPose getPose();
|
||||
FPose getRawPose();
|
||||
|
Loading…
Reference in New Issue
Block a user