• 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
joint.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_JOINT_H
24 #define STEPCORE_JOINT_H
25 
26 #include "world.h"
27 
28 namespace StepCore
29 {
30 
31 class Particle;
32 class RigidBody;
33 
37 class Anchor: public Item, public Joint
38 {
39  STEPCORE_OBJECT(Anchor)
40 
41 public:
43  explicit Anchor(Object* body = 0, const Vector2d& position = Vector2d::Zero(), double angle = 0);
44 
46  Object* body() const { return _body; }
48  void setBody(Object* body);
49 
51  const Vector2d& position() const { return _position; }
53  void setPosition(const Vector2d& position) { _position = position; }
54 
56  double angle() const { return _angle; }
58  void setAngle(double angle) { _angle = angle; }
59 
60  int constraintsCount();
61  void getConstraintsInfo(ConstraintsInfo* info, int offset);
62 
63  //void getConstraints(double* value, double* derivative);
64  //void getJacobian(GmmSparseRowMatrix* value, GmmSparseRowMatrix* derivative, int offset);
65 
66 protected:
67  Object* _body;
68  Vector2d _position;
69  double _angle;
70 
71  Particle* _p;
72  RigidBody* _r;
73 };
74 
78 class Pin: public Item, public Joint
79 {
80  STEPCORE_OBJECT(Pin)
81 
82 public:
84  explicit Pin(Object* body = 0, const Vector2d& localPosition = Vector2d::Zero(),
85  const Vector2d& position = Vector2d::Zero());
86 
88  Object* body() const { return _body; }
90  void setBody(Object* body);
91 
93  const Vector2d& localPosition() const { return _localPosition; }
95  void setLocalPosition(const Vector2d& localPosition) { _localPosition = localPosition; }
96 
98  const Vector2d& position() const { return _position; }
100  void setPosition(const Vector2d& position) { _position = position; }
101 
102  int constraintsCount();
103  void getConstraintsInfo(ConstraintsInfo* info, int offset);
104 
105  //void getConstraints(double* value, double* derivative);
106  //void getJacobian(GmmSparseRowMatrix* value, GmmSparseRowMatrix* derivative, int offset);
107 
108 protected:
109  Object* _body;
110  Vector2d _localPosition;
111  Vector2d _position;
112 
113  Particle* _p;
114  RigidBody* _r;
115 };
116 
120 class Stick: public Item, public Joint
121 {
122  STEPCORE_OBJECT(Stick)
123 
124 public:
126  explicit Stick(double restLength = 1,
127  Object* body1 = 0, Object* body2 = 0,
128  const Vector2d& localPosition1 = Vector2d::Zero(),
129  const Vector2d& localPosition2 = Vector2d::Zero());
130 
132  double restLength() const { return _restLength; }
134  void setRestLength(double restLength) { _restLength = restLength; }
135 
137  Object* body1() const { return _body1; }
139  void setBody1(Object* body1);
140 
142  Object* body2() const { return _body2; }
144  void setBody2(Object* body2);
145 
148  Vector2d localPosition1() const { return _localPosition1; }
151  void setLocalPosition1(const Vector2d& localPosition1) { _localPosition1 = localPosition1; }
152 
155  Vector2d localPosition2() const { return _localPosition2; }
158  void setLocalPosition2(const Vector2d& localPosition2) { _localPosition2 = localPosition2; }
159 
161  Vector2d position1() const;
163  Vector2d position2() const;
164 
166  Vector2d velocity1() const;
168  Vector2d velocity2() const;
169 
171  Particle* particle1() const { return _p1; }
173  Particle* particle2() const { return _p2; }
175  RigidBody* rigidBody1() const { return _r1; }
177  RigidBody* rigidBody2() const { return _r2; }
178 
179  int constraintsCount();
180  void getConstraintsInfo(ConstraintsInfo* info, int offset);
181 
182 protected:
183  double _restLength;
184  Object* _body1;
185  Object* _body2;
186  Vector2d _localPosition1;
187  Vector2d _localPosition2;
188 
189  Particle* _p1;
190  Particle* _p2;
191  RigidBody* _r1;
192  RigidBody* _r2;
193 };
194 
198 class Rope: public Stick
199 {
200  STEPCORE_OBJECT(Rope)
201 
202 public:
203  void getConstraintsInfo(ConstraintsInfo* info, int offset);
204 };
205 
206 } // namespace StepCore
207 
208 #endif
StepCore::Anchor::_r
RigidBody * _r
Definition: joint.h:72
StepCore::Anchor::_position
Vector2d _position
Definition: joint.h:68
StepCore::Stick::velocity2
Vector2d velocity2() const
Velocity of the second end of the stick.
Definition: joint.cc:269
StepCore::Pin::setLocalPosition
void setLocalPosition(const Vector2d &localPosition)
Set local position of the pin on the body.
Definition: joint.h:95
StepCore::Anchor::_p
Particle * _p
Definition: joint.h:71
StepCore::Anchor::Anchor
Anchor(Object *body=0, const Vector2d &position=Vector2d::Zero(), double angle=0)
Constructs Anchor.
StepCore::Stick::localPosition2
Vector2d localPosition2() const
Local position of the second end of the stick on the body or in the world (if the end is not connecte...
Definition: joint.h:155
StepCore::Vector2d
Eigen::Vector2d Vector2d
Two-dimensional vector with double components.
Definition: vector.h:29
StepCore::Pin::getConstraintsInfo
void getConstraintsInfo(ConstraintsInfo *info, int offset)
Fill the part of constraints information structure starting at offset.
Definition: joint.cc:152
StepCore::Anchor
Fixes position of the body.
Definition: joint.h:37
StepCore::Object
Root of the StepCore classes hierarchy.
Definition: object.h:57
StepCore::Stick::velocity1
Vector2d velocity1() const
Velocity of the first end of the stick.
Definition: joint.cc:262
StepCore::Stick::setBody2
void setBody2(Object *body2)
Set pointer to the second connected body.
Definition: joint.cc:228
StepCore::Stick::rigidBody1
RigidBody * rigidBody1() const
Get first connected RigidBody.
Definition: joint.h:175
StepCore::Stick::_localPosition1
Vector2d _localPosition1
Definition: joint.h:186
StepCore::Stick::localPosition1
Vector2d localPosition1() const
Local position of the first end of the stick on the body or in the world (if the end is not connected...
Definition: joint.h:148
StepCore::Pin::body
Object * body() const
Get pointer to the body.
Definition: joint.h:88
StepCore::Stick::getConstraintsInfo
void getConstraintsInfo(ConstraintsInfo *info, int offset)
Fill the part of constraints information structure starting at offset.
Definition: joint.cc:284
StepCore::Stick::restLength
double restLength() const
Get the restLength of the stick.
Definition: joint.h:132
StepCore::Stick::position1
Vector2d position1() const
Position of the first end of the stick.
Definition: joint.cc:248
StepCore::RigidBody
Rigid body.
Definition: rigidbody.h:144
StepCore::Stick::body1
Object * body1() const
Get pointer to the first connected body.
Definition: joint.h:137
StepCore::Anchor::_body
Object * _body
Definition: joint.h:67
world.h
Item, Body, Force and Tool interfaces, World class.
StepCore::Anchor::position
const Vector2d & position() const
Get position of the anchor.
Definition: joint.h:51
StepCore::Joint
Interface for joints.
Definition: world.h:258
StepCore::Pin::Pin
Pin(Object *body=0, const Vector2d &localPosition=Vector2d::Zero(), const Vector2d &position=Vector2d::Zero())
Constructs Pin.
Definition: joint.cc:116
StepCore::Anchor::setAngle
void setAngle(double angle)
Set angle of the anchor.
Definition: joint.h:58
StepCore::Stick::Stick
Stick(double restLength=1, Object *body1=0, Object *body2=0, const Vector2d &localPosition1=Vector2d::Zero(), const Vector2d &localPosition2=Vector2d::Zero())
Constructs Stick.
Definition: joint.cc:199
StepCore::Stick::_r2
RigidBody * _r2
Definition: joint.h:192
StepCore::Stick::body2
Object * body2() const
Get pointer to the second connected body.
Definition: joint.h:142
StepCore::Rope::getConstraintsInfo
void getConstraintsInfo(ConstraintsInfo *info, int offset)
Fill the part of constraints information structure starting at offset.
Definition: joint.cc:381
StepCore::Stick::_p1
Particle * _p1
Definition: joint.h:189
StepCore::Item
The root class for any world items (bodies and forces)
Definition: world.h:69
StepCore::Pin::localPosition
const Vector2d & localPosition() const
Local position of the pin on the body.
Definition: joint.h:93
StepCore::Stick::setRestLength
void setRestLength(double restLength)
Set the restLength of the stick.
Definition: joint.h:134
StepCore::Anchor::constraintsCount
int constraintsCount()
Get count of constraints.
Definition: joint.cc:82
StepCore::Pin::_r
RigidBody * _r
Definition: joint.h:114
StepCore::Anchor::getConstraintsInfo
void getConstraintsInfo(ConstraintsInfo *info, int offset)
Fill the part of constraints information structure starting at offset.
Definition: joint.cc:89
StepCore::Stick::particle2
Particle * particle2() const
Get second connected Particle.
Definition: joint.h:173
StepCore::Pin::_p
Particle * _p
Definition: joint.h:113
StepCore::Stick::setBody1
void setBody1(Object *body1)
Set pointer to the first connected body.
Definition: joint.cc:208
StepCore::Stick::_localPosition2
Vector2d _localPosition2
Definition: joint.h:187
StepCore::Pin::_body
Object * _body
Definition: joint.h:109
StepCore::Pin::constraintsCount
int constraintsCount()
Get count of constraints.
Definition: joint.cc:143
StepCore::Anchor::angle
double angle() const
Get angle of the anchor.
Definition: joint.h:56
StepCore::Stick::setLocalPosition1
void setLocalPosition1(const Vector2d &localPosition1)
Set local position of the first end of the stick on the body or in the world (if the end is not conne...
Definition: joint.h:151
StepCore::Stick::_body2
Object * _body2
Definition: joint.h:185
StepCore::Pin::position
const Vector2d & position() const
Get global position of the pin.
Definition: joint.h:98
StepCore::Stick::_restLength
double _restLength
Definition: joint.h:183
StepCore::Anchor::_angle
double _angle
Definition: joint.h:69
StepCore::Anchor::body
Object * body() const
Get pointer to the body.
Definition: joint.h:46
StepCore::Particle
Particle with mass.
Definition: particle.h:103
StepCore::Stick::setLocalPosition2
void setLocalPosition2(const Vector2d &localPosition2)
Set local position of the second end of the stick on the body or in the world (if the end is not conn...
Definition: joint.h:158
StepCore::Pin::setPosition
void setPosition(const Vector2d &position)
Set global position of the pin.
Definition: joint.h:100
StepCore::Anchor::setPosition
void setPosition(const Vector2d &position)
Set position of the anchor.
Definition: joint.h:53
StepCore::Pin
Fixes position of a given point on the body.
Definition: joint.h:78
StepCore::Anchor::setBody
void setBody(Object *body)
Set pointer to the body.
Definition: joint.cc:62
StepCore::Stick::_body1
Object * _body1
Definition: joint.h:184
StepCore::Rope
Massless rope: maximal distance between two points on particles or rigid bodies.
Definition: joint.h:198
StepCore::Stick::rigidBody2
RigidBody * rigidBody2() const
Get second connected RigidBody.
Definition: joint.h:177
StepCore::Pin::_localPosition
Vector2d _localPosition
Definition: joint.h:110
StepCore::Stick::position2
Vector2d position2() const
Position of the second end of the stick.
Definition: joint.cc:255
STEPCORE_OBJECT
#define STEPCORE_OBJECT(_className)
Definition: object.h:49
StepCore::Pin::setBody
void setBody(Object *body)
Set pointer to the body.
Definition: joint.cc:123
StepCore::ConstraintsInfo
Constraints information structure XXX: Move it to constraintsolver.h.
Definition: world.h:216
StepCore::Stick::particle1
Particle * particle1() const
Get first connected Particle.
Definition: joint.h:171
StepCore::Pin::_position
Vector2d _position
Definition: joint.h:111
StepCore::Stick::_p2
Particle * _p2
Definition: joint.h:190
StepCore::Stick::constraintsCount
int constraintsCount()
Get count of constraints.
Definition: joint.cc:276
StepCore::Stick::_r1
RigidBody * _r1
Definition: joint.h:191
StepCore::Stick
Massless stick: fixed distance between two points on particles or rigid bodies.
Definition: joint.h:120
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