• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

step/stepcore

  • sources
  • kde-4.12
  • kdeedu
  • step
  • stepcore
softbody.h
Go to the documentation of this file.
1 /* This file is part of StepCore library.
2  Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
3 
4  StepCore library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  StepCore library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with StepCore; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
23 #ifndef STEPCORE_SOFTBODY_H
24 #define STEPCORE_SOFTBODY_H
25 
26 #include "particle.h"
27 #include "spring.h"
28 #include "world.h"
29 #include <cmath>
30 
31 namespace StepCore {
32 
36 class SoftBodyParticle: public Particle
37 {
38  STEPCORE_OBJECT(SoftBodyParticle)
39 
40 public:
42  explicit SoftBodyParticle(Vector2d position = Vector2d::Zero(), Vector2d velocity = Vector2d::Zero(), double mass = 1)
43  : Particle(position, velocity, mass) {}
44 };
45 
49 class SoftBodySpring: public Spring
50 {
51  STEPCORE_OBJECT(SoftBodySpring)
52 
53 public:
55  explicit SoftBodySpring(double restLength = 0, double stiffness = 1, double damping = 0,
56  Item* bodyPtr1 = 0, Item* bodyPtr2 = 0)
57  : Spring(restLength, stiffness, damping, bodyPtr1, bodyPtr2) {}
58 };
59 
60 typedef std::vector<SoftBodyParticle*> SoftBodyParticleList;
61 
65 class SoftBody: public ItemGroup
66 {
67  STEPCORE_OBJECT(SoftBody)
68 
69 public:
71  SoftBody(): _showInternalItems(true) { setColor(0xffa9a9a9); }
72 
82  ItemList createSoftBodyItems(const Vector2d& position, const Vector2d& size, const Vector2i& split,
83  double bodyMass, double youngModulus, double bodyDamping);
84 
86  void addItems(const ItemList& items);
87 
89  Vector2d position() const;
91  void setPosition(const Vector2d position);
92 
94  Vector2d velocity() const;
96  void setVelocity(const Vector2d velocity);
97 
99  double angularVelocity() const;
101  void setAngularVelocity(double angularVelocity);
102 
104  double angularMomentum() const;
105 
107  void setAngularMomentum(double angularMomentum);
108 
110  Vector2d acceleration() const { return force()/mass(); }
111 
113  double angularAcceleration() const { return torque()/inertia(); }
114 
116  Vector2d force() const;
118  double torque() const;
119 
121  double mass() const;
122 
124  double inertia() const;
125 
127  bool showInternalItems() const { return _showInternalItems; }
129  void setShowInternalItems(bool showInternalItems) {
130  _showInternalItems = showInternalItems; }
131 
133  const SoftBodyParticleList& borderParticles();
134 
135  QString borderParticleNames() const;
136  void setBorderParticleNames(const QString& borderParticleNames);
137 
138  void worldItemRemoved(Item* item);
139  void setWorld(World* world);
140 
141 protected:
142  SoftBodyParticleList _borderParticles;
143  QString _borderParticleNames;
144  bool _showInternalItems;
145 };
146 
147 } // namespace StepCore
148 
149 #endif
150 
StepCore::Particle::mass
double mass() const
Get mass of the particle.
Definition: particle.h:138
StepCore::Spring::stiffness
double stiffness() const
Get stiffness of the spring.
Definition: spring.h:149
StepCore::ItemGroup::item
Item * item(const QString &name) const
Get any descendant item by its name.
Definition: world.cc:191
StepCore::Vector2d
Eigen::Vector2d Vector2d
Two-dimensional vector with double components.
Definition: vector.h:29
StepCore::SoftBody::setPosition
void setPosition(const Vector2d position)
Set the position of the center of mass.
Definition: softbody.cc:185
StepCore::SoftBody::_borderParticles
SoftBodyParticleList _borderParticles
Definition: softbody.h:142
StepCore::SoftBody::mass
double mass() const
Get total body mass.
Definition: softbody.cc:157
StepCore::SoftBody::SoftBody
SoftBody()
Constructs a SoftBody.
Definition: softbody.h:71
StepCore::SoftBody::setAngularVelocity
void setAngularVelocity(double angularVelocity)
Set the angular velicity of the body.
Definition: softbody.cc:261
StepCore::SoftBody::worldItemRemoved
void worldItemRemoved(Item *item)
Definition: softbody.cc:344
StepCore::SoftBody::angularVelocity
double angularVelocity() const
Get the angular velicity of the body.
Definition: softbody.cc:256
StepCore::SoftBody::borderParticles
const SoftBodyParticleList & borderParticles()
Get ordered list of particles on the border of the body.
Definition: softbody.cc:311
StepCore::SoftBodyParticle
Soft body particle.
Definition: softbody.h:36
StepCore::SoftBody::createSoftBodyItems
ItemList createSoftBodyItems(const Vector2d &position, const Vector2d &size, const Vector2i &split, double bodyMass, double youngModulus, double bodyDamping)
Creates paricles and springs inside soft body.
StepCore::SoftBody::showInternalItems
bool showInternalItems() const
Get status of drawing of internal items.
Definition: softbody.h:127
StepCore::SoftBodySpring
Soft body spring.
Definition: softbody.h:49
spring.h
Spring class.
StepCore::SoftBodyParticle::SoftBodyParticle
SoftBodyParticle(Vector2d position=Vector2d::Zero(), Vector2d velocity=Vector2d::Zero(), double mass=1)
Constructs a SoftBadyParticle.
Definition: softbody.h:42
StepCore::Item::world
World * world() const
Get pointer to World in which this object lives.
Definition: world.h:91
world.h
Item, Body, Force and Tool interfaces, World class.
StepCore::SoftBody::torque
double torque() const
Get the torque acting on the body.
Definition: softbody.cc:296
StepCore::SoftBodyParticleList
std::vector< SoftBodyParticle * > SoftBodyParticleList
Definition: softbody.h:60
StepCore::Item::setColor
void setColor(Color color)
Set item color (for use in GUI)
Definition: world.h:112
StepCore::Item
The root class for any world items (bodies and forces)
Definition: world.h:69
StepCore::SoftBody::angularAcceleration
double angularAcceleration() const
Get angular acceleration of the body.
Definition: softbody.h:113
StepCore::SoftBody::setBorderParticleNames
void setBorderParticleNames(const QString &borderParticleNames)
Definition: softbody.cc:338
StepCore::SoftBody::inertia
double inertia() const
Get the inrtia of the body.
Definition: softbody.cc:224
StepCore::SoftBody::setVelocity
void setVelocity(const Vector2d velocity)
Set the velocity of the center of mass.
Definition: softbody.cc:212
StepCore::SoftBody::position
Vector2d position() const
Get the position of the center of mass.
Definition: softbody.cc:171
StepCore::ItemGroup
Groups several items together.
Definition: world.h:309
StepCore::SoftBody::borderParticleNames
QString borderParticleNames() const
Definition: softbody.cc:327
StepCore::SoftBody::force
Vector2d force() const
Get the force acting on the body.
Definition: softbody.cc:282
StepCore::ItemList
std::vector< Item * > ItemList
List of pointers to Item.
Definition: world.h:298
StepCore::Particle
Particle with mass.
Definition: particle.h:103
StepCore::Spring
Massless spring.
Definition: spring.h:129
particle.h
Particle and ChargedParticle classes.
StepCore::ItemGroup::items
const ItemList & items() const
Get list of all direct child items in the ItemGroup.
Definition: world.h:326
StepCore::SoftBody
SoftBody - a group of several SoftBodyParticle and SoftBodySprings.
Definition: softbody.h:65
StepCore::SoftBody::velocity
Vector2d velocity() const
Get the velocity of the center of mass.
Definition: softbody.cc:197
StepCore::SoftBody::_borderParticleNames
QString _borderParticleNames
Definition: softbody.h:143
StepCore::Vector2i
Eigen::Vector2i Vector2i
Two-dimensional vector with integer components.
Definition: vector.h:34
StepCore::SoftBody::acceleration
Vector2d acceleration() const
Get acceleration of the center of mass.
Definition: softbody.h:110
StepCore::SoftBody::angularMomentum
double angularMomentum() const
Get the angular momentum of the body.
Definition: softbody.cc:239
StepCore::Particle::position
const Vector2d & position() const
Get position of the particle.
Definition: particle.h:117
StepCore::SoftBodySpring::SoftBodySpring
SoftBodySpring(double restLength=0, double stiffness=1, double damping=0, Item *bodyPtr1=0, Item *bodyPtr2=0)
Constructs a SoftBodySpring.
Definition: softbody.h:55
StepCore::World
Contains multiple Item, Solver and general properties such as time.
Definition: world.h:372
StepCore::SoftBody::setAngularMomentum
void setAngularMomentum(double angularMomentum)
Set the angular momentum of the body.
Definition: softbody.cc:277
STEPCORE_OBJECT
#define STEPCORE_OBJECT(_className)
Definition: object.h:49
StepCore::Spring::damping
double damping() const
Get damping of the spring.
Definition: spring.h:154
StepCore::Particle::velocity
const Vector2d & velocity() const
Get velocity of the particle.
Definition: particle.h:122
StepCore::SoftBody::setShowInternalItems
void setShowInternalItems(bool showInternalItems)
Set status of drawing of internal items.
Definition: softbody.h:129
StepCore::Spring::restLength
double restLength() const
Get rest length of the spring.
Definition: spring.h:141
StepCore::SoftBody::_showInternalItems
bool _showInternalItems
Definition: softbody.h:144
StepCore::SoftBody::addItems
void addItems(const ItemList &items)
Adds all items to ItemGroup.
Definition: softbody.cc:149
StepCore::SoftBody::setWorld
void setWorld(World *world)
Set/change pointer to World in which this object lives.
Definition: softbody.cc:356
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:43:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal