Skip to content

Commit

Permalink
fixed rotator for z-up vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
sevec committed Jul 5, 2020
1 parent 2118cff commit 4ff932e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,10 @@ inline Mat33f getRotationMatrix(const Vec3f& axis, const float angle) {

// (0,0,1) -> dir rotator
inline Mat33f getRotatorTo(const Vec3f& dir) {
const Vec3f up(0, 0, 1);
if (dir == up) {
return Mat33f::identity();
Vec3f up(0, 0, 1);
const float dot = dotProd(dir, up);
if (fabs(dot) > 0.999999f) {
up = Vec3f(1, 0, 0);
}

const Vec3f x = normalize(crossProd(up, dir));
Expand Down
3 changes: 2 additions & 1 deletion UniformGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class UniformGrid {
Idxs dims_;

public:
UniformGrid() = default;
UniformGrid()
: dims_(0) {}

UniformGrid(const Idxs& dims)
: dims_(dims) {
Expand Down

0 comments on commit 4ff932e

Please sign in to comment.