Расстановка точек на окружности
This commit is contained in:
@@ -41,6 +41,26 @@ static void signal_thread_exit(struct window_thread_slot *slot)
|
||||
pthread_mutex_unlock(&g_thread_lock);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Прототип ASM-функции
|
||||
void place_points_on_circle(
|
||||
float pos_x,
|
||||
float pos_y,
|
||||
float offset_rad,
|
||||
float radius,
|
||||
float *points,
|
||||
size_t count);
|
||||
|
||||
struct Point
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
static void *window_aux_loop(void *arg)
|
||||
{
|
||||
struct window_thread_slot *slot = arg;
|
||||
@@ -49,7 +69,36 @@ static void *window_aux_loop(void *arg)
|
||||
{
|
||||
/* На время обновления позиции фигуры локаем мутекс */
|
||||
pthread_mutex_lock(&draw_info->figure_mutex);
|
||||
figure_animation_step(draw_info);
|
||||
// figure_animation_step(draw_info);
|
||||
|
||||
const size_t n = 8;
|
||||
struct vec2 *pts = malloc(sizeof(struct vec2) * n);
|
||||
if (!pts)
|
||||
{
|
||||
printf("malloc failed\n");
|
||||
}
|
||||
|
||||
float center_x = 0.0f;
|
||||
float center_y = 0.0f;
|
||||
float offset = 0.78f;
|
||||
float radius = 1.0f;
|
||||
|
||||
// Вызов ASM-функции
|
||||
place_points_on_circle(
|
||||
center_x,
|
||||
center_y,
|
||||
offset,
|
||||
radius,
|
||||
(float *)pts, // адрес выходного массива
|
||||
n);
|
||||
|
||||
// Вывод для проверки (и удобной точки останова)
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
printf("%zu: x = %f, y = %f\n", i, pts[i].x, pts[i].y);
|
||||
}
|
||||
|
||||
free(pts);
|
||||
pthread_mutex_unlock(&draw_info->figure_mutex);
|
||||
|
||||
usleep(30 * 1000);
|
||||
|
||||
Reference in New Issue
Block a user