473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

tangential velocoity and impact angle

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:
Expand|Select|Wrap|Line Numbers
  1. /*for tangential velocity*/ 
  2. real vi = sqrt(p->state.V[0]* p->state.V[0] 
  3.                + p->state.V[1]* p->state.V[1]                     
  4.                + p->state.V[2]* p->state.V[2]);
  5.  
  6.  
  7. /*for impact angle */
  8. real alphai = acos ((f_normal[0]*p->state.V[0] + f_normal[1]*p->state.V[1]
  9.         + f_normal[2]*p->state.V[2])/sqrt(f_normal[0]*(f_normal[0]
  10.         + f_normal[1]*(f_normal[1] + f_normal[2]*(f_normal[2])* sqrt(p->state.V[0]* p->state.V[0]
  11.         + p->state.V[1]* p->state.V[1]+ p->state.V[2]* p->state.V[2])))
  12.  
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.
Nov 27 '07 #1
6 2451
weaknessforcats
9,208 Expert Mod 8TB
Please read the posting guidelines.


I can provide specific help on a C/C++ question but not on a general physics solution.
Nov 28 '07 #2
dear moderator,

the problem is not of physics, although it is a physics problem.
i have read the guidelines and have posted this.
well this is not my homework assignment, as i am doing my doctoral thesis..and this is only a small part of my extended research.
i asked this question because i am stuck, as i am getting nan (not a number) for many cases of particle impact..and i think this is where i think the programming part can be explained and debugged
i am not very good in programming, else i could have solved this problem myself.

a help would have been really appreciated and helpful for me.

thank you.
Nov 28 '07 #3
You are trying to use the dot product formula but you are not calculating correctly the modulus of both vectors.

This is what you should do.

Calculate the dot product and store it in a double variable "x".
Calculate the modulus of the Normal vector and store it in a double variable "y"
Calculate the modulus of the Velocity vector and store it in a double variable "z"
Calculate y*z, then check whether this value is close to zero.
If it is close to zero, dont calculate the angle, assume it is PI/2 radians in this case.
If it is not close to zero, then calculate the angle from: acos( x/ (y*z) )
There you go thats the angle.

I assume the tangencial velocity is a vector that is ortogonal to the normal vector? then
tangencial velocity vector = velocity - unormal ( unormal dotproduct velocity )

Where unormal is the normal vector divided by its modulus.


As a final note, your code is a bit messy because you are not using classes. I would recomend you using vector classes rather than arrays. And use doubles instead of floats.
Nov 29 '07 #4
dear cucumber,

thanks a lot for your reply even when the moderator 'denied'. thanks a lot truly..
i have made the impact angle one and it gives ok. (no nan)..

i just wanted to check the expression for tangential velocity which i figured from your post. Is it somthing like this ?
Expand|Select|Wrap|Line Numbers
  1. vel_tang_in = abs(p->state.V[0] - (f_normal[0]*p->state.V[0])
  2.                        + p->state.V[1] - (f_normal[0]*p->state.V[1])
  3.                        + p->state.V[2] - (f_normal[0]*p->state.V[2]));
  4.  
please rectify me if i am wrong.

thanks a lot.

kind regards,

rana
Nov 29 '07 #5
I think the moderator comment was right, but I am a math freak and I cant help solving math problems.

Now, I am just assuming you are trying to calculate the tangencial vector to a surface when a vector hits the surface on a given point, and you already have the Normal vector of the surface at that point.

So do this:

Normalize the normal vector, hehe that sounds funny, but you have to do that. That means divide each component of the normal vector by the normal vector modulus. Save this vector as the "unormal" vector.

Then calculate de dotproduct between the normalized normal vector and the velocity vector. Store this result in a double variable "x".

Now multiply the unormal vector by the scalar value "x", that means, each component should by multiplied by it. Then subtract the resulting vector from the velocity vector, you will obtain the tangencial velocity vector. To obtain the tangencial velocity calculate the modulus of the resulting vector.


Have a good math.
Nov 29 '07 #6
dear cucumber,

the tangential velocity which is am referring to is the velocity of the particle. the particle will have two velocity, tangential and normal.
can u please script the expression, as i am not able to udnerstand it clearly.
p->state.V is the velocity vector in to the boundary (before the particle hits with the wall)

kind regards,
rana
Nov 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Darren Grant | last post by:
Hi there, I've attempted to implement an Angle class. An Angle is a subset of an integer, where the range is [0,360). All other operations should be permitted. The code works, I think......
1
by: Ricardo Furtado | last post by:
I'm programming in vb .Net and i need to know how to determine angles. For example i have a figure like the following: | | | ------------------ | | |
29
by: Vol | last post by:
I think 'atan' can get the angle but it is not the four quadrant angle. Is there any function that i can get the angle from -pi to pi? or I have to use some if ... else? I know in Matlab, we use...
15
by: cwsullivan | last post by:
Hi gang, I have a grid full of particles in my program, and I want to find an angle between two particles. I'm having trouble because it seems like the answer depends on whether or not the target...
4
by: Jem | last post by:
Hi all I have the following code which draws a vertical line on a form... Dim VertCrossHairX1 As Integer = 75 Dim VertCrossHairX2 As Integer = 75 Dim VertCrossHairY1 As Integer = 70 Dim...
3
by: Doraj | last post by:
Hello ! Here is my problem : I had some php scripts which worked well with php 4.0.5 (GD 1.6.2 according to phpinfo() ) and i put them on a new server with php 4.4.2 (and GD 2.0.28). Now,...
2
by: laredotornado | last post by:
Hi, I'm using php 4.4.4. Maybe I'm misreading the docs, but in the imagettfbbox manual (http://us2.php.net/imagettfbbox), it says that text coordinates are the same regardless of what the angle...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.