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
933c067a
Commit
933c067a
authored
3 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/physics'
# Conflicts: # src/field.c
parents
d37d8f88
a779664a
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
src/field.c
+16
-7
16 additions, 7 deletions
src/field.c
src/field.h
+4
-5
4 additions, 5 deletions
src/field.h
with
20 additions
and
12 deletions
src/field.c
+
16
−
7
View file @
933c067a
#include
"
field
.h"
#include
"
physics
.h"
#include
<math.h>
#include
<stdbool.h>
#include
<stdlib.h>
#include
"physics.h"
#include
"../utils/utils.h"
// Compute E*qP/norm(qP)
// Return false if norm(qP) < eps
bool
compute_e
(
charge_t
c
,
vec2
p
,
double
eps
,
vec2
*
e
){
return
EXIT_SUCCESS
;
/// qP = vectoriel(P-q)
/// Compute the vector value of the field generated by a charge at a given point in space.
bool
compute_e
(
charge_t
c
,
vec2
p
,
double
eps
,
vec2
*
e
)
{
vec2
relative_position
=
vec2_sub
(
p
,
c
.
pos
);
if
(
vec2_norm
(
relative_position
)
<
eps
)
return
false
;
double
field
=
K
*
c
.
q
/
vec2_norm_sqr
(
relative_position
);
*
e
=
vec2_mul
(
field
,
vec2_normalize
(
relative_position
));
return
true
;
}
// Compute the normalized sum of Ei*qiP/norm(qiP)
...
...
@@ -19,13 +29,12 @@ bool compute_total_normalized_e(charge_t *charges, int num_charges, vec2 p, doub
// starting from pos0.
// 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
){
return
EXIT_SUCCESS
;
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
)
{
return
EXIT_SUCCESS
;
}
// Draw all the charges
// A circle with minus sign for negative charges
// A circle with a plus sign for positive charges
static
void
draw_charges
(
struct
gfx_context_t
*
context
,
charge_t
*
charges
,
int
num_charges
,
double
x0
,
double
x1
,
double
y0
,
double
y1
){
static
void
draw_charges
(
struct
gfx_context_t
*
context
,
charge_t
*
charges
,
int
num_charges
,
double
x0
,
double
x1
,
double
y0
,
double
y1
)
{
}
This diff is collapsed.
Click to expand it.
src/field.h
+
4
−
5
View file @
933c067a
...
...
@@ -5,11 +5,10 @@
#include
"../utils/utils.h"
#include
<stdio.h>
typedef
struct
charge_t
{
double
q
;
vec2
pos
;
}
charge
;
typedef
struct
_charge_t
{
double
q
;
vec2
pos
;
}
charge_t
;
// Compute E*qP/norm(qP)
// Return false if norm(qP) < eps
...
...
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