al_calculate_arc(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

hey bestie πŸ’– welcome to the group chat for al_calculate_arc(3) β€” this is the Allegro 5 API page from the Allegro reference manual, and we’re gonna make arc math make sense, fr fr ✨

🌸 NAME 🌸

al_calculate_arc β€” Allegro 5 API πŸ’…

✨ SYNOPSIS ✨

#include <allegro5/allegro_primitives.h>

void al_calculate_arc(float* dest, int stride, float cx, float cy,
   float rx, float ry, float start_theta, float delta_theta, float thickness,
   int num_points)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so listen πŸ‘‘ when thickness <= 0, this function computes positions of num_points regularly spaced points on an elliptical arc. lowkey iconic.

When thickness > 0, this function computes two sets of points, obtained as follows: the first set is obtained by taking the points computed in the thickness <= 0 case and shifting them by thickness / 2 outward, in a direction perpendicular to the arc curve. The second set is the same, but shifted thickness / 2 inward relative to the arc. The two sets of points are interleaved in the destination buffer (i.e. the first pair of points will be collinear with the arc center, the first point of the pair will be farther from the center than the second point; the next pair will also be collinear, but at a different angle and so on). periodt πŸ’«

The destination buffer dest is interpreted as a set of regularly spaced pairs of floats, each pair holding the coordinates of the corresponding point on the arc. The two floats in the pair are adjacent, and the distance (in bytes) between the addresses of the first float in two successive pairs is stride. For example, if you have a tightly packed array of floats with no spaces between pairs, then stride will be exactly 2 * sizeof(float). no cap 🫢

Example with thickness <= 0:

const int num_points = 4;
float points[num_points][2];
al_calculate_arc(&points[0][0], 2 * sizeof(float), 0, 0, 10, 10, 0, ALLEGRO_PI / 2, 0, num_points);

assert((int)points[0][0] == 10);
assert((int)points[0][1] == 0);

assert((int)points[num_points - 1][0] == 0);
assert((int)points[num_points - 1][1] == 10);

Example with thickness > 0:

const int num_points = 4;
float points[num_points * 2][2];
al_calculate_arc(&points[0][0], 2 * sizeof(float), 0, 0, 10, 10, 0, ALLEGRO_PI / 2, 2, num_points);

assert((int)points[0][0] == 11);
assert((int)points[0][1] == 0);
assert((int)points[1][0] == 9);
assert((int)points[1][1] == 0);

assert((int)points[(num_points - 1) * 2][0] == 0);
assert((int)points[(num_points - 1) * 2][1] == 11);
assert((int)points[(num_points - 1) * 2 + 1][0] == 0);
assert((int)points[(num_points - 1) * 2 + 1][1] == 9);

🫢 Parameters 🫢

  • dest β€” the destination buffer.
  • stride β€” distance (in bytes) between starts of successive pairs of points.
  • cx, cy β€” center of the arc.
  • rx, ry β€” radii of the arc.
  • start_theta β€” the initial angle from which the arc is calculated, in radians.
  • delta_theta β€” angular span of the arc in radians (pass a negative number to switch direction).
  • thickness β€” thickness of the arc.
  • num_points β€” the number of points to calculate.

🌈 SEE ALSO 🌈


that’s the whole page, signed off by the Allegro reference manual for al_calculate_arc(3) in the Allegro 5 API β€” no date listed on this cutie, so consider this your sparkly timestamp πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms