Help converting Psuedo to spin
bambino
Posts: 789
Hi Guys, Been awile.
Below is some psuedo code i was lucky enough to get, as the equation used calculas notation(greek to me)
It appears to be easily converted to spin, but I thought I would post my first question now and just bump this thread latter when I get stumped again.
Right now the only thing that jumps out at me is the Power statement towards the bottom. Its not declared as a variable so I am assumeing this is some sort of operand. Can someone shed some light on that.
// GLOBAL VARIABLES
var
// Data Acquisition Information
SampleFrequency: integer; // Data acquisition rate, samples/second
nSamples : integer; // Number of acquired data samples
// Input Data
AccelData: array [0..nSamples] of real; // Array of acceleration data in g units
// Outputs
HICmax : real; // HIC score
HICinterval : real; // HIC interval
// HIC CALCULATION PROCEDURE
procedure HIC_Calculation;
// LOCAL VARIABLES
var
// Intermediate Results
integral : array [0..nSamples-1] of real; // HIC Integral Values
iHIC0,iHIC1 : integer; // HIC interval boundaries
HIC : real; // Intermediate HIC result
// Counters
i,j : integer;
begin
// Initialise results
iHIC0 := 0;
iHIC1 := 0;
HICmax:=-1.0;
// Calculate Integral
integral [0]:=0.0;
for i:=1 to nSamples do integral : =integral [i-1] +(AccelData +AccelData [i-1])/2;
// Scan all possible HIC intervals for maximum score
for i := 0 to nSamples-1 do
for j := i+1 to nSamples do
begin
HIC:=(integral [j]-integral )/(j-i);
if HIC>0.0
then HIC:=Power (HIC,2.5) 'This is the first statement I need help understanding
else HIC:=0.0;
HIC:=HIC*(j-i)/SampleFrequency;
if HIC>HICmax then
begin
HICmax:=HIC;
iHIC0:=i;
iHIC1:=j;
end;
end;
// Calculate the HIC interval
HICinterval := (IHIC1-IHIC0)/SampleFrequency;
end;
end.Below is some psuedo code i was lucky enough to get, as the equation used calculas notation(greek to me)
It appears to be easily converted to spin, but I thought I would post my first question now and just bump this thread latter when I get stumped again.
Right now the only thing that jumps out at me is the Power statement towards the bottom. Its not declared as a variable so I am assumeing this is some sort of operand. Can someone shed some light on that.
// GLOBAL VARIABLES
var
// Data Acquisition Information
SampleFrequency: integer; // Data acquisition rate, samples/second
nSamples : integer; // Number of acquired data samples
// Input Data
AccelData: array [0..nSamples] of real; // Array of acceleration data in g units
// Outputs
HICmax : real; // HIC score
HICinterval : real; // HIC interval
// HIC CALCULATION PROCEDURE
procedure HIC_Calculation;
// LOCAL VARIABLES
var
// Intermediate Results
integral : array [0..nSamples-1] of real; // HIC Integral Values
iHIC0,iHIC1 : integer; // HIC interval boundaries
HIC : real; // Intermediate HIC result
// Counters
i,j : integer;
begin
// Initialise results
iHIC0 := 0;
iHIC1 := 0;
HICmax:=-1.0;
// Calculate Integral
integral [0]:=0.0;
for i:=1 to nSamples do integral : =integral [i-1] +(AccelData +AccelData [i-1])/2;
// Scan all possible HIC intervals for maximum score
for i := 0 to nSamples-1 do
for j := i+1 to nSamples do
begin
HIC:=(integral [j]-integral )/(j-i);
if HIC>0.0
then HIC:=Power (HIC,2.5) 'This is the first statement I need help understanding
else HIC:=0.0;
HIC:=HIC*(j-i)/SampleFrequency;
if HIC>HICmax then
begin
HICmax:=HIC;
iHIC0:=i;
iHIC1:=j;
end;
end;
// Calculate the HIC interval
HICinterval := (IHIC1-IHIC0)/SampleFrequency;
end;
Comments
your source lines here
[/code}
works for me. (NOTE: use square brackets instead of the '{ or }' ones.) Is there a simpler form?
If you use the Float32 object, it has a Pow() function that will do this.
Yes, the code looks pretty straight forward. It will not get a lot of attention from me and thus this thread will get buried. But when I get into the guts of it and have aproblem I'll bump it up again.
Pascal.....The article actually said it was from c++, but the := notation and the "do" statements didn't seem to fit. But I have limited languages to draw experience from.
Thanks for all the input. I don't even have the hardware done that this little guy will play in. I need to be able to understand what's going on here as well. At the peak of my mathematical prime we are Talking Algebra 2. Integral equations in calculus, like this, need to seep into my memory very slowly!
Thank you very much!
Now, if the maths is all Greek to you how are you going to tell if your final code is bug free and producing the correct results?
Volunteer numskulls and a large hammer?
I will have a commercial unit available with which to compare samples.
The link to your PDF would not open for me , but I have found that most documents on the web refer to automobile testing. The ASTM. I quoted from is actually for the sports industry. Without soundly Like the HIC test are BS, let me state that this big equation boils down to a boolean answer. Pass or Fail. With the threshold being a bloated number that suggests someone survived or Everyone died!
With so many numbers to consider, I presume verifying the accuracy will pan out easily against the Control unit. The results will either jive with the control, or not.
The real scare here: Is figuring out where the math went wrong went it doesn't sync With the control.
Now that Will be a good time to have a hammer available!!!
OK I fixed the link above to the HIC PDF.
This worries me, be aware that the HIC is not and probably never was intended to be used in such a way and is mostly a very vague hand waving guestimate. From that PDF:
"Just as with students' examination marks, the HIC does not provide an interval scale that enables comparisons. The HIC cannot make any statement about kind and severity of eventual injuries but gives an initial orientation for an estimation of the general injury risk."
"The complicate formula, the huge computer used for the calculation and the exact numerical result feign a meaningfulness that that crash-modelling using the HIC does not have."
"Reality was simplified very strongly."
"Probably the formula defining the HIC was created by accident ....got more or less satisfactory results , and this formulation became the norm."
"...such thing "smell" like a rule of thumb"
Given all that it probably does not matter much about how accurately you calculate it:)
From where I'm sitting no! But it will be expected to come within a certain percent of what the control or Triaxe says it is. Most folks won't to know what the G max is and are happy with that. But some of our customers are wanting the HIC as well!
The HIC in no accident though. It was derived from the severity Index which has a similar equation. They are both covered in the testing standard and the limitations of the HIC Are pointed out! So don't be too scared! Anytime I've seen it used was to weed out poor designs! Which is to say "If a play surface won't pass the HIC, Then don't bother to pay for more extensive testing. "
The other thing is the power of 2.5, well 2.5 is the same as 5/2 (five halves) and if you raise something to 5/2 you actually raise it to the power of 5 and then square root it:
http://images.planetmath.org:8080/cache/objects/7340/js/img1.png
I hope that helps a little.
Graham