Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phys_tp_elec
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
boris.stefanov
phys_tp_elec
Commits
63bee7c6
Commit
63bee7c6
authored
2 years ago
by
JM
Browse files
Options
Downloads
Patches
Plain Diff
Modification génération ligne
parent
ced5490b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/field.c
+25
-5
25 additions, 5 deletions
src/field.c
src/main.c
+0
-1
0 additions, 1 deletion
src/main.c
with
25 additions
and
6 deletions
src/field.c
+
25
−
5
View file @
63bee7c6
...
...
@@ -9,7 +9,6 @@
#define SIGN_SIZE 10
#define CHARGE_R 25
// Compute E*qP/norm(qP)
// Return false if norm(qP) < eps
/// qP = vectoriel(P-q)
...
...
@@ -35,6 +34,11 @@ bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, doub
return
true
;
}
double
compute_delta_x
(){
double
result
=
pow
(
WID
,
2
)
+
pow
(
HEI
,
2
);
result
=
sqrt
(
result
);
return
1
/
result
;
}
// Compute and then draw all the points belonging to a field line,
// starting from pos0.
...
...
@@ -43,12 +47,27 @@ bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, doub
static
bool
draw_field_line
(
struct
gfx_context_t
*
ctxt
,
charge_t
*
charges
,
int
num_charges
,
double
dx
,
vec2
pos0
,
double
x0
,
double
x1
,
double
y0
,
double
y1
)
{
vec2
pos
=
vec2_create
(
pos0
.
x
,
pos0
.
y
);
vec2
pos_sum
;
for
(
int
i
=
0
;
i
<
num_charges
;
i
++
)
vec2
pos_next
;
vec2
e
;
double
delta
=
compute_delta_x
();
// Remplacer par une boucle qui s'arrête lorsqu'on atteint une charge
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
//compute_e(charges[i], ..., &pos_sum);
compute_total_normalized_e
(
charges
,
num_charges
,
pos
,
0
.
01
,
&
e
);
pos_next
.
x
=
pos
.
x
+
delta
*
(
e
.
x
/
vec2_normalize
(
e
).
x
);
pos_next
.
y
=
pos
.
y
+
delta
*
(
e
.
y
/
vec2_normalize
(
e
).
y
);
//printf("%f + %f * (%f / %f)\n", pos.x, delta, e.x, vec2_normalize(e).x);
//printf("%f %f\n", pos_next.x, pos_next.y);
coordinates_t
coordinate_pos
=
position_to_coordinates
(
WID
,
HEI
,
x0
,
x1
,
y0
,
y1
,
pos
);
coordinates_t
coordinate_pos_next
=
position_to_coordinates
(
WID
,
HEI
,
x0
,
x1
,
y0
,
y1
,
pos_next
);
//printf("%d %d\n", charge_1.column, charge_1.row);
//printf("%d %d\n\n", charge_2.column, charge_2.row);
gfx_draw_line
(
ctxt
,
coordinate_pos
,
coordinate_pos_next
,
COLOR_YELLOW
);
pos
=
pos_next
;
}
//vec2 pos_next =
return
EXIT_SUCCESS
;
}
...
...
@@ -87,9 +106,10 @@ void draw_everything(
double
dx
,
double
x0
,
double
x1
,
double
y0
,
double
y1
)
{
srand
(
time
(
NULL
));
draw_charges
(
ctxt
,
charges
,
num_charges
,
x0
,
x1
,
y0
,
y1
);
for
(
int
i
=
0
;
i
<
num_lines
;
++
i
)
{
vec2
pos0
=
vec2_
normalize
(
vec2_create
(
rand
(),
rand
())
);
vec2
pos0
=
vec2_
create
((
double
)
rand
()
/
RAND_MAX
,
(
double
)
rand
()
/
RAND_MAX
);
draw_field_line
(
ctxt
,
charges
,
num_charges
,
dx
,
pos0
,
x0
,
x1
,
y0
,
y1
);
}
}
This diff is collapsed.
Click to expand it.
src/main.c
+
0
−
1
View file @
63bee7c6
...
...
@@ -12,7 +12,6 @@
int
main
()
{
srand
(
time
(
NULL
));
charge_t
charges
[
NCHARGES
]
=
{
{.
q
=-
0
.
25
,
.
pos
=
vec2_create
(
0
.
25
,
0
.
5
)},
{.
q
=
0
.
25
,
.
pos
=
vec2_create
(
0
.
75
,
0
.
5
)},
...
...
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