summaryrefslogtreecommitdiff
path: root/main_simple_scanner.cpp
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-12 13:26:50 +0800
committerKeuin <[email protected]>2022-04-12 13:26:50 +0800
commit6421008201f188b83d243af58a3f990a098fadad (patch)
treeb6bd81dafb2832ac102de20bbd500aeda1f3888a /main_simple_scanner.cpp
parent1a00ca37996c15b4575b617e4a4e7d674e66e57e (diff)
Bugfix: output image is upside down.
Diffstat (limited to 'main_simple_scanner.cpp')
-rw-r--r--main_simple_scanner.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/main_simple_scanner.cpp b/main_simple_scanner.cpp
index 9b578d2..99fed35 100644
--- a/main_simple_scanner.cpp
+++ b/main_simple_scanner.cpp
@@ -124,7 +124,7 @@ public:
const auto r = center - viewpoint;
const int img_hw = image_width / 2, img_hh = image_height / 2;
// iterate over every pixel on the image
- for (int j = -img_hh; j < img_hh; ++j) { // axis y
+ for (int j = -img_hh + 1; j <= img_hh; ++j) { // axis y, transformation is needed
for (int i = -img_hw; i < img_hw; ++i) { // axis x
const vec3d off{
.x=1.0 * i / img_hw * half_width,
@@ -134,7 +134,7 @@ public:
const auto dir = r + off; // direction vector from camera to current pixel on screen
const ray3d ray{viewpoint, dir}; // from camera to pixel (on the viewport)
const auto pixel = color(ray);
- image.set(i + img_hw, j + img_hh, pixel);
+ image.set(i + img_hw, -j + img_hh, pixel);
}
}
return image;