int main() { int Error = 0; Error += test_translate(); Error += test_scale(); Error += test_rotate(); return Error; }
int main(int argc, char **argv) { gint tests_run = 0; gint tests_passed = 0; gint tests_failed = 0; gdouble scale_list[] = {5.0, 2.5, 2.0, 1.5, 1.0, 0.9, 0.5, 0.3, 0.1, 0.09, 0.05, 0.03}; gint x_list[] = {-16, 0, 15}; gint i, j, k; gegl_init(0, NULL); g_object_set(G_OBJECT(gegl_config()), "swap", "RAM", "use-opencl", FALSE, NULL); printf ("testing scaled blit\n"); for (i = 0; i < sizeof(x_list) / sizeof(x_list[0]); ++i) { for (j = 0; j < sizeof(scale_list) / sizeof(scale_list[0]); ++j) { const Babl *format_list[] = {babl_format ("RGBA u8"), babl_format ("RGBA u16")}; for (k = 0; k < sizeof(format_list) / sizeof(format_list[0]); ++k) { if (test_scale (scale_list[j], x_list[i], 0, format_list[k])) tests_passed++; else tests_failed++; tests_run++; } } } gegl_exit(); printf ("\n"); if (tests_passed == tests_run) return 0; return -1; return 0; }
static void TestMatrix44(skiatest::Reporter* reporter) { SkMatrix44 mat, inverse, iden1, iden2, rot; mat.reset(); mat.setTranslate(1, 1, 1); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(2, 2, 2); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(SK_MScalar1/2, SK_MScalar1/2, SK_MScalar1/2); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(3, 3, 3); rot.setRotateDegreesAbout(0, 0, -1, 90); mat.postConcat(rot); REPORTER_ASSERT(reporter, mat.invert(NULL)); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); iden2.setConcat(inverse, mat); REPORTER_ASSERT(reporter, is_identity(iden2)); // test rol/col Major getters { mat.setTranslate(2, 3, 4); float dataf[16]; double datad[16]; mat.asColMajorf(dataf); assert16<float>(reporter, dataf, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1); mat.asColMajord(datad); assert16<double>(reporter, datad, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1); mat.asRowMajorf(dataf); assert16<float>(reporter, dataf, 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1); mat.asRowMajord(datad); assert16<double>(reporter, datad, 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1); } test_concat(reporter); if (false) { // avoid bit rot, suppress warning (working on making this pass) test_common_angles(reporter); } test_constructor(reporter); test_gettype(reporter); test_determinant(reporter); test_transpose(reporter); test_get_set_double(reporter); test_set_row_col_major(reporter); test_translate(reporter); test_scale(reporter); test_map2(reporter); }
DEF_TEST(Matrix44, reporter) { SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); SkMatrix44 inverse(SkMatrix44::kUninitialized_Constructor); SkMatrix44 iden1(SkMatrix44::kUninitialized_Constructor); SkMatrix44 iden2(SkMatrix44::kUninitialized_Constructor); SkMatrix44 rot(SkMatrix44::kUninitialized_Constructor); mat.setTranslate(1, 1, 1); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(2, 2, 2); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(SK_MScalar1/2, SK_MScalar1/2, SK_MScalar1/2); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); mat.setScale(3, 3, 3); rot.setRotateDegreesAbout(0, 0, -1, 90); mat.postConcat(rot); REPORTER_ASSERT(reporter, mat.invert(NULL)); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); iden2.setConcat(inverse, mat); REPORTER_ASSERT(reporter, is_identity(iden2)); // test tiny-valued matrix inverse mat.reset(); auto v = SkDoubleToMScalar(1.0e-12); mat.setScale(v,v,v); rot.setRotateDegreesAbout(0, 0, -1, 90); mat.postConcat(rot); mat.postTranslate(v,v,v); REPORTER_ASSERT(reporter, mat.invert(NULL)); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); // test mixed-valued matrix inverse mat.reset(); mat.setScale(SkDoubleToMScalar(1.0e-2), SkDoubleToMScalar(3.0), SkDoubleToMScalar(1.0e+2)); rot.setRotateDegreesAbout(0, 0, -1, 90); mat.postConcat(rot); mat.postTranslate(SkDoubleToMScalar(1.0e+2), SkDoubleToMScalar(3.0), SkDoubleToMScalar(1.0e-2)); REPORTER_ASSERT(reporter, mat.invert(NULL)); mat.invert(&inverse); iden1.setConcat(mat, inverse); REPORTER_ASSERT(reporter, is_identity(iden1)); // test degenerate matrix mat.reset(); mat.set3x3(1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0); REPORTER_ASSERT(reporter, !mat.invert(NULL)); // test rol/col Major getters { mat.setTranslate(2, 3, 4); float dataf[16]; double datad[16]; mat.asColMajorf(dataf); assert16<float>(reporter, dataf, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1); mat.asColMajord(datad); assert16<double>(reporter, datad, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1); mat.asRowMajorf(dataf); assert16<float>(reporter, dataf, 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1); mat.asRowMajord(datad); assert16<double>(reporter, datad, 1, 0, 0, 2, 0, 1, 0, 3, 0, 0, 1, 4, 0, 0, 0, 1); } test_concat(reporter); if (false) { // avoid bit rot, suppress warning (working on making this pass) test_common_angles(reporter); } test_constructor(reporter); test_gettype(reporter); test_determinant(reporter); test_invert(reporter); test_transpose(reporter); test_get_set_double(reporter); test_set_row_col_major(reporter); test_translate(reporter); test_scale(reporter); test_map2(reporter); test_3x3_conversion(reporter); test_has_perspective(reporter); test_preserves_2d_axis_alignment(reporter); test_toint(reporter); }
void draw_default_fixed_cockpit_clock_hands (cockpit_panels panel) { float hour_hand_value, minute_hand_value, second_hand_value, x_centre, y_centre; scale_data *hour_hand_scale, *minute_hand_scale, *second_hand_scale, *p; if (draw_virtual_cockpit_needles_on_fixed_cockpits) { return; } get_clock_hand_values (&hour_hand_value, &minute_hand_value, &second_hand_value); switch (panel) { //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_AHEAD: //////////////////////////////////////// { x_centre = 45.0; y_centre = 388.0; hour_hand_scale = clock_small_hand_scale_down_20_ahead; minute_hand_scale = clock_large_hand_scale_down_20_ahead; second_hand_scale = clock_large_hand_scale_down_20_ahead; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_LEFT30: //////////////////////////////////////// { x_centre = 317.0; y_centre = 349.0; hour_hand_scale = clock_small_hand_scale_down_20_left_30; minute_hand_scale = clock_large_hand_scale_down_20_left_30; second_hand_scale = clock_large_hand_scale_down_20_left_30; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_LEFT60: //////////////////////////////////////// { x_centre = 589.0; y_centre = 386.0; hour_hand_scale = clock_small_hand_scale_down_20_left_60; minute_hand_scale = clock_large_hand_scale_down_20_left_60; second_hand_scale = clock_large_hand_scale_down_20_left_60; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal (instrument_error); break; } } // // draw second hand over minute hand over hour hand // p = find_scale_value (hour_hand_scale, hour_hand_value); draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour); p = find_scale_value (minute_hand_scale, minute_hand_value); draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour); p = find_scale_value (second_hand_scale, second_hand_value); draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, red_needle_colour); if (test_cockpit_instruments && DEBUG_MODULE) { test_scale (minute_hand_scale, 0.0, 55.0, 5.0); test_scale (hour_hand_scale, 0.0, 11.0, 1.0); set_pixel (ix_640_480 + x_centre, iy_640_480 + y_centre, sys_col_red); } }
void draw_default_fixed_cockpit_barometric_altimeter_needle (cockpit_panels panel) { float altimeter_needle_value, x_centre, y_centre; scale_data *altimeter_needle_scale, *p; if (draw_virtual_cockpit_needles_on_fixed_cockpits) { return; } altimeter_needle_value = get_barometric_altimeter_needle_value (); switch (panel) { //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_AHEAD: //////////////////////////////////////// { x_centre = 599.0; y_centre = 440.0; altimeter_needle_scale = barometric_altimeter_needle_scale_down_20_ahead; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_RIGHT30: //////////////////////////////////////// { x_centre = 333.0; y_centre = 393.0; altimeter_needle_scale = barometric_altimeter_needle_scale_down_20_right_30; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_RIGHT60: //////////////////////////////////////// { x_centre = 73.0; y_centre = 430.0; altimeter_needle_scale = barometric_altimeter_needle_scale_down_20_right_60; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal (instrument_error); break; } } p = find_scale_value (altimeter_needle_scale, altimeter_needle_value); draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour); if (test_cockpit_instruments && DEBUG_MODULE) { test_scale (altimeter_needle_scale, 0.0, 900.0, 100.0); set_pixel (ix_640_480 + x_centre, iy_640_480 + y_centre, sys_col_red); } }
void draw_ah64a_fixed_cockpit_airspeed_indicator_needle (cockpit_panels panel) { float airspeed_needle_value, x_centre, y_centre; scale_data *airspeed_needle_scale, *p; if (draw_virtual_cockpit_needles_on_fixed_cockpits) { return; } airspeed_needle_value = get_airspeed_indicator_needle_value (); switch (panel) { //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_AHEAD: //////////////////////////////////////// { x_centre = 533.0; y_centre = 440.0; airspeed_needle_scale = airspeed_indicator_needle_scale_down_20_ahead; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_RIGHT30: //////////////////////////////////////// { x_centre = 281.0; y_centre = 411.0; airspeed_needle_scale = airspeed_indicator_needle_scale_down_20_right_30; break; } //////////////////////////////////////// case COCKPIT_PANEL_DOWN20_RIGHT60: //////////////////////////////////////// { x_centre = 12.0; y_centre = 471.0; airspeed_needle_scale = airspeed_indicator_needle_scale_down_20_right_60; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal (instrument_error); break; } } p = find_scale_value (airspeed_needle_scale, airspeed_needle_value); draw_line (fx_640_480 + x_centre, fy_640_480 + y_centre, fx_640_480 + p->x, fy_640_480 + p->y, white_needle_colour); if (test_cockpit_instruments && DEBUG_MODULE) { test_scale (airspeed_needle_scale, 0.0, 250.0, 50.0); set_pixel (ix_640_480 + x_centre, iy_640_480 + y_centre, sys_col_red); } }