aboutsummaryrefslogtreecommitdiffstats
path: root/yage/physics/body.h
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-09-09 07:55:22 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-09-09 07:55:22 +0100
commit60072c1d8089ffd3294e76636198d14710be95b8 (patch)
tree511d459e9afe69ca58d05880eb53ce44a9a183c6 /yage/physics/body.h
parent660996bd750dbb5fcdce85845ee6b260f3ed23eb (diff)
downloadYAGE-60072c1d8089ffd3294e76636198d14710be95b8.tar.gz
YAGE-60072c1d8089ffd3294e76636198d14710be95b8.zip
Restructuring
Diffstat (limited to 'yage/physics/body.h')
-rw-r--r--yage/physics/body.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/yage/physics/body.h b/yage/physics/body.h
new file mode 100644
index 00000000..bd33a9ac
--- /dev/null
+++ b/yage/physics/body.h
@@ -0,0 +1,56 @@
+/* ----------------------------------------------------------------------------
+ * body.h
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
+ * See file LICENSE for more details
+ * ----------------------------------------------------------------------------
+ */
+
+#ifndef YAGE_PHYSICS_BODY_H
+#define YAGE_PHYSICS_BODY_H
+
+#include <YAGE/Math/matrix.h>
+
+namespace yage
+{
+class Body
+{
+public:
+ // gravity constant
+ static const double GRAVITY;
+
+protected:
+ // center of mass of the object
+ Vector2d position_ = Vector2d(0, 0);
+
+ // mass of the object
+ double mass_ = 1;
+
+ // current velocity of the object
+ Vector2d velocity_ = Vector2d(0, 0);
+
+ // boolean that defines if gravity can act on the object
+ bool gravity_ = true;
+
+ // current acceleration
+ Vector2d acceleration_ = Vector2d(0, 0);
+
+ // force acting on the body
+ Vector2d force_ = Vector2d(0, 0);
+
+public:
+ // apply force to the object and update the velocity
+ virtual void applyForce(const Vector2d &force) = 0;
+ virtual void update() = 0;
+
+ double xPosition() const;
+ double yPosition() const;
+
+protected:
+ // protected constructor to initialize member variables
+ Body(Vector2d position = Vector2d(0, 0), double mass = 1,
+ Vector2d velocity = Vector2d(0, 0), bool gravity = false);
+};
+} // namespace yage
+
+#endif