Youngs Modulus Spring Strain

51 Views Asked by At

I need to simulate steel strain. But I can not add enough strain. If I will, it exploding and damping values can not fix.

Here is my code:

Vector3 delta = distance_joint.FirstNode.transform.position - distance_joint.SecondNode.transform.position;
float deltalength = delta.magnitude;

// Calculate strain
float strain = (deltalength - distance_joint.Distance) / distance_joint.Distance;

// Calculate the spring force based on Young's Modulus
Vector3 force = delta.normalized * SpringK * strain;

// Calculate relative velocity
Vector3 relativeVelocity = distance_joint.SecondNode.GetVelocity() - distance_joint.FirstNode.GetVelocity();

// Damping coefficient (you can adjust this value)
float dampingCoefficient = SpringDamping;

// Calculate the damping force based on relative velocity
Vector3 dampingForce = -dampingCoefficient * relativeVelocity;

// Combine spring force and damping force
force += dampingForce;

// Apply forces to the connected nodes
distance_joint.SecondNode.AddForce(force);
distance_joint.FirstNode.AddForce(-force);

Skeleton Structer

I wanna make a car skeleton.I need to simulate steel like material strain.

0

There are 0 best solutions below