1al_calculate_arc(3)                                        al_calculate_arc(3)
2
3
4

NAME

6       al_calculate_arc - Allegro 5 API
7

SYNOPSIS

9              #include <allegro5/allegro_primitives.h>
10
11              void al_calculate_arc(float* dest, int stride, float cx, float cy,
12                 float rx, float ry, float start_theta, float delta_theta, float thickness,
13                 int num_points)
14

DESCRIPTION

16       When thickness <= 0 this function computes positions of num_points reg‐
17       ularly spaced points on an elliptical  arc.   When  thickness > 0  this
18       function  computes  two  sets of points, obtained as follows: the first
19       set is obtained by taking the points  computed  in  the  thickness <= 0
20       case and shifting them by thickness / 2 outward, in a direction perpen‐
21       dicular to the arc curve.  The second set  is  the  same,  but  shifted
22       thickness / 2  inward  relative to the arc.  The two sets of points are
23       interleaved in the destination buffer (i.e.  the first pair  of  points
24       will be collinear with the arc center, the first point of the pair will
25       be farther from the center than the second point; the  next  pair  will
26       also be collinear, but at a different angle and so on).
27
28       The destination buffer dest is interpreted as a set of regularly spaced
29       pairs of floats, each pair holding the coordinates of the corresponding
30       point  on  the  arc.   The two floats in the pair are adjacent, and the
31       distance (in bytes) between the addresses of the  first  float  in  two
32       successive  pairs is stride.  For example, if you have a tightly packed
33       array of floats with no spaces  between  pairs,  then  stride  will  be
34       exactly 2 * sizeof(float).
35
36       Example with thickness <= 0:
37
38              const int num_points = 4;
39              float points[num_points][2];
40              al_calculate_arc(&points[0][0], 2 * sizeof(float), 0, 0, 10, 10, 0, ALLEGRO_PI / 2, 0, num_points);
41
42              assert((int)points[0][0] == 10);
43              assert((int)points[0][1] == 0);
44
45              assert((int)points[num_points - 1][0] == 0);
46              assert((int)points[num_points - 1][1] == 10);
47
48       Example with thickness > 0:
49
50              const int num_points = 4;
51              float points[num_points * 2][2];
52              al_calculate_arc(&points[0][0], 2 * sizeof(float), 0, 0, 10, 10, 0, ALLEGRO_PI / 2, 2, num_points);
53
54              assert((int)points[0][0] == 11);
55              assert((int)points[0][1] == 0);
56              assert((int)points[1][0] == 9);
57              assert((int)points[1][1] == 0);
58
59              assert((int)points[(num_points - 1) * 2][0] == 0);
60              assert((int)points[(num_points - 1) * 2][1] == 11);
61              assert((int)points[(num_points - 1) * 2 + 1][0] == 0);
62              assert((int)points[(num_points - 1) * 2 + 1][1] == 9);
63
64       Parameters:
65
66       · dest - The destination buffer
67
68       · stride  -  Distance  (in bytes) between starts of successive pairs of
69         points
70
71       · cx, cy - Center of the arc
72
73       · rx, ry - Radii of the arc
74
75       · start_theta - The initial angle from which the arc is  calculated  in
76         radians
77
78       · delta_theta  -  Angular  span  of the arc in radians (pass a negative
79         number to switch direction)
80
81       · thickness - Thickness of the arc
82
83       · num_points - The number of points to calculate
84

SEE ALSO

86       al_draw_arc(3), al_calculate_spline(3), al_calculate_ribbon(3)
87
88
89
90Allegro reference manual                                   al_calculate_arc(3)
Impressum