Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
qangleconstraint.h
1 
2 /************************************************************************************
3  * MIT License
4  *
5  * Copyright (c) 2023 Eray Zesen
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  * https://github.com/erayzesen/QuarkPhysics
25  *
26 **************************************************************************************/
27 
28 #ifndef QANGLECONSTRAINT_H
29 #define QANGLECONSTRAINT_H
30 #include "qparticle.h"
31 
32 class QMesh;
38 {
39  float rigidity=0.5f;
40  QParticle *pA;
41  QParticle *pB;
42  QParticle *pC;
43  float minAngle=0.0;
44  float maxAngle=0.0;
45  float currentAngle=0.0f;
46  float prevAngle=0.0f;
47  bool enabled=true;
48  bool beginToSaveAngles=true;
49 
50 
51 public:
58  QAngleConstraint(QParticle *particleA,QParticle *particleB,QParticle *particleC,float angleRange=0.1f );
67  QAngleConstraint(QParticle *particleA,QParticle *particleB,QParticle *particleC,float minimumAngle,float maximumAngle);
68 
69 
70 
76  virtual void Update(float specifiedRigidity=-1.0f,bool addToAccumulatedForces=false);
77 
78  //Get Methods
81  return pA;
82  }
85  return pB;
86  }
89  return pC;
90  }
92  float GetMinAngle(){
93  return minAngle;
94  }
96  float GetMaxAngle(){
97  return maxAngle;
98  }
100  float GetRigidity(){
101  return rigidity;
102  }
104  bool GetEnabled(){
105  return enabled;
106  }
107 
108  float GetCurrentAngle(){
109  return currentAngle;
110  }
111 
112  //Set Methods
118  pA=particle;
119  return this;
120  }
126  pB=particle;
127  return this;
128  }
129 
135  pC=particle;
136  return this;
137  }
143  minAngle=value;
144  return this;
145  }
146 
152  maxAngle=value;
153  return this;
154  }
155 
160  QAngleConstraint *SetRigidity(float rigidity){
161  this->rigidity=rigidity;
162  return this;
163  }
169  enabled=value;
170  return this;
171  }
172 
173 
174 
175 
176  static float GetAngleOfParticlesWithLocalPositions( QParticle *particleA,QParticle *particleB,QParticle *particleC);
177 
181  bool manualDeletion=false;
182 
183 
184 
185 
186 
187 };
188 
189 #endif // QANGLECONSTRAINT_H
You can apply angle constraints between 3 particles using the QAngleConstraint. The physics engine us...
Definition: qangleconstraint.h:38
QParticle * GetParticleB()
Definition: qangleconstraint.h:84
QParticle * GetParticleC()
Definition: qangleconstraint.h:88
QAngleConstraint * SetMaxAngle(float value)
Definition: qangleconstraint.h:151
QAngleConstraint * SetEnabled(bool value)
Definition: qangleconstraint.h:168
bool manualDeletion
Definition: qangleconstraint.h:181
bool GetEnabled()
Definition: qangleconstraint.h:104
QAngleConstraint * SetParticleA(QParticle *particle)
Definition: qangleconstraint.h:117
float GetMinAngle()
Definition: qangleconstraint.h:92
float GetMaxAngle()
Definition: qangleconstraint.h:96
QAngleConstraint * SetMinAngle(float value)
Definition: qangleconstraint.h:142
QAngleConstraint(QParticle *particleA, QParticle *particleB, QParticle *particleC, float angleRange=0.1f)
Definition: qangleconstraint.cpp:51
QParticle * GetParticleA()
Definition: qangleconstraint.h:80
QAngleConstraint * SetParticleB(QParticle *particle)
Definition: qangleconstraint.h:125
virtual void Update(float specifiedRigidity=-1.0f, bool addToAccumulatedForces=false)
Definition: qangleconstraint.cpp:76
float GetRigidity()
Definition: qangleconstraint.h:100
QAngleConstraint * SetParticleC(QParticle *particle)
Definition: qangleconstraint.h:134
QAngleConstraint * SetRigidity(float rigidity)
Definition: qangleconstraint.h:160
QParticle objects form the network structures of QMesh objects defined for all body object types....
Definition: qparticle.h:40
Every QBody object requires meshes. In other traditional physics engines, the term 'shape' is used in...
Definition: qmesh.h:49