Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1.       for (int j = 0; j < forcePlates[i].ForceSamples.Length; j++)
  2.                             {
  3.                                 //just to avoid error when ApplicationPoint is NaN
  4.                                 if (forcePlates[i].ForceSamples[j] != null)
  5.                                 {
  6.                                     //just to avoid error when ApplicationPoint is NaN                            
  7.                                     if (forcePlates != null
  8.                                     && forcePlates[i] != null
  9.                                     && forcePlates[i].ForceSamples != null
  10.                                     && forcePlates[i].ForceSamples[j] != null
  11.                                     && forcePlates[i].ForceSamples[j].Force != null
  12.                                     && forcePlates[i].ForceSamples[j].ApplicationPoint != null
  13.                                     && forcePlates[i].ForceSamples[j].Moment != null
  14.                                     && !float.IsNaN(forcePlates[i].ForceSamples[j].Force.sqrMagnitude)
  15.                                     && !float.IsNaN(forcePlates[i].ForceSamples[j].ApplicationPoint.sqrMagnitude)
  16.                                     && !float.IsNaN(forcePlates[i].ForceSamples[j].Moment.sqrMagnitude))
  17.                                     {
  18.                                         try
  19.                                         {
  20.                                             Vector3 force = Vector3.zero;
  21.                                             lock (forcePlates[i].ForceSamples[j])
  22.                                             {
  23.                                                 force = (transform.TransformPoint(forcePlates[i].ForceSamples[j].Force) - transform.position) * forceScale;
  24.                                             }
  25.  
  26.                                             Vector3 moment = Vector3.zero;
  27.                                             lock (forcePlates[i].ForceSamples[j])
  28.                                             {
  29.                                                 moment = transform.TransformPoint(forcePlates[i].ForceSamples[j].Moment);
  30.                                             }
  31.  
  32.                                             Vector3 COP = Vector3.zero;
  33.                                             lock (forcePlates[i].ForceSamples[j])
  34.                                             {
  35.                                                 COP = transform.TransformPoint(forcePlates[i].ForceSamples[j].ApplicationPoint) - transform.position;
  36.                                             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement