C#获取1个数据/ 20 [英] C# To take 1 datum / 20

查看:43
本文介绍了C#获取1个数据/ 20的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



此代码中创建的文本文件并不好。我没有很好的价值观。



我想我的问题是关于这一行:

Hello !

The text file which is created in this code, is not good. I don't have the good values.

I suppose my problem is about this line :

float delta_x = (((nv_data [59].positions [frame] - nv_data [59].positions [frame - 1]).z) * 0.001f);





我认为需要:



I think it takes :

nv_data[59].positions[20]-nv_data[59].positions[19]
nv_data[59].positions[40]-nv_data[59].positions[39]
nv_data[59].positions[60]-nv_data[59].positions[59]
...





或:



or :

nv_data[59].positions[20]-nv_data[59].positions[0]
nv_data[59].positions[21]-nv_data[59].positions[1]
nv_data[59].positions[22]-nv_data[59].positions[2]
...



< u>或:


or :

nv_data[59].positions[20]-nv_data[59].positions[19]
nv_data[59].positions[21]-nv_data[59].positions[20]
nv_data[59].positions[22]-nv_data[59].positions[21]
...





而不是:(这就是我想要的)



Instead of : (and it's it that I want)

nv_data[59].positions[20]-nv_data[59].positions[0]
nv_data[59].positions[40]-nv_data[59].positions[20]
nv_data[59].positions[60]-nv_data[59].positions[40]
...





我只想使用每一帧/ 20。



这里出现的代码部分:





I want to use only each frame / 20 .

Here the part of the code where it appears :

void FixedUpdate() {

    delta_time += Time.deltaTime;

    if (frame < nv_data [0].positions.Length) {

                    if ((frame % 20) == 0) {

                            for (int k = 0; k < body.Length; ++k) {

                            if (body [k] != null) { 

                                            body [k].transform.localPosition = nv_data [k].positions [frame] / 1000; // This part is ok

                                    } else
                                            continue;
                            }

            Debug.Log("Frame_animation : " + frame); // I have 1 frame / 20 : 0 , 20 , 40 , 60 , ...

                            if (indice_3 < forces_dup.Length-1) {

                                if (frame >= 20) {

                    Debug.Log ("Frame_writer : " + frame); // I have 1 frame / 20 : 0 , 20 , 40 , 60 , ...
                                            float delta_x = (((nv_data [59].positions [frame] - nv_data [59].positions [frame - 1]).z) * 0.001f); // It's here that I think I have some problems
                                            vitesse = delta_x / Time.deltaTime;
                                            acceleration = (vitesse - ancienne_vitesse) / Time.deltaTime;
                                            ancienne_vitesse = vitesse;

                                            indice_3 ++;

                                            StreamWriter writer = new StreamWriter ("Masse-fois-Accelerations_FR_5Hz", true);

                                            using (writer) {

                                                    writer.WriteLine (Time.time + "\t" + 80*acceleration + "\t" + forces_dup [indice_3].x); // Here I don't have the correct values for 80*acceleration
                                            }
                                    }
                            }
                    }

                            frame++;
            }
    }





非常感谢您的帮助



Thank you very much in advance for your help

推荐答案

void FixedUpdate() {

    delta_time += Time.deltaTime;

    if (frame < nv_data [0].positions.Length) {

                    if ((frame % 20) == 0) {

                            for (int k = 0; k < body.Length; ++k) {

                            if (body [k] != null) { 

                                            body [k].transform.localPosition = nv_data [k].positions [frame] / 1000;

                                    } else
                                            continue;
                            }

                            if (indice_3 < forces_dup.Length-1) {

                                if (frame >= 1) {

                                            float delta_z = (((nv_data [59].positions [frame] - nv_data [59].positions [frame - 20]).z) * 0.001f);
                                            vitesse = delta_z / (Time.deltaTime*20);
                                            acceleration = (vitesse - ancienne_vitesse) / (Time.deltaTime*20);
                                            ancienne_vitesse = vitesse;

                                            indice_3 ++;

                                            StreamWriter writer = new StreamWriter ("Masse-fois-Accelerations_FR_5Hz", true);

                                            using (writer) {

                                                    writer.WriteLine (Time.time + "\t" + 80*acceleration + "\t" + forces_dup [indice_3].x);
                                            }
                                    }
                            }
                    }

                            frame++;
            }


这篇关于C#获取1个数据/ 20的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆