Skip to content

Commit

Permalink
Base: [skip ci] add class ViewOrthoProjMatrix for orthogonal projecti…
Browse files Browse the repository at this point in the history
…ons in 3d
  • Loading branch information
wwmayer committed Aug 7, 2020
1 parent 4ce85d3 commit 0dff8a6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Base/ViewProj.cpp
Expand Up @@ -191,3 +191,41 @@ Vector3d ViewProjMatrix::inverse (const Vector3d& src) const

return dst;
}

// ----------------------------------------------------------------------------

ViewOrthoProjMatrix::ViewOrthoProjMatrix (const Matrix4D &rclMtx)
: _clMtx(rclMtx)
{
_clMtxInv = _clMtx;
_clMtxInv.inverse();
}

ViewOrthoProjMatrix::~ViewOrthoProjMatrix()
{
}

Matrix4D ViewOrthoProjMatrix::getProjectionMatrix (void) const
{
return _clMtx;
}

Vector3f ViewOrthoProjMatrix::operator()(const Vector3f &rclPt) const
{
return Vector3f(_clMtx * rclPt);
}

Vector3d ViewOrthoProjMatrix::operator()(const Vector3d &rclPt) const
{
return Vector3d(_clMtx * rclPt);
}

Vector3f ViewOrthoProjMatrix::inverse (const Vector3f &rclPt) const
{
return Vector3f(_clMtxInv * rclPt);
}

Vector3d ViewOrthoProjMatrix::inverse (const Vector3d &rclPt) const
{
return Vector3d(_clMtxInv * rclPt);
}
23 changes: 23 additions & 0 deletions src/Base/ViewProj.h
Expand Up @@ -88,6 +88,29 @@ class BaseExport ViewProjMatrix : public ViewProjMethod
Matrix4D _clMtx, _clMtxInv;
};

/**
* The ViewOrthoProjMatrix class returns the result of the multiplication
* of the 3D vector and the transformation matrix.
* Unlike ViewProjMatrix this class is not supposed to project points onto
* a viewport but project points onto a plane in 3D.
*/
class BaseExport ViewOrthoProjMatrix : public ViewProjMethod
{
public:
ViewOrthoProjMatrix (const Matrix4D &rclMtx);
virtual ~ViewOrthoProjMatrix();

Vector3f operator()(const Vector3f &rclPt) const;
Vector3d operator()(const Vector3d &rclPt) const;
Vector3f inverse (const Vector3f &rclPt) const;
Vector3d inverse (const Vector3d &rclPt) const;

Matrix4D getProjectionMatrix (void) const;

protected:
Matrix4D _clMtx, _clMtxInv;
};

} // namespace Base

#endif // BASE_VIEWPROJ_H

0 comments on commit 0dff8a6

Please sign in to comment.