1#ifndef ULT_PHYSICS_SPRING_H_INCLUDED
2#define ULT_PHYSICS_SPRING_H_INCLUDED
104 if (!mBall1 || !mBall2) {
return; }
105 Vector3D springVec = mBall2->GetPosition() - mBall1->GetPosition();
106 mTension = mConstant * (springVec.
Magnitude() - mLength) / mLength;
108 mBall1->AddForce(springVec * mTension);
109 mBall2->AddForce((springVec * mTension) * -1.0f);
114 float mTension, mConstant, mLength;
PointMass()
Definition PointMass.h:19
Spring()
Definition Spring.h:69
void Update()
Definition Spring.h:102
~Spring()
Definition Spring.h:79
void SetSpring(float t, float c, float l, SpringMass *m1, SpringMass *m2)
Definition Spring.h:90
SpringMass()
Definition Spring.h:19
void SetNormal(const Vector3D &n)
Definition Spring.h:37
Vector3D * GetNormalPtr()
Definition Spring.h:32
void SetIsFixed(const bool val)
Definition Spring.h:52
bool IsFixed() const
Definition Spring.h:47
Vector3D GetNormal() const
Definition Spring.h:27
void NormalizeNormal()
Definition Spring.h:42
void Normalize()
Definition Vector3D.cpp:157
float Magnitude() const
Definition Vector3D.cpp:152