Skip to content

Commit

Permalink
Add makeOrtho2d function
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-koyama committed Jul 10, 2018
1 parent e6f61ae commit 85df0cc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions three-dim-util/matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ namespace threedimutil
0.0, 0.0, - 2.0 / dz, tz,
0.0, 0.0, 0.0, 1.0).finished();
}

inline Eigen::Matrix4d makeOrtho2d(double left,
double right,
double bottom,
double top)
{
const double dx = right - left;
const double dy = top - bottom;
const double tx = - (right + left) / dx;
const double ty = - (top + bottom) / dy;
return (Eigen::Matrix4d() << 2.0 / dx, 0.0, 0.0, tx,
0.0, 2.0 / dy, 0.0, ty,
0.0, 0.0, - 1.0, 0.0,
0.0, 0.0, 0.0, 1.0).finished();
}
}

#endif /* matrix_hpp */

0 comments on commit 85df0cc

Please sign in to comment.