Results 1 to 18 of 18

Thread: [Resolved] Trigonometry and Vectors

  1. #1

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Resolved [Resolved] Trigonometry and Vectors

    Having a dumb moment, so I need a little help. I have a 'vector' defined as U=-4.3, and V=-3.3

    From these two figures I need to derive an angle of about 45degs and a speed of about 11.

    I have no idea (although remember doing stuff like this ages ago) where to start. Actually that's not true . . .

    The hypo = -5.42 (by way of pythag) I can get the tan of the angle (o over a) but I can't recall how to derive the angle - and I certainly have no idea how to derive speed . . .

    I presume that the speed is the length of the vector?
    Last edited by yrwyddfa; Mar 16th, 2006 at 06:18 AM.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Trigonometry and Vectors

    Explain 'U' and 'V' to me. I think I probably know the rest.

  3. #3

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    From what I can gather they are the opp, and adj respectively - but I'm not sure . . .
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Trigonometry and Vectors

    My memory of this is a little faded

    What does the overall vector represent? Velocity?

  5. #5

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    The values are an ouput from the a numerical weather model. They denote wind speed and direction; Supposedly using simple maths it can be converted into which direction the wind is coming from and how fast it is. The results I quoted are from an interpretation of that model from elsewhere, so for instance given the values U=-4.3, and V=-3.3 I should be able to derive that the wind will be N'Ely of about 11 (not sure of units) [edit]it's in mph, but the output might be in knots, so that might have to be converted, too[/edit]

    My memory is gone, too - it's been sixteen years since I last looked at trigonometry
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Trigonometry and Vectors

    Morning,

    It depends on what your U and V are. Are they velocities? Distances? Coordinates? If you haven't been given any other information, then you have to assume that they're supposed to be velocities. If they're perpendicular, then you can use Pythagoras and tan to get teh angle, as you say, but you won't get 45 degrees nor will you get hypotenuse of 11. Tan 45 = 1, so opposite must = adjacent.

    The alternative is that these velocities aren't perpendicular. In that case though, you need to assume one or other of the speed or angle and try to work out the other. Obviously, if they aren't perpendicular and can be at any angle then the resultant vector can be any length you like between 1 (where the vectors are in opposite directions) to 7.6 (where they add).

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  7. #7
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Trigonometry and Vectors

    If these two represent perpendicular velocities pointing at the origin, then the length of the resultant vector is, as you say, from Pythagoras 5.42. If this is in metres/second, then this translates to 10.53 knots or 12.12 mph.
    The angle between the two is atan (3.3/4.3) = 37.5 degrees north of east (i.e. if east was the x axis, go 37.5 degrees to the north). And it's pointing towards the origin. Hence the wind is coming from the NE at a speed of 10.53 knots.

    Close enough?

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  8. #8

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    Thanks, still no closer to figuring out where to even start. I have another example (so the two together give)

    u=-4.4,v=-0.7 means E, 9mph
    u=-4.3,v=-3.3 means NE 11mph

    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  9. #9

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    Quote Originally Posted by zaza
    If these two represent perpendicular velocities pointing at the origin, then the length of the resultant vector is, as you say, from Pythagoras 5.42. If this is in metres/second, then this translates to 10.53 knots or 12.12 mph.
    The angle between the two is atan (3.3/4.3) = 37.5 degrees north of east (i.e. if east was the x axis, go 37.5 degrees to the north). And it's pointing towards the origin. Hence the wind is coming from the NE at a speed of 10.53 knots.

    Close enough?

    zaza
    I posted my last before I caught the your last. Cheers zaza, will run through some examples and report back
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  10. #10
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Trigonometry and Vectors

    In your second example, the length of the hypotenuse is sqrt(0.7^2 + 4.4^2) = 4.455m/s. This converts to 8.66 knots or 9.97 mph.
    The angle between them is atan 0.7/4.4 = 9.03 degrees. And both vectors point towards the origin (being negative), so the resultant is also pointing towards the origin, more ore less from the East.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  11. #11
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Trigonometry and Vectors

    If this is correct, then the way to think about it is the following. Imagine starting at the origin. Move along the x axis (W to E) by the magnitude of U (-U means head West). Then move along the Y axis (S to N) by the magnitude of V (-V means head South). The resultant vector from the origin to where you now are is the direction in which the wind is travelling (i.e. in the first example it is travelling roughly SW, so coming from the NE). The magnitude is obtained by Pythagoras (root of the sum of the squares) and is in m/s, which must be converted into knots. The angle is obtained by inverse tan of V/U and represents the angle that the wind is coming from relative to East towards North. So 37.5 degrees is roughly from the North East.

    Does that give roughly the right results.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  12. #12

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    Yeah that gives good results, thanks. Last part is to transform this vector into an angle from 0-360. Is there already some mathematical method for doing this? Or is it simply a list of If/Thens ?
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  13. #13

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Trigonometry and Vectors

    VB Code:
    1. Function DeriveWind(x As Double, y As Double, h As Double, v As Double)
    2.  
    3.     Const RAD_2_DEG As Double = 57.295780490443 '(180/PI)
    4.    
    5.     Dim px As Boolean
    6.     Dim py As Boolean
    7.    
    8.     ' Get wind speed in m/s, and convert to mph
    9.     v = Sqr(x * x + y * y) * 2.24
    10.    
    11.     ' Work out wind direction
    12.     h = Atn(Abs(y) / Abs(x)) * RAD_2_DEG
    13.    
    14.     ' Figure out which quadrant the vector is in and
    15.     ' convert to compass angles (between 0-360) to return heading
    16.     px = Sgn(x) = 1
    17.     py = Sgn(y) = 1
    18.    
    19.     If px And py Then
    20.         h = 180 + h
    21.     End If
    22.    
    23.     If px And Not py Then
    24.         h = 270 + h
    25.     End If
    26.    
    27.     If Not px And py Then
    28.         h = 90 + h
    29.     End If
    30.    
    31.     If Not px And Not py Then
    32.         h = 90 - h
    33.     End If
    34.    
    35. End Function

    Here's the resultant code. If anyone can improve on the messy if, then, elses at the end I'd be eternally grateful.

    Cheers
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  14. #14
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [Resolved] Trigonometry and Vectors

    You don't return a value and you haven't used V

  15. #15

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: [Resolved] Trigonometry and Vectors

    Quote Originally Posted by penagate
    You don't return a value and you haven't used V
    I wonder what ' v = Sqr(x * x + y * y) * 2.24' that does, then?

    True - it should be a sub.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

  16. #16
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [Resolved] Trigonometry and Vectors

    You don't return a value and you have used V

    Didn't see it.

  17. #17
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: [Resolved] Trigonometry and Vectors

    Morning,

    You need to handle x=0 as well, otherwise you will have to calculate atan(infinity).

    Here is some code taken from my Coordinates and Vectors link...

    VB Code:
    1. If coordin.X = 0 Then   'Handle X=0
    2.                 If coordin.Y > 0 Then
    3.                     coordout.Theta = PI / 2
    4.                 ElseIf coordin.Y < 0 Then
    5.                     coordout.Theta = 3 * PI / 2
    6.                 Else
    7.                     coordout.Theta = 0
    8.                 End If
    9.             Else
    10.                 If coordin.X > 0 And coordin.Y >= 0 Then    'If in +/+ quadrant
    11.                     coordout.Theta = Atan(coordin.Y / coordin.X)
    12.                 ElseIf coordin.X > 0 And coordin.Y < 0 Then 'If in +/- quadrant, need large angle
    13.                     coordout.Theta = (2 * PI) + Atan(coordin.Y / coordin.X)
    14.                 Else    'In negative quadrants
    15.                     coordout.Theta = PI + Atan(coordin.Y / coordin.X)
    16.                 End If
    17.             End If

    It takes x and y and returns theta, where theta is in radians and runs from 0 to 2Pi.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  18. #18

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: [Resolved] Trigonometry and Vectors

    Changed it a bit, but now get exactly the values I need without resorting to nasty IF, THEN, ELSES . . .

    VB Code:
    1. Public Sub DeriveWind(ByVal u As Single, ByVal v As Single)
    2.  
    3.     'a=(u,v)
    4.     'b=(0,1)
    5.    
    6.     Dim ma As Single ' |a|
    7.     Dim m As Single
    8.     Dim d As Single
    9.    
    10.     ' Get wind speed (magnitude) and convert it to mph
    11.     ma = Sqr(u * u + v * v)
    12.     m = ma * 2.24
    13.    
    14.     ' Get angle(d) difference between a, and b
    15.     ' because cos(d) = a.b/|a||b|, therefore d = arccos(a.b/|a||b|)
    16.     ' simplified d = arccos(v/|a|)
    17.     d = 360 - (ArcCos(v / ma) * 57.295780490443)
    18.    
    19.     Debug.Print d, m
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

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