History

Working on QR decomposition.

Andrzej Kapolka committed 12 years ago

Commit 3fe6e301 parent 7c1333d1 file · +22 −0Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+22−0
@@ -1850,6 +1850,28 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { · 1849 unmodified lines
1850 }1850 }
1851 normal = glm::normalize(normal);1851 normal = glm::normalize(normal);
1852 center /= crossingCount;1852 center /= crossingCount;
1853
1854 // use a sequence of Givens rotations to perform a QR decomposition
1855 // see http://www.cs.rice.edu/~jwarren/papers/techreport02408.pdf
1856 glm::mat4 r(0.0f);
1857 glm::vec4 bottom;
1858 for (int i = 0; i < crossingCount; i++) {
1859 const EdgeCrossing& crossing = crossings[i];
1860 bottom = glm::vec4(crossing.normal, glm::dot(crossing.normal, crossing.point));
1861
1862 for (int j = 0; j < 4; j++) {
1863 float angle = glm::atan(-bottom[j], r[j][j]);
1864 float sina = glm::sin(angle);
1865 float cosa = glm::cos(angle);
1866
1867 for (int k = 0; k < 4; k++) {
1868 float tmp = bottom[k];
1869 bottom[k] = sina * r[k][j] + cosa * tmp;
1870 r[k][j] = cosa * r[k][j] - sina * tmp;
1871 }
1872 }
1873 }
1874
1853 if (totalWeight > 0.0f) {1875 if (totalWeight > 0.0f) {
1854 materialWeights *= (EIGHT_BIT_MAXIMUM / totalWeight);1876 materialWeights *= (EIGHT_BIT_MAXIMUM / totalWeight);
1855 }1877 }