| 1 | 1/1 | 返回列表 |
| 查看: 677 | 回復(fù): 0 | ||
yali1990金蟲 (小有名氣)
|
[求助]
自規(guī)避行走鏈
|
|
#include "stdafx.h" #include "math.h" #include"stdlib.h"//調(diào)用rand()及srand()函數(shù) #include "time.h" #define PI 3.1415926 void mass_center_Rg2() { double X[10000][3];//鏈段坐標(biāo) double MC_X[3];//質(zhì)心坐標(biāo) int l=500;//鏈條數(shù) int N;//聚合度 srand((unsigned)time(NULL)); double a,b,d; double r=2.0; double Sum_Rg2; double Rg2; double X_Dis; double Y_Dis; double Z_Dis; FILE *write; write = fopen("Rg2_compute-1.txt","w" ;for(N=1000;N<=2000;N+=20) { Sum_Rg2=0.0; for(int j=1;j d=0.0; X[0][0]=0.0; X[0][1]=0.0; X[0][2]=0.0; MC_X[0] = 0.0; MC_X[1] = 0.0; MC_X[2] = 0.0; for(int i=0;i d=((float)rand())/RAND_MAX; a=d*PI; b=d*PI*2.0; X[i+1][0]=X[0]+r*sin(a)*cos(b);//鏈單元的坐標(biāo) X[i+1][1]=X[1]+r*sin(a)*sin(b);//鏈單元的坐標(biāo) X[i+1][2]=X[2]+r*cos(a);//鏈單元的坐標(biāo) if((i+1)>=2) { for(int counter=i-1;counter>=0;counter--) { double r0,x0,y0,z0; x0=X[i+1][0]-X[counter][0]; y0=X[i+1][1]-X[counter][1]; z0=X[i+1][2]-X[counter][2]; r0=pow(x0,2)+pow(y0,2)+pow(z0,2); if(r0>=4.0) { d=((float)rand())/RAND_MAX; a=d*PI; b=d*PI*2.0; X[i+1][0]=X[0]+r*sin(a)*cos(b);//鏈單元的坐標(biāo) X[i+1][1]=X[1]+r*sin(a)*sin(b);//鏈單元的坐標(biāo) X[i+1][2]=X[2]+r*cos(a);//鏈單元的坐標(biāo) } else continue; } } } for(int i=1;i<=N;i++){ MC_X[0]=MC_X[0]+ X[0]; MC_X[1]=MC_X[1]+ X[1]; MC_X[2]=MC_X[2]+ X[2]; } MC_X[0]=MC_X[0]/N; MC_X[1]=MC_X[1]/N; MC_X[2]=MC_X[2]/N; //printf("%f, %f ,%f\n",MC_X[0],MC_X[1],MC_X[2]); Rg2=0.0; for(int i=1;i<=N;i++){ X_Dis=X[0]-MC_X[0]; Y_Dis=X[1]-MC_X[1]; Z_Dis=X[2]-MC_X[2]; Rg2+=pow(X_Dis,2)+pow(Y_Dis,2)+pow(Z_Dis,2); } Rg2= Rg2/N; Sum_Rg2+=Rg2; } Sum_Rg2=Sum_Rg2/l; //平均,求出均方半徑 fprintf(write,"輸出N=%d,Sum_Rg2=%f\n",N,Sum_Rg2); printf("N= %d \n", N); } fclose(write); } int _tmain(int argc, _TCHAR* argv[]) { mass_center_Rg2();//調(diào)用函數(shù)求出鏈的質(zhì)心和Rg getchar(); return 0; } 這個(gè)是我編的代碼,目的是每產(chǎn)生一個(gè)坐標(biāo),都判斷它是否與前面的坐標(biāo)重合,如果重合,則重新產(chǎn)生一個(gè)新的坐標(biāo)。接下來是算質(zhì)心坐標(biāo),進(jìn)而計(jì)算均方回轉(zhuǎn)半徑。 目前我的問題是:這個(gè)和我之前計(jì)算無規(guī)行走鏈,得到的均方回轉(zhuǎn)半徑值基本一致,我要怎么改變坐標(biāo)的判斷條件? |
找到一些相關(guān)的精華帖子,希望有用哦~
| 1 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +7 | 張zz111 2026-03-27 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +6 | 白QF 2026-03-21 | 7/350 |
|
|
[考研] 085701環(huán)境工程,267求調(diào)劑 +12 | minht 2026-03-26 | 12/600 |
|
|
[考研] 285求調(diào)劑 +4 | AZMK 2026-03-27 | 7/350 |
|
|
[考研] 食品工程專碩一志愿中海洋309求調(diào)劑 +3 | 小張zxy張 2026-03-26 | 5/250 |
|
|
[考研] 材料292調(diào)劑 +12 | 橘頌思美人 2026-03-23 | 12/600 |
|
|
[考研] 283求調(diào)劑(080500) +4 | A child 2026-03-27 | 4/200 |
|
|
[考研] 一志愿華東理工大學(xué)081700,初試分?jǐn)?shù)271 +6 | kotoko_ik 2026-03-23 | 7/350 |
|
|
[考研] 333求調(diào)劑 +3 | question挽風(fēng) 2026-03-23 | 3/150 |
|
|
[考研] 0703化學(xué)/290求調(diào)劑/本科經(jīng)歷豐富/工科也可 +7 | 丹青奶蓋 2026-03-26 | 8/400 |
|
|
[考研] 321求調(diào)劑 +5 | 材料cailiao 2026-03-21 | 5/250 |
|
|
[考研] 329求調(diào)劑 +5 | 1() 2026-03-22 | 5/250 |
|
|
[考研] 081200-11408-276學(xué)碩求調(diào)劑 +3 | 崔wj 2026-03-26 | 3/150 |
|
|
[考研] 機(jī)械學(xué)碩310分,數(shù)一英一,一志愿211本科雙非找調(diào)劑信息 +3 | @357 2026-03-25 | 3/150 |
|
|
[考研] 332求調(diào)劑 +6 | 032500 2026-03-25 | 6/300 |
|
|
[考研] 考研調(diào)劑 +6 | 來好運(yùn)來來來 2026-03-21 | 7/350 |
|
|
[考研] 求調(diào)劑 +3 | 李李不服輸 2026-03-25 | 3/150 |
|
|
[考研] 生物學(xué)學(xué)碩求調(diào)劑 +7 | 小羊睡著了? 2026-03-23 | 10/500 |
|
|
[考研] 材料專碩331求調(diào)劑 +4 | 鮮當(dāng)牛 2026-03-24 | 4/200 |
|
|
[考研] 求調(diào)劑 +7 | 十三加油 2026-03-21 | 7/350 |
|