Browse Source

Name consistency

Godzil 4 years ago
parent
commit
863bb2a34b

+ 2 - 2
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);

+ 2 - 2
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);
 };

+ 3 - 3
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);
 

+ 3 - 3
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();
    

+ 6 - 6
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"));
 

+ 1 - 1
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);
             }
         }
     }

+ 1 - 1
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);
             }
 
         }

+ 1 - 1
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));
 

+ 9 - 9
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);