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
36a4455e
Commit
36a4455e
authored
2 years ago
by
JM
Browse files
Options
Downloads
Patches
Plain Diff
Optimisation draw_field_line
parent
a881dd4a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/field.c
+11
-18
11 additions, 18 deletions
src/field.c
with
11 additions
and
18 deletions
src/field.c
+
11
−
18
View file @
36a4455e
...
...
@@ -80,33 +80,26 @@ bool line_reach_charge(vec2 pos, charge_t * charges, double num_charges, double
// Returns false if pos0 is not a valid position
// (for example if pos0 is too close to a charge).
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_next
;
vec2
pos_positive
=
vec2_create
(
pos0
.
x
,
pos0
.
y
);
vec2
pos_negative
=
vec2_create
(
pos0
.
x
,
pos0
.
y
);
vec2
pos_next_positive
;
vec2
pos_next_negative
;
bool
stop
=
false
;
// * 5 à supprimer lorsque le code est optimisé
double
delta
=
compute_delta_x
()
*
5
;
int
max_for
=
50
;
for
(
int
i
=
0
;
i
<
max_for
&&
!
stop
;
i
++
)
{
stop
=
line_reach_charge
(
pos
,
charges
,
num_charges
,
dx
);
if
(
!
stop
){
stop
=
draw_field_line_point
(
ctxt
,
charges
,
num_charges
,
x0
,
x1
,
y0
,
y1
,
pos
,
&
pos_next
,
-
delta
);
pos
=
pos_next
;
}
}
pos
=
vec2_create
(
pos0
.
x
,
pos0
.
y
);
stop
=
false
;
for
(
int
i
=
0
;
i
<
max_for
&&
!
stop
;
i
++
)
{
stop
=
line_reach_charge
(
pos
,
charges
,
num_charges
,
dx
);
stop
=
line_reach_charge
(
pos_positive
,
charges
,
num_charges
,
dx
)
||
line_reach_charge
(
pos_negative
,
charges
,
num_charges
,
dx
);
if
(
!
stop
){
stop
=
draw_field_line_point
(
ctxt
,
charges
,
num_charges
,
x0
,
x1
,
y0
,
y1
,
pos
,
&
pos_next
,
delta
);
pos
=
pos_next
;
stop
=
draw_field_line_point
(
ctxt
,
charges
,
num_charges
,
x0
,
x1
,
y0
,
y1
,
pos_positive
,
&
pos_next_positive
,
delta
)
||
draw_field_line_point
(
ctxt
,
charges
,
num_charges
,
x0
,
x1
,
y0
,
y1
,
pos_negative
,
&
pos_next_negative
,
-
delta
);
pos_positive
=
pos_next_positive
;
pos_negative
=
pos_next_negative
;
}
}
return
EXIT_SUCCESS
;
return
!
stop
;
}
// Draw all the 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