6 #include "storage/individual.h"
7 #include "storage/family.h"
11 #define FAMILY_AVAIL_RANGE 180
13 struct position * calculate_individual_position(struct familia_individual * individual)
15 struct position * pos = NULL;
16 struct familia_family * parents = NULL;
17 unsigned int children_no = 1;
20 parents = familia_individual_get_parents(individual);
21 if (parents == NULL) {
22 debug("TODO: Calculate position for root individual.");
26 nth = familia_individual_nth_child_of_family(individual, parents);
28 debug("Cannot calculate child number.");
32 children_no = parents->children_no;
34 if (children_no == 0) {
35 debug("Children number mismatch: I have child of family, " \
36 "but parents does not have any children!");
40 pos = (struct position *)malloc(sizeof(struct position));
45 /* If there is only one child in family, place it vertically
46 * over the family (do not change x and z). For all other
47 * calculate these positions.
49 if (children_no != 1) {
50 /* Angle by which every child is rotated. */
52 /* Angle by which this child will be rotated */
54 theta = FAMILY_AVAIL_RANGE / children_no;
56 /* We subtract from FAMILY_AVAIL_RANGE (e.g. 180),
57 * to count angle from left instead of from right.
58 * This makes oldest children display in this order.
60 alpha = FAMILY_AVAIL_RANGE - theta * nth;
66 /* pos.y is a local coordinate now. */
67 pos->y = convert_date_to_height(NULL);
72 struct position * calculate_family_position(struct familia_family * family)
74 /* TODO: Implement this function*/