Skip to content
Snippets Groups Projects
Commit 26e9c0f9 authored by tanguy.cavagna's avatar tanguy.cavagna :desktop:
Browse files

Depedency of draw

parent d05ad22f
No related branches found
No related tags found
No related merge requests found
utils.c 0 → 100644
#include <math.h>
#include <stdlib.h>
#include "vector/vector.h"
#include "utils.h"
coordinates_t coordinates_create(int row_, int column_)
{
coordinates_t c = {.row = row_, .column = column_};
return c;
}
// Transform a position in the univers [x0,y0]x[x1,y1] to a screen position
coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos)
{
double dx = x1 - x0;
double dy = y1 - y0;
return coordinates_create((int)round(height * (pos.y - y0) / dy), (int)round(width * (pos.x - x0) / dx));
}
double rand_one()
{
return (double)rand() / (double)RAND_MAX;
}
charge_t charge_create(double q, vector pos)
{
charge_t c = {.q = q, .pos = pos};
return c;
}
\ No newline at end of file
utils.h 0 → 100644
#ifndef _UTILS_H_
#define _UTILS_H_
#define K 8.988e9;
#define E 1.602e-19;
#include <stdint.h>
#include "vector/vector.h"
typedef struct
{
uint32_t row;
uint32_t column;
} coordinates_t;
typedef struct
{
double q;
vector pos;
} charge_t;
coordinates_t coordinates_create(int row_, int column_);
// Transform a position in the univers [x0,y0]x[x1,y1] to a screen position
coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos);
double rand_one();
charge_t charge_create(double q, vector pos);
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment