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
4c79ea46
Commit
4c79ea46
authored
3 years ago
by
tanguy.cavagna
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused stuff
parent
7aaf3676
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
charge/charge.c
+1
-12
1 addition, 12 deletions
charge/charge.c
with
1 addition
and
12 deletions
charge/charge.c
+
1
−
12
View file @
4c79ea46
...
...
@@ -75,10 +75,7 @@ double random_charge_q(bool positive) {
return
(
rand
()
%
100
)
*
(
positive
?
1
:
-
1
);
}
int
sign
(
double
a
)
{
return
(
a
<
0
)
?
-
1
:
1
;
}
vec2
electristatic_force
(
charge_t
a
,
charge_t
b
)
{
bool
attractive
=
sign
(
a
.
q
)
!=
sign
(
b
.
q
);
vec2
rab
=
vec2_sub
(
b
.
pos
,
a
.
pos
);
vec2
res
=
vec2_mul
(
rab
,
-
K
*
(((
a
.
q
*
10e-6
)
*
(
b
.
q
*
10e-6
))
/
pow
(
vec2_norm
(
rab
),
2
)));
...
...
@@ -101,22 +98,14 @@ vec2 resulting_electrostatic_force(charge_t *charges, int num_charges,
return
resulting
;
}
vec2
compute_initial_vecocity
(
charge_t
c
,
charge_t
*
charges
,
int
num_charges
)
{
double
norm
=
0
;
double
angle
=
rand
()
%
360
;
return
vec2_create
(
norm
*
cos
(
angle
),
norm
*
sin
(
angle
));
}
vec2
compute_acceleration
(
charge_t
c
,
charge_t
*
charges
,
int
num_charges
)
{
return
vec2_mul
(
resulting_electrostatic_force
(
charges
,
num_charges
,
c
),
1
.
0
/
CHARGE_MASS
);
}
vec2
compute_first_pos
(
charge_t
c
,
charge_t
*
charges
,
int
num_charges
)
{
vec2
velocity
=
compute_initial_vecocity
(
c
,
charges
,
num_charges
);
vec2
a
=
compute_acceleration
(
c
,
charges
,
num_charges
);
vec2
pos
=
vec2_add
(
vec2_add
(
c
.
pos
,
vec2_mul
(
velocity
,
DELTA_T
)),
vec2_mul
(
a
,
pow
(
DELTA_T
,
2
)
/
2
));
vec2
pos
=
vec2_add
(
c
.
pos
,
vec2_mul
(
a
,
pow
(
DELTA_T
,
2
)
/
2
));
return
pos
;
}
...
...
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