Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3], SPGCONST int rotations[][3][3], const int num_rotations) { int i, j, pg_num; int axes[3]; PointSymmetry pointsym; Pointgroup pointgroup; debug_print("ptg_get_transformation_matrix:\n"); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { transform_mat[i][j] = 0; } } pg_num = get_pointgroup_number_by_rotations(rotations, num_rotations); if (pg_num > 0) { pointgroup = ptg_get_pointgroup(pg_num); pointsym = get_pointsymmetry(rotations, num_rotations); get_axes(axes, pointgroup.laue, &pointsym); set_transformation_matrix(transform_mat, axes); } else { pointgroup = ptg_get_pointgroup(0); } return pointgroup; }
static void sort_axes(int axes[3]) { int axis; int t_mat[3][3]; if (axes[1] > axes[2]) { axis = axes[1]; axes[1] = axes[2]; axes[2] = axis; } if (axes[0] > axes[1]) { axis = axes[0]; axes[0] = axes[1]; axes[1] = axis; } if (axes[1] > axes[2]) { axis = axes[1]; axes[1] = axes[2]; axes[2] = axis; } set_transformation_matrix(t_mat, axes); if (mat_get_determinant_i3(t_mat) < 0) { axis = axes[1]; axes[1] = axes[2]; axes[2] = axis; } }
static int map_output_xrandr(Display *dpy, int deviceid, const char *output_name) { int rc = EXIT_FAILURE; XRRScreenResources *res; XRROutputInfo *output_info; res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); output_info = find_output_xrandr(dpy, output_name); /* crtc holds our screen info, need to compare to actual screen size */ if (output_info) { XRRCrtcInfo *crtc_info; Matrix m; matrix_set_unity(&m); crtc_info = XRRGetCrtcInfo (dpy, res, output_info->crtc); set_transformation_matrix(dpy, &m, crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); rc = apply_matrix(dpy, deviceid, &m); XRRFreeCrtcInfo(crtc_info); XRRFreeOutputInfo(output_info); } else printf("Unable to find output '%s'. " "Output may not be connected.\n", output_name); XRRFreeScreenResources(res); return rc; }
static int laue4m(int axes[3], SPGCONST PointSymmetry * pointsym) { int i, num_ortho_axis, norm, min_norm, is_found, tmpval; int axis_vec[3]; int prop_rot[3][3], t_mat[3][3]; int ortho_axes[NUM_ROT_AXES]; for (i = 0; i < pointsym->size; i++) { get_proper_rotation(prop_rot, pointsym->rot[i]); /* Search foud-fold rotation */ if ( mat_get_trace_i3(prop_rot) == 1) { /* The first axis */ axes[2] = get_rotation_axis(prop_rot); break; } } /* The second axis */ num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, 4); if (! num_ortho_axis) { goto err; } min_norm = 8; is_found = 0; for (i = 0; i < num_ortho_axis; i++) { norm = mat_norm_squared_i3(rot_axes[ortho_axes[i]]); if (norm < min_norm) { min_norm = norm; axes[0] = ortho_axes[i]; is_found = 1; } } if (! is_found) { goto err; } /* The third axis */ mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); is_found = 0; for (i = 0; i < NUM_ROT_AXES; i++) { if (is_exist_axis(axis_vec, i)) { is_found = 1; axes[1] = i; break; } } if (! is_found) { goto err; } set_transformation_matrix(t_mat, axes); if (mat_get_determinant_i3(t_mat) < 0) { tmpval = axes[0]; axes[0] = axes[1]; axes[1] = tmpval; } return 1; err: return 0; }
static int map_output_xinerama(Display *dpy, int deviceid, const char *output_name) { const char *prefix = "HEAD-"; XineramaScreenInfo *screens = NULL; int rc = EXIT_FAILURE; int event, error; int nscreens; int head; Matrix m; if (!XineramaQueryExtension(dpy, &event, &error)) { fprintf(stderr, "Unable to set screen mapping. Xinerama extension not found\n"); goto out; } if (strlen(output_name) < strlen(prefix) + 1 || strncmp(output_name, prefix, strlen(prefix)) != 0) { fprintf(stderr, "Please specify the output name as HEAD-X," "where X is the screen number\n"); goto out; } head = output_name[strlen(prefix)] - '0'; screens = XineramaQueryScreens(dpy, &nscreens); if (nscreens == 0) { fprintf(stderr, "Xinerama failed to query screens.\n"); goto out; } else if (nscreens <= head) { fprintf(stderr, "Found %d screens, but you requested %s.\n", nscreens, output_name); goto out; } matrix_set_unity(&m); set_transformation_matrix(dpy, &m, screens[head].x_org, screens[head].y_org, screens[head].width, screens[head].height); rc = apply_matrix(dpy, deviceid, &m); out: XFree(screens); return rc; }
static int laue3m(int axes[3], SPGCONST PointSymmetry * pointsym) { int i, is_found, tmpval, axis; int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3]; int axis_vec[3]; for (i = 0; i < pointsym->size; i++) { get_proper_rotation(prop_rot, pointsym->rot[i]); /* Search three-fold rotation */ if (mat_get_trace_i3(prop_rot) == 0) { /* The first axis */ axes[2] = get_rotation_axis(prop_rot); debug_print("laue3m prop_rot\n"); debug_print_matrix_i3(prop_rot); break; } } is_found = 0; for (i = 0; i < pointsym->size; i++) { get_proper_rotation(prop_rot2, pointsym->rot[i]); /* Search two-fold rotation */ if (! (mat_get_trace_i3(prop_rot2) == -1)) { continue; } /* The second axis */ axis = get_rotation_axis(prop_rot2); if (! (axis == axes[2])) { axes[0] = axis; is_found = 1; break; } } if (! is_found) { goto err; } /* The third axis */ mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[axes[0]]); is_found = 0; for (i = 0; i < NUM_ROT_AXES; i++) { is_found = is_exist_axis(axis_vec, i); if (is_found == 1) { axes[1] = i; break; } if (is_found == -1) { axes[1] = i + NUM_ROT_AXES; break; } } if (! is_found) { goto err; } set_transformation_matrix(t_mat, axes); if (mat_get_determinant_i3(t_mat) < 0) { tmpval = axes[0]; axes[0] = axes[1]; axes[1] = tmpval; } return 1; err: return 0; }
static int laue_one_axis(int axes[3], SPGCONST PointSymmetry * pointsym, const int rot_order) { int i, j, num_ortho_axis, det, is_found, tmpval; int axis_vec[3], tmp_axes[3]; int prop_rot[3][3], t_mat[3][3]; int ortho_axes[NUM_ROT_AXES]; debug_print("laue_one_axis with rot_order %d\n", rot_order); for (i = 0; i < pointsym->size; i++) { get_proper_rotation(prop_rot, pointsym->rot[i]); /* Search foud-fold rotation */ if (rot_order == 4) { if (mat_get_trace_i3(prop_rot) == 1) { /* The first axis */ axes[2] = get_rotation_axis(prop_rot); break; } } /* Search three-fold rotation */ if (rot_order == 3) { if (mat_get_trace_i3(prop_rot) == 0) { /* The first axis */ axes[2] = get_rotation_axis(prop_rot); break; } } } /* Candidates of the second axis */ num_ortho_axis = get_orthogonal_axis(ortho_axes, prop_rot, rot_order); if (! num_ortho_axis) { goto err; } tmp_axes[1] = -1; tmp_axes[2] = axes[2]; for (i = 0; i < num_ortho_axis; i++) { is_found = 0; tmp_axes[0] = ortho_axes[i]; mat_multiply_matrix_vector_i3(axis_vec, prop_rot, rot_axes[tmp_axes[0]]); for (j = 0; j < num_ortho_axis; j++) { is_found = is_exist_axis(axis_vec, ortho_axes[j]); if (is_found == 1) { tmp_axes[1] = ortho_axes[j]; break; } if (is_found == -1) { tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES; break; } } if (!is_found) { continue; } set_transformation_matrix(t_mat, tmp_axes); det = abs(mat_get_determinant_i3(t_mat)); if (det < 4) { /* to avoid F-center choice det=4 */ axes[0] = tmp_axes[0]; axes[1] = tmp_axes[1]; goto end; } } err: /* axes are not correctly found. */ warning_print("spglib: Secondary axis is not found."); warning_print("(line %d, %s).\n", __LINE__, __FILE__); return 0; end: set_transformation_matrix(t_mat, axes); if (mat_get_determinant_i3(t_mat) < 0) { tmpval = axes[0]; axes[0] = axes[1]; axes[1] = tmpval; } debug_print("axes[0] = %d\n", axes[0]); debug_print("axes[1] = %d\n", axes[1]); debug_print("axes[2] = %d\n", axes[2]); return 1; }