Results 1 to 5 of 5

Thread: Forces, Speed,...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Location
    Slovenia
    Posts
    100

    Forces, Speed,...

    Im looking for formula for calc impact force from speed and mass of flying object.
    This i need becouse soon i gona start writing 2d physical engine.



  2. #2
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Forces, Speed,...

    the second law of newton should help you out in normal cases (no light speed involved)

    you just need to invert it to get the force that's neccesary to stop the object
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  3. #3
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229

    Re: Forces, Speed,...

    why don't you use the momentum equations? You can either have a completely elastic collision or an inelastic collision. Of course, there are some that are in between, where it's just a coefficient that is a property of the two materials involved multiplied by the final velocity.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Location
    Slovenia
    Posts
    100

    Re: Forces, Speed,...

    How to check if line is crossed by another line and on what coordinates.



  5. #5
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: Forces, Speed,...

    VB Code:
    1. Type tPoint
    2.     X As Double
    3.     Y As Double
    4. End Type
    5.  
    6. Type tLine
    7.     B As tPoint
    8.     E As tPoint
    9. End Type
    10.  
    11.  
    12. Function Intersect(L1 As tLine, L2 As tLine, Optional ByRef Pin As tPoint) As Boolean
    13. 'pin is used byref to return the point of intersection
    14. Dim a1 As Double
    15. Dim b1 As Double
    16. Dim a2 As Double
    17. Dim b2 As Double
    18. Dim i As Boolean
    19. Dim t As tPoint
    20.  
    21.     'determine the formula y = a * x + b for each line
    22.     a1 = (L1.E.Y - L1.B.Y) / (L1.E.X - L1.B.X)
    23.     b1 = L1.B.Y - L1.B.X * a1
    24.    
    25.     a2 = (L2.E.Y - L2.B.Y) / (L2.E.X - L2.B.X)
    26.     b2 = L2.B.Y - L2.B.X * a2
    27.    
    28.     If a1 = a2 Then 'test if the lines are parallel
    29.         If (b1 = b2) Then 'test if the lines start from the same point on the y axis
    30.             If L1.E.X < L1.B.X Then
    31.                 t = L1.B
    32.                 L1.B = L1.E
    33.                 L1.E = t
    34.             End If
    35.             If L2.E.X < L2.B.X Then
    36.                 t = L2.B
    37.                 L2.B = L2.E
    38.                 L2.E = t
    39.             End If
    40.             If L2.B.X <= L1.B.X And L1.B.X <= L2.E.X Then 'pick the first point that is on both linesections
    41.                 Pin = L1.B
    42.                 i = True
    43.             ElseIf L1.B.X <= L2.B.X And L2.B.X <= L1.E.X Then
    44.                 Pin = L2.B
    45.                 i = True
    46.             Else 'the linesections do not match
    47.                 Pin.X = 0
    48.                 Pin.Y = b1
    49.             End If
    50.         Else 'no intersection at all
    51.             Pin = t
    52.         End If
    53.     Else 'intersection in one point
    54.         Pin.X = (b2 - b1) / (a1 - a2) 'calculate the intersection
    55.         Pin.Y = a1 * Pin.X + b1
    56.         i = (la.B.X <= Pin.X And Pin.X <= la.E.X) Or (la.E.X <= Pin.X And Pin.X <= la.B.X) 'test if the intersection is on one of the lines
    57.     End If
    58.    
    59.     Intersect = i
    60. End Function
    Last edited by jeroen79; Feb 21st, 2007 at 06:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width