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
d7b34e78
Commit
d7b34e78
authored
2 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
save
parent
5d3d4b0b
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
Makefile
+3
-0
3 additions, 0 deletions
Makefile
src/field.c
+4
-5
4 additions, 5 deletions
src/field.c
with
7 additions
and
5 deletions
Makefile
+
3
−
0
View file @
d7b34e78
...
...
@@ -7,6 +7,9 @@ TESTS:= draw_tests field_tests
all
:
main
exec
:
main
./main
main
:
main.o $(OBJFILES)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$(
LDFLAGS
)
-lSDL2
...
...
This diff is collapsed.
Click to expand it.
src/field.c
+
4
−
5
View file @
d7b34e78
...
...
@@ -41,11 +41,7 @@ bool is_in_screen(coordinates_t pos) {
bool
draw_field_line_point
(
struct
gfx_context_t
*
ctxt
,
charge_t
*
charges
,
int
num_charges
,
double
x0
,
double
x1
,
double
y0
,
double
y1
,
vec2
pos
,
vec2
*
pos_next
,
double
delta
)
{
vec2
e
;
compute_total_normalized_e
(
charges
,
num_charges
,
pos
,
0
.
01
,
&
e
);
double
norm_e
=
vec2_norm
(
e
);
// TODO: "Problème ici" ?
pos_next
->
x
=
pos
.
x
+
delta
*
(
e
.
x
/
norm_e
);
pos_next
->
y
=
pos
.
y
+
delta
*
(
e
.
y
/
norm_e
);
*
pos_next
=
vec2_add
(
pos
,
vec2_mul
(
delta
,
vec2_normalize
(
e
)));
if
(
pos_next
->
x
<=
0
||
pos_next
->
x
>=
1
||
pos_next
->
y
<=
0
||
pos_next
->
y
>=
1
)
return
false
;
...
...
@@ -61,6 +57,7 @@ bool draw_field_line_point(struct gfx_context_t *ctxt, charge_t *charges, int nu
return
!
is_in_screen
(
coordinate_pos
);
}
bool
line_reach_charge
(
vec2
pos
,
charge_t
*
charges
,
int
num_charges
,
double
dx
)
{
for
(
int
j
=
0
;
j
<
num_charges
;
++
j
)
{
if
(
vec2_norm
(
vec2_sub
(
pos
,
charges
[
j
].
pos
))
<
dx
/
HEI
)
{
...
...
@@ -103,6 +100,7 @@ static bool draw_field_line(struct gfx_context_t *ctxt, charge_t *charges, int n
return
!
stop_positive
||
!
stop_negative
;
}
/// Draw all the charges
/// A circle with minus sign for negative charges
/// A circle with a plus sign for positive charges
...
...
@@ -129,6 +127,7 @@ static void draw_charges(struct gfx_context_t *context, charge_t *charges, int n
}
}
void
draw_everything
(
struct
gfx_context_t
*
ctxt
,
charge_t
*
charges
,
...
...
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