Skip to content
Snippets Groups Projects
Commit 5377429f authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele und Tafelbilder 12.12.2024

parent f957c776
No related branches found
No related tags found
No related merge requests found
Showing
with 390 additions and 0 deletions
File added
File added
File added
File added
20241212/pendel-1-differentialgleichung.png

30.1 KiB

README: Differentialgleichung des mathematischen Pendels
20241212/pendel-2-analytische-loesung-mit-kleinwinkelnaeherung.png

121 KiB

README: Analytische Lösung Differentialgleichung des mathematischen Pendels mit Kleinwinkelnäherung
File added
#include <gtk/gtk.h>
#include <math.h>
int width = 320;
int height = 240;
int gap = height / 20;
int r = gap;
double visual_length = height - 2 * gap - r;
double phi0 = -0.5;
double omega0 = 0.0;
double t0 = 0.0;
double g = 9.81;
double l = 1.0;
double dt = 0.02;
double t = t0;
double phi = phi0;
double omega = omega0;
gboolean draw (GtkWidget *widget, cairo_t *c, gpointer data)
{
GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 };
int x = width / 2 + visual_length * sin (phi);
int y = gap + visual_length * cos (phi);
gdk_cairo_set_source_rgba (c, &blue);
cairo_move_to (c, width / 2, gap);
cairo_line_to (c, x, y);
cairo_stroke (c);
cairo_arc (c, x, y, r, 0, 2 * G_PI);
cairo_fill (c);
return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */
}
gboolean timer (GtkWidget *widget)
{
t += dt;
phi += omega * dt;
omega += - dt * g / l * sin (phi);
gtk_widget_queue_draw_area (widget, 0, 0, width, height);
g_timeout_add (50, (GSourceFunc) timer, widget);
return FALSE;
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Hello");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_set_size_request (drawing_area, width, height);
g_signal_connect (drawing_area, "draw", G_CALLBACK (draw), NULL);
g_timeout_add (50, (GSourceFunc) timer, drawing_area);
gtk_main ();
return 0;
}
#include <gtk/gtk.h>
#include <math.h>
#define WIDTH 320
#define HEIGHT 240
#define GAP (HEIGHT / 20)
#define r GAP
#define visual_length (HEIGHT - 2 * GAP - r)
#define phi0 (-0.5)
#define omega0 0.0
#define t0 0.0
#define g 9.81
#define l 1.0
#define dt 0.02
double t = t0;
double phi = phi0;
double omega = omega0;
gboolean draw (GtkWidget *widget, cairo_t *c, gpointer data)
{
GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 };
int x = WIDTH / 2 + visual_length * sin (phi);
int y = GAP + visual_length * cos (phi);
gdk_cairo_set_source_rgba (c, &blue);
cairo_move_to (c, WIDTH / 2, GAP);
cairo_line_to (c, x, y);
cairo_stroke (c);
cairo_arc (c, x, y, r, 0, 2 * G_PI);
cairo_fill (c);
return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */
}
gboolean timer (GtkWidget *widget)
{
t += dt;
phi += omega * dt;
omega += - dt * g / l * sin (phi);
gtk_widget_queue_draw_area (widget, 0, 0, WIDTH, HEIGHT);
g_timeout_add (50, (GSourceFunc) timer, widget);
return FALSE;
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Hello");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT);
g_signal_connect (drawing_area, "draw", G_CALLBACK (draw), NULL);
g_timeout_add (50, (GSourceFunc) timer, drawing_area);
gtk_main ();
return 0;
}
#include <gtk/gtk.h>
#include <math.h>
#define WIDTH 320
#define HEIGHT 240
#define GAP (HEIGHT / 20)
#define r GAP
#define visual_length (HEIGHT - 2 * GAP - r)
#define phi0 (-0.5)
#define omega0 0.0
#define t0 0.0
#define g 9.81
#define l 1.0
#define dt 0.02
double t = t0;
double phi = phi0;
double omega = omega0;
gboolean draw (GtkWidget *widget, cairo_t *c, gpointer data)
{
GdkRGBA orange = { 1.0, 0.5, 0.0, 1.0 };
int x = WIDTH / 2 + visual_length * sin (phi);
int y = GAP + visual_length * cos (phi);
gdk_cairo_set_source_rgba (c, &orange);
cairo_move_to (c, WIDTH / 2, GAP);
cairo_line_to (c, x, y);
cairo_stroke (c);
cairo_arc (c, x, y, r, 0, 2 * G_PI);
cairo_fill (c);
return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */
}
gboolean timer (GtkWidget *widget)
{
t += dt;
phi += omega * dt;
omega += - dt * g / l * phi;
gtk_widget_queue_draw_area (widget, 0, 0, WIDTH, HEIGHT);
g_timeout_add (50, (GSourceFunc) timer, widget);
return FALSE;
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Hello");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT);
g_signal_connect (drawing_area, "draw", G_CALLBACK (draw), NULL);
g_timeout_add (50, (GSourceFunc) timer, drawing_area);
gtk_main ();
return 0;
}
#include <gtk/gtk.h>
#include <math.h>
#define WIDTH 320
#define HEIGHT 240
#define GAP (HEIGHT / 20)
#define r GAP
#define visual_length (HEIGHT - 2 * GAP - r)
#define phi0 (-0.5)
#define omega0 0.0
#define t0 0.0
#define g 9.81
#define l 1.0
#define dt 0.02
double t = t0;
double phi_with_sin = phi0;
double omega_with_sin= omega0;
double phi_without_sin = phi0;
double omega_without_sin= omega0;
void draw_pendulum (cairo_t *c, double phi, GdkRGBA *colour)
{
int x = WIDTH / 2 + visual_length * sin (phi);
int y = GAP + visual_length * cos (phi);
gdk_cairo_set_source_rgba (c, colour);
cairo_move_to (c, WIDTH / 2, GAP);
cairo_line_to (c, x, y);
cairo_stroke (c);
cairo_arc (c, x, y, r, 0, 2 * G_PI);
cairo_fill (c);
}
gboolean draw (GtkWidget *widget, cairo_t *c, gpointer data)
{
GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 };
GdkRGBA orange = { 1.0, 0.5, 0.0, 1.0 };
GdkRGBA green = { 0.0, 0.5, 0.0, 1.0 };
double A = phi0;
double B = 0.5 * M_PI; /* 90° */
double phi_analytic = A * sin (sqrt (g / l) * t + B);
/* Näherungen: Kleinwinkel dt */
draw_pendulum (c, phi_with_sin, &blue); /* blau nein ja */
draw_pendulum (c, phi_without_sin, &orange); /* orange ja ja */
draw_pendulum (c, phi_analytic, &green); /* grün ja nein */
return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */
}
gboolean timer (GtkWidget *widget)
{
t += dt;
phi_with_sin += omega_with_sin * dt;
omega_with_sin += - dt * g / l * sin (phi_with_sin);
phi_without_sin += omega_without_sin * dt;
omega_without_sin += - dt * g / l * phi_without_sin;
gtk_widget_queue_draw_area (widget, 0, 0, WIDTH, HEIGHT);
g_timeout_add (50, (GSourceFunc) timer, widget);
return FALSE;
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Hello");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT);
g_signal_connect (drawing_area, "draw", G_CALLBACK (draw), NULL);
g_timeout_add (50, (GSourceFunc) timer, drawing_area);
gtk_main ();
return 0;
}
#include <gtk/gtk.h>
#include <math.h>
#define WIDTH 320
#define HEIGHT 240
#define GAP (HEIGHT / 20)
#define r GAP
#define visual_length (HEIGHT - 2 * GAP - r)
#define phi0 (-5.0 / 180.0 * M_PI)
#define omega0 0.0
#define t0 0.0
#define g 9.81
#define l 1.0
#define dt 0.02
double t = t0;
double phi_with_sin = phi0;
double omega_with_sin= omega0;
double phi_without_sin = phi0;
double omega_without_sin= omega0;
void draw_pendulum (cairo_t *c, double phi, GdkRGBA *colour)
{
int x = WIDTH / 2 + visual_length * sin (phi);
int y = GAP + visual_length * cos (phi);
gdk_cairo_set_source_rgba (c, colour);
cairo_move_to (c, WIDTH / 2, 10);
cairo_line_to (c, x, y);
cairo_stroke (c);
cairo_arc (c, x, y, r, 0, 2 * G_PI);
cairo_fill (c);
}
gboolean draw (GtkWidget *widget, cairo_t *c, gpointer data)
{
GdkRGBA blue = { 0.0, 0.5, 1.0, 1.0 };
GdkRGBA orange = { 1.0, 0.5, 0.0, 1.0 };
GdkRGBA green = { 0.0, 0.5, 0.0, 1.0 };
double A = phi0;
double B = 0.5 * M_PI; /* 90° */
double phi_analytic = A * sin (sqrt (g / l) * t + B);
draw_pendulum (c, phi_with_sin, &blue);
draw_pendulum (c, phi_without_sin, &orange);
draw_pendulum (c, phi_analytic, &green);
return FALSE; /* TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. */
}
gboolean timer (GtkWidget *widget)
{
t += dt;
phi_with_sin += omega_with_sin * dt;
omega_with_sin += - dt * g / l * sin (phi_with_sin);
phi_without_sin += omega_without_sin * dt;
omega_without_sin += - dt * g / l * phi_without_sin;
gtk_widget_queue_draw_area (widget, 0, 0, WIDTH, HEIGHT);
g_timeout_add (50, (GSourceFunc) timer, widget);
return FALSE;
}
int main (int argc, char **argv)
{
gtk_init (&argc, &argv);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_window_set_title (GTK_WINDOW (window), "Hello");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_show (drawing_area);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
gtk_widget_set_size_request (drawing_area, WIDTH, HEIGHT);
g_signal_connect (drawing_area, "draw", G_CALLBACK (draw), NULL);
g_timeout_add (50, (GSourceFunc) timer, drawing_area);
gtk_main ();
return 0;
}
File added
20241212/smiley.png

585 B

#define smiley_width 14
#define smiley_height 14
static char smiley_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04,
0x08, 0x04, 0x00, 0x00, 0x01, 0x20, 0x02, 0x10, 0x04, 0x08, 0xF8, 0x07,
0x00, 0x00, 0x00, 0x00, };
...@@ -56,6 +56,8 @@ Tafelbilder: ...@@ -56,6 +56,8 @@ Tafelbilder:
* [05.12.2024: Schaltzeichen: „Widerstand ist zwecklos!“](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-0-widerstand-ist-zwecklos.png) * [05.12.2024: Schaltzeichen: „Widerstand ist zwecklos!“](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-0-widerstand-ist-zwecklos.png)
* [05.12.2024: Ohne Pull-Up- oder Pull-Down-Widerstand ist der Schaltzustand bei geöffnetem Taster undefiniert.](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-1-ohne-pull-up-pull-down.png) * [05.12.2024: Ohne Pull-Up- oder Pull-Down-Widerstand ist der Schaltzustand bei geöffnetem Taster undefiniert.](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-1-ohne-pull-up-pull-down.png)
* [05.12.2024: Pull-Down-, Pull-Up- und interner Pull-Up-Widerstand](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-2-mit-pull-up-pull-down.png) * [05.12.2024: Pull-Down-, Pull-Up- und interner Pull-Up-Widerstand](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241205/pull-up-pull-down-2-mit-pull-up-pull-down.png)
* [12.12.2024: Differentialgleichung des mathematischen Pendels](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241212/pendel-1-differentialgleichung.png)
* [12.12.2024: Analytische Lösung Differentialgleichung des mathematischen Pendels mit Kleinwinkelnäherung](https://gitlab.cvh-server.de/pgerwinski/hp/raw/2024ws/20241212/pendel-2-analytische-loesung-mit-kleinwinkelnaeherung.png)
Praktikumsunterlagen: Praktikumsunterlagen:
--------------------- ---------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment