Hello,
I am working on a problem in which a particle hits a wall and gets reflected.
I need to calculate the tangential velocity and the impact angle with the wall.
I wrote this:
[code=c]/*for tangential velocity*/
real vi = sqrt(p->state.V[0]* p->state.V[0]
+ p->state.V[1]* p->state.V[1]
+ p->state.V[2]* p->state.V[2]);
/*for impact angle */
real alphai = acos ((f_normal[0]*p->state.V[0] + f_normal[1]*p->state.V[1]
+ f_normal[2]*p->state.V[2])/sqrt(f_normal[0]*(f_normal[0]
+ f_normal[1]*(f_normal[1] + f_normal[2]*(f_normal[2])* sqrt(p->state.V[0]* p->state.V[0]
+ p->state.V[1]* p->state.V[1]+ p->state.V[2]* p->state.V[2])))
[/code]
I write the values to a file, every time the particle hits the wall.
The angle gives nan for many hits, while in most the value is of the range 1.2-2.5 , etc. Why does this happen?
Also, the tangential expression is incorrect.
Can you give me the correct solution?
Thank you.
I am working on a problem in which a particle hits a wall and gets reflected.
I need to calculate the tangential velocity and the impact angle with the wall.
I wrote this:
[code=c]/*for tangential velocity*/
real vi = sqrt(p->state.V[0]* p->state.V[0]
+ p->state.V[1]* p->state.V[1]
+ p->state.V[2]* p->state.V[2]);
/*for impact angle */
real alphai = acos ((f_normal[0]*p->state.V[0] + f_normal[1]*p->state.V[1]
+ f_normal[2]*p->state.V[2])/sqrt(f_normal[0]*(f_normal[0]
+ f_normal[1]*(f_normal[1] + f_normal[2]*(f_normal[2])* sqrt(p->state.V[0]* p->state.V[0]
+ p->state.V[1]* p->state.V[1]+ p->state.V[2]* p->state.V[2])))
[/code]
I write the values to a file, every time the particle hits the wall.
The angle gives nan for many hits, while in most the value is of the range 1.2-2.5 , etc. Why does this happen?
Also, the tangential expression is incorrect.
Can you give me the correct solution?
Thank you.
Comment