/* Simple test of cpDampedSpringGetStiffness(). */ void test_cpDampedSpringGetStiffness(void) { cpConstraint *spring1 = cpDampedSpringNew(body1, body2, cpv(13.2, 6.54), cpv(0, 0), 13, 50.48, 1); CU_ASSERT(cpDampedSpringGetStiffness(spring1) == 50.48); cpConstraint *spring2 = cpDampedSpringNew(body1, body2, cpv(13.2, 6.54), cpv(0, 0), -0.45, 0, 1); CU_ASSERT(cpDampedSpringGetStiffness(spring2) == 0); cpConstraint *spring3 = cpDampedSpringNew(body1, body2, cpv(13.2, 6.54), cpv(0, 0), 0, -16.57, 1); CU_ASSERT(cpDampedSpringGetStiffness(spring3) == -16.57); cpConstraint *spring4 = cpDampedSpringNew(body1, body2, cpv(13.2, 6.54), cpv(0, 0), 91.65, 19, 1); CU_ASSERT(cpDampedSpringGetStiffness(spring4) == 19); }
float PhysicsJointSpring::getStiffness() const { return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_cpConstraints.front())); }
static cpFloat springForce(cpConstraint *spring, cpFloat dist) { cpFloat clamp = 20.0f; return cpfclamp(cpDampedSpringGetRestLength(spring) - dist, -clamp, clamp)*cpDampedSpringGetStiffness(spring); }
cpFloat DampedSpring::getStiffness(void) { return cpDampedSpringGetStiffness(constraint); }
float Spring::getStiffness(){ return cpDampedSpringGetStiffness(constraint); }