x009.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "xerror.h"
4 #include "xmath.h"
5 #include "xphysics.h"
6 #include <iostream>
7 
8 namespace nmx::apps::x009 {
9 
13 class Pendulum
14 {
15 private:
16  double _length, _mass;
17 
18 public:
24  Pendulum(double l, double m)
25  : _length{ l }
26  , _mass{ m } {
27  //Länge und Masse sind positive Größen
28  if (l <= 0 || m <= 0) {
29  throw std::domain_error(__func__);
30  }
31  }
32 
37  double length() const { return _length; }
38 
43  double mass() const { return _mass; }
44 }; // Pendulum
45 
49 inline void ex1() {
50  using namespace gravitation;
51  Pendulum p{ 1, 2 };
52  //Schwingungsdauer für kleine Auslenkungen
53  const double T0 = 2 * Math::PI * std::sqrt(p.length() / Earth::g);
54  std::cout << p.length() << std::endl;
55  std::cout << p.mass() << std::endl;
56  std::cout << T0 << std::endl;
57 }
58 
59 } // namespace nmx::apps::x009
double length() const
length Zugriff auf interne Variable
Definition: x009.h:37
double mass() const
mass Zugriff auf interne Variable
Definition: x009.h:43
Pendulum(double l, double m)
Pendulum Konstruktor.
Definition: x009.h:24
void ex1()
ex1 Beispiel: Eigenschaften eines mathematischen Pendels
Definition: x009.h:49
The Pendulum class Eigenschaften eines mathematischen Pendels.
Definition: x009.h:13
static constexpr double PI
Definition: xmath.h:11