tangential velocoity and impact angle

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • royrana
    New Member
    • Nov 2007
    • 5

    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:
    [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.
    Last edited by Killer42; Nov 30 '07, 01:28 AM.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Please read the posting guidelines.


    I can provide specific help on a C/C++ question but not on a general physics solution.

    Comment

    • royrana
      New Member
      • Nov 2007
      • 5

      #3
      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.

      Comment

      • Cucumber
        New Member
        • Sep 2007
        • 90

        #4
        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.

        Comment

        • royrana
          New Member
          • Nov 2007
          • 5

          #5
          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 ?
          [code=c]
          vel_tang_in = abs(p->state.V[0] - (f_normal[0]*p->state.V[0])
          + p->state.V[1] - (f_normal[0]*p->state.V[1])
          + p->state.V[2] - (f_normal[0]*p->state.V[2]));
          [/code]
          please rectify me if i am wrong.

          thanks a lot.

          kind regards,

          rana
          Last edited by pbmods; Nov 30 '07, 12:05 AM. Reason: Added CODE tags.

          Comment

          • Cucumber
            New Member
            • Sep 2007
            • 90

            #6
            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.

            Comment

            • royrana
              New Member
              • Nov 2007
              • 5

              #7
              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

              Comment

              Working...