Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
electric-field
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
repos.tanguy.cavagna
physics
electric-field
Commits
26e9c0f9
Commit
26e9c0f9
authored
3 years ago
by
tanguy.cavagna
Browse files
Options
Downloads
Patches
Plain Diff
Depedency of draw
parent
d05ad22f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
utils.c
+29
-0
29 additions, 0 deletions
utils.c
utils.h
+31
-0
31 additions, 0 deletions
utils.h
with
60 additions
and
0 deletions
utils.c
0 → 100644
+
29
−
0
View file @
26e9c0f9
#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
This diff is collapsed.
Click to expand it.
utils.h
0 → 100644
+
31
−
0
View file @
26e9c0f9
#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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment