From 863bb2a34b104492b77c7d698d35c985c0a39ddd Mon Sep 17 00:00:00 2001 From: Godzil Date: Thu, 20 Feb 2020 14:48:11 +0000 Subject: [PATCH] Name consistency --- source/canvas.cpp | 4 ++-- source/include/canvas.h | 4 ++-- source/include/transformation.h | 6 +++--- source/transformation.cpp | 6 +++--- tests/canvas_test.cpp | 12 ++++++------ tests/ch5_test.cpp | 2 +- tests/ch6_test.cpp | 2 +- tests/sphere_test.cpp | 2 +- tests/transformation_test.cpp | 18 +++++++++--------- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/source/canvas.cpp b/source/canvas.cpp index bbe3a99..82f17a8 100644 --- a/source/canvas.cpp +++ b/source/canvas.cpp @@ -30,7 +30,7 @@ Canvas::~Canvas() } } -void Canvas::put_pixel(uint32_t x, uint32_t y, Colour c) +void Canvas::putPixel(uint32_t x, uint32_t y, Colour c) { uint32_t offset = y * this->stride + x * BytePP; this->bitmap[offset + 0] = MAX(MIN(c.red() * 255, 255), 0); @@ -38,7 +38,7 @@ void Canvas::put_pixel(uint32_t x, uint32_t y, Colour c) this->bitmap[offset + 2] = MAX(MIN(c.blue() * 255, 255), 0); } -Colour Canvas::get_pixel(uint32_t x, uint32_t y) +Colour Canvas::getPixel(uint32_t x, uint32_t y) { uint32_t offset = y * this->stride + x * BytePP; return Colour(this->bitmap[offset + 0] / 255, this->bitmap[offset + 1] / 255, this->bitmap[offset + 2] / 255); diff --git a/source/include/canvas.h b/source/include/canvas.h index 5911a2e..46d6f42 100644 --- a/source/include/canvas.h +++ b/source/include/canvas.h @@ -23,8 +23,8 @@ public: Canvas(uint32_t width, uint32_t height); ~Canvas(); - void put_pixel(uint32_t x, uint32_t y, Colour c); - Colour get_pixel(uint32_t x, uint32_t y); + void putPixel(uint32_t x, uint32_t y, Colour c); + Colour getPixel(uint32_t x, uint32_t y); bool SaveAsPNG(const char *filename); }; diff --git a/source/include/transformation.h b/source/include/transformation.h index fa41f3e..b37baa0 100644 --- a/source/include/transformation.h +++ b/source/include/transformation.h @@ -15,9 +15,9 @@ Matrix translation(double x, double y, double z); Matrix scaling(double x, double y, double z); -Matrix rotation_x(double angle); -Matrix rotation_y(double angle); -Matrix rotation_z(double angle); +Matrix rotationX(double angle); +Matrix rotationY(double angle); +Matrix rotationZ(double angle); Matrix shearing(double Xy, double Xx, double Yx, double Yz, double Zx, double Zy); diff --git a/source/transformation.cpp b/source/transformation.cpp index d666ea0..9238da4 100644 --- a/source/transformation.cpp +++ b/source/transformation.cpp @@ -33,7 +33,7 @@ Matrix scaling(double x, double y, double z) return ret; } -Matrix rotation_x(double angle) +Matrix rotationX(double angle) { Matrix ret = Matrix4().identity(); @@ -45,7 +45,7 @@ Matrix rotation_x(double angle) return ret; } -Matrix rotation_y(double angle) +Matrix rotationY(double angle) { Matrix ret = Matrix4().identity(); @@ -57,7 +57,7 @@ Matrix rotation_y(double angle) return ret; } -Matrix rotation_z(double angle) +Matrix rotationZ(double angle) { Matrix ret = Matrix4().identity(); diff --git a/tests/canvas_test.cpp b/tests/canvas_test.cpp index e95f210..84c86fd 100644 --- a/tests/canvas_test.cpp +++ b/tests/canvas_test.cpp @@ -21,7 +21,7 @@ TEST(CanvasTest, Creating_a_canvas) { for(x = 0; x < 10; x++) { - ASSERT_EQ(c.get_pixel(x, y), Colour(0, 0, 0)); + ASSERT_EQ(c.getPixel(x, y), Colour(0, 0, 0)); } } } @@ -31,9 +31,9 @@ TEST(CanvasTest, Test_Writing_pixels_to_a_canvas_Test) Canvas c = Canvas(10, 20); Colour red = Colour(1, 0, 0); - c.put_pixel(2, 3, red); + c.putPixel(2, 3, red); - ASSERT_EQ(c.get_pixel(2, 3), red); + ASSERT_EQ(c.getPixel(2, 3), red); } @@ -44,9 +44,9 @@ TEST(CanvasTest, Save_a_PNG_file) Colour c2 = Colour(0, 0.5, 0); Colour c3 = Colour(-0.5, 0, 1); - c.put_pixel(0, 0, c1); - c.put_pixel(2, 1, c2); - c.put_pixel(4, 2, c3); + c.putPixel(0, 0, c1); + c.putPixel(2, 1, c2); + c.putPixel(4, 2, c3); ASSERT_TRUE(c.SaveAsPNG("Save_a_PNG_file.png")); diff --git a/tests/ch5_test.cpp b/tests/ch5_test.cpp index dabb71f..2b7e0bc 100644 --- a/tests/ch5_test.cpp +++ b/tests/ch5_test.cpp @@ -36,7 +36,7 @@ int main() if (!xs.hit().nothing()) { - c.put_pixel(x, y, red); + c.putPixel(x, y, red); } } } diff --git a/tests/ch6_test.cpp b/tests/ch6_test.cpp index 10c6aca..e80db5e 100644 --- a/tests/ch6_test.cpp +++ b/tests/ch6_test.cpp @@ -47,7 +47,7 @@ int main() Tuple eye = -r.direction; Colour pixelColour = hit.object->material.lighting(light, hitPoint, eye, hitNormalVector); - c.put_pixel(x, y, pixelColour); + c.putPixel(x, y, pixelColour); } } diff --git a/tests/sphere_test.cpp b/tests/sphere_test.cpp index 8b85f25..5328f41 100644 --- a/tests/sphere_test.cpp +++ b/tests/sphere_test.cpp @@ -168,7 +168,7 @@ TEST(SphereTest, Computing_the_normal_on_a_tranformed_sphere) { Sphere s = Sphere(); - s.setTransform(scaling(1, 0.5, 1) * rotation_z(M_PI / 5)); + s.setTransform(scaling(1, 0.5, 1) * rotationZ(M_PI / 5)); Tuple n = s.normalAt(Point(0, sqrt(2)/2, -sqrt(2)/2)); diff --git a/tests/transformation_test.cpp b/tests/transformation_test.cpp index 703855a..d151b66 100644 --- a/tests/transformation_test.cpp +++ b/tests/transformation_test.cpp @@ -78,8 +78,8 @@ TEST(TransformationTest, Reflexion_is_scaling_by_a_negative_value) TEST(TransformationTest, Rotating_a_point_around_the_X_axis) { Point p = Point(0, 1, 0); - Matrix half_quarter = rotation_x(M_PI / 4.); - Matrix full_quarter = rotation_x(M_PI / 2.); + Matrix half_quarter = rotationX(M_PI / 4.); + Matrix full_quarter = rotationX(M_PI / 2.); ASSERT_EQ(half_quarter * p, Point(0, sqrt(2)/2, sqrt(2)/2)); ASSERT_EQ(full_quarter * p, Point(0, 0, 1)); @@ -88,7 +88,7 @@ TEST(TransformationTest, Rotating_a_point_around_the_X_axis) TEST(TransformationTest, The_inverse_of_an_x_rotation_rotates_in_the_opposite_direction) { Point p = Point(0, 1, 0); - Matrix half_quarter = rotation_x(M_PI / 4.); + Matrix half_quarter = rotationX(M_PI / 4.); Matrix inv = half_quarter.inverse(); ASSERT_EQ(inv * p, Point(0, sqrt(2)/2, -sqrt(2)/2)); @@ -97,8 +97,8 @@ TEST(TransformationTest, The_inverse_of_an_x_rotation_rotates_in_the_opposite_di TEST(TransformationTest, Rotating_a_point_around_the_Y_axis) { Point p = Point(0, 0, 1); - Matrix half_quarter = rotation_y(M_PI / 4.); - Matrix full_quarter = rotation_y(M_PI / 2.); + Matrix half_quarter = rotationY(M_PI / 4.); + Matrix full_quarter = rotationY(M_PI / 2.); ASSERT_EQ(half_quarter * p, Point(sqrt(2)/2, 0, sqrt(2)/2)); ASSERT_EQ(full_quarter * p, Point(1, 0, 0)); @@ -107,8 +107,8 @@ TEST(TransformationTest, Rotating_a_point_around_the_Y_axis) TEST(TransformationTest, Rotating_a_point_around_the_Z_axis) { Point p = Point(0, 1, 0); - Matrix half_quarter = rotation_z(M_PI / 4.); - Matrix full_quarter = rotation_z(M_PI / 2.); + Matrix half_quarter = rotationZ(M_PI / 4.); + Matrix full_quarter = rotationZ(M_PI / 2.); ASSERT_EQ(half_quarter * p, Point(-sqrt(2)/2, sqrt(2)/2, 0)); ASSERT_EQ(full_quarter * p, Point(-1, 0, 0)); @@ -165,7 +165,7 @@ TEST(TransformationTest, A_shearing_transformation_moves_z_in_proportion_to_y) TEST(TransformationTest, Individual_trnasformations_are_applied_in_sequence) { Point p = Point(1, 0, 1); - Matrix A = rotation_x(M_PI / 2.); + Matrix A = rotationX(M_PI / 2.); Matrix B = scaling(5, 5, 5); Matrix C = translation(10, 5, 7); @@ -182,7 +182,7 @@ TEST(TransformationTest, Individual_trnasformations_are_applied_in_sequence) TEST(TransformationTest, Chained_transformation_must_be_applied_in_reverse_order) { Point p = Point(1, 0, 1); - Matrix A = rotation_x(M_PI / 2.); + Matrix A = rotationX(M_PI / 2.); Matrix B = scaling(5, 5, 5); Matrix C = translation(10, 5, 7);