Skip to content

Commit

Permalink
TITANIC: Named some functions in fvector
Browse files Browse the repository at this point in the history
  • Loading branch information
dafioram committed Aug 21, 2017
1 parent 2a96a6f commit 04598dd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/star_control/fmatrix.cpp
Expand Up @@ -124,7 +124,7 @@ void FMatrix::set(const DVector &row1, const DVector &row2, const DVector &row3)

void FMatrix::set(const FVector &v) {
_row3 = v;
_row2 = _row3.fn1();
_row2 = _row3.swapComponents();

_row1 = _row3.crossProduct(_row2);

Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/star_control/fvector.cpp
Expand Up @@ -31,7 +31,7 @@ namespace Titanic {
FVector::FVector(const DVector &src) : _x(src._x), _y(src._y), _z(src._z) {
}

FVector FVector::fn1() const {
FVector FVector::swapComponents() const {
return FVector(
(ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 &&
ABS(_x - _z) < 0.00001) ? -_y : _y,
Expand Down Expand Up @@ -78,7 +78,7 @@ float FVector::getDistance(const FVector &src) const {
return sqrt(xd * xd + yd * yd + zd * zd);
}

FVector FVector::fn5(const FPose &pose) const {
FVector FVector::MatProdRowVect(const FPose &pose) const {
FVector v;
v._x = pose._row2._x * _y + pose._row3._x * _z + pose._row1._x * _x + pose._vector._x;
v._y = pose._row2._y * _y + pose._row3._y * _z + pose._row1._y * _x + pose._vector._y;
Expand Down
13 changes: 11 additions & 2 deletions engines/titanic/star_control/fvector.h
Expand Up @@ -51,7 +51,12 @@ class FVector {
_x = _y = _z = 0.0;
}

FVector fn1() const;
/**
* Returns a vector with all components of this vector circularlly rotated up 1.
* this x being _y, this y being _z, and this z being _x. A sign change may also
* be done on x/_y based on some conditions.
*/
FVector swapComponents() const;

/**
* Calculates the cross-product between this matrix and a passed one
Expand Down Expand Up @@ -80,7 +85,11 @@ class FVector {
*/
float getDistance(const FVector &src) const;

FVector fn5(const FPose &pose) const;
/**
* Returns a vector that is this vector on the left as a row vector
* times the 3x4 affine matrix on the right.
*/
FVector MatProdRowVect(const FPose &pose) const;

/**
* Returns true if the passed vector equals this one
Expand Down
8 changes: 4 additions & 4 deletions engines/titanic/star_control/star_camera.cpp
Expand Up @@ -269,10 +269,10 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
tempV5 -= row1;
tempV6 -= row1;

tempV1 = tempV1.fn5(pose);
tempV4 = tempV4.fn5(pose);
tempV5 = tempV5.fn5(pose);
tempV6 = tempV6.fn5(pose);
tempV1 = tempV1.MatProdRowVect(pose);
tempV4 = tempV4.MatProdRowVect(pose);
tempV5 = tempV5.MatProdRowVect(pose);
tempV6 = tempV6.MatProdRowVect(pose);

tempV4 -= tempV1;
tempV5 -= tempV1;
Expand Down
6 changes: 3 additions & 3 deletions engines/titanic/star_control/viewport.cpp
Expand Up @@ -107,7 +107,7 @@ void CViewport::setPosition(const FVector &v) {
}

void CViewport::setPosition(const FPose &pose) {
_position = _position.fn5(pose);
_position = _position.MatProdRowVect(pose);
_flag = false;
}

Expand Down Expand Up @@ -215,7 +215,7 @@ FVector CViewport::fn16(int index, const FVector &src) {
FVector CViewport::fn17(int index, const FVector &src) {
FVector dest;
FPose pose = getPose();
FVector tv = src.fn5(pose);
FVector tv = src.MatProdRowVect(pose);

dest._x = (_valArray[index] + tv._x)
* _centerVector._x / (_centerVector._y * tv._z);
Expand All @@ -227,7 +227,7 @@ FVector CViewport::fn17(int index, const FVector &src) {
FVector CViewport::fn18(int index, const FVector &src) {
FVector dest;
FPose pose = getRawPose();
FVector tv = src.fn5(pose);
FVector tv = src.MatProdRowVect(pose);

dest._x = (_valArray[index] + tv._x)
* _centerVector._x / (_centerVector._y * tv._z);
Expand Down

0 comments on commit 04598dd

Please sign in to comment.