void can_project_and_scale_points() { FrameBuffer fb(500, 500); Vect v = Vect(0, 0, 100); fb.projectAndScalePoint(v); ASSERT_EQUAL_FLOAT(v.getX(), 250, 0.1); ASSERT_EQUAL_FLOAT(v.getY(), 250, 0.1); }
/** * Test the modification function */ static void test_modifPoint() { Point * p; p = initPoint(); modifyPoint(p, 5., 4.); ASSERT_EQUAL_FLOAT(p->x, 5); ASSERT_EQUAL_FLOAT(p->y, 4); destroyPoint(p); }
void plot_translated_point() { FrameBuffer fb(500, 500); MeshPoint mp(0, 0, 50); fb.addPoint(mp); Vect::Translate(mp, -10, 0, 0); fb.addPoint(mp); fb.plotPoints("./imgs/fb_test_plot.jpg"); MeshPoint p0 = fb.getPoint(0); MeshPoint p1 = fb.getPoint(1); ASSERT_EQUAL_FLOAT(p0.getX(), 0, 0.00001); ASSERT_EQUAL_FLOAT(p1.getX(), -10, 0.00001); }
void can_project_micropolygon() { MeshPoint mp1(-10, -10, 100); MeshPoint mp2(10, -10, 100); MeshPoint mp3(-10, 10, 100); MeshPoint mp4(10, 10, 100); MicroPolygon poly; poly.a = mp1; poly.b = mp2; poly.c = mp3; poly.d = mp4; FrameBuffer fb(500, 500); fb.projectMicroPolygon(poly); ASSERT_EQUAL_FLOAT(poly.a.getX(), 206.699, 0.1); ASSERT_EQUAL_FLOAT(poly.a.getY(), 206.699, 0.1); ASSERT_EQUAL_FLOAT(poly.b.getX(), 293.301, 0.1); ASSERT_EQUAL_FLOAT(poly.b.getY(), 206.699, 0.1); ASSERT_EQUAL_FLOAT(poly.c.getX(), 206.699, 0.1); ASSERT_EQUAL_FLOAT(poly.c.getY(), 293.301, 0.1); ASSERT_EQUAL_FLOAT(poly.d.getX(), 293.301, 0.1); ASSERT_EQUAL_FLOAT(poly.d.getY(), 293.301, 0.1); }
void can_project_mesh_point() { FrameBuffer fb(500, 500); MeshPoint mp(0, 0, 100); fb.projectAndScalePoint(mp); ASSERT_EQUAL_FLOAT(mp.getX(), 250, 0.1); ASSERT_EQUAL_FLOAT(mp.getY(), 250, 0.1); MeshPoint mp2(-10, -10, 100); fb.projectAndScalePoint(mp2); ASSERT_EQUAL_FLOAT(mp2.getX(), 206.699, 0.1); ASSERT_EQUAL_FLOAT(mp2.getY(), 206.699, 0.1); }
/** * Test the initialisation function */ static void test_initPoint() { Point * p = initPoint(); ASSERT_EQUAL_FLOAT(p->x, 0); ASSERT_EQUAL_FLOAT(p->y, 0); destroyPoint(p); }