Results 1 to 11 of 11

Thread: Trig/Geo problem

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Arrow Trig/Geo problem

    Hi!

    I need some help calculating this.
    Take a look at this illustration.

    Here you'll see a point at (x,y).
    Using a line (green) drawn from the origin and a known angle (a) we can make another line (blue).
    This line (blue) is drawn from the point down to a help-line (brownish) that has the angle ca and
    the origin (cx,cy). Where these two lines intersect (x2,y2), i need to know the x2.
    Drawing a line from the point to the help-line at 90 degrees we will get a distance (d), i need that one too.

    That's all!

    Thanks very much!

    Attached Images Attached Images  
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    please help me...any help is apriciated. just something to get me started. not a whole function is not needed.
    if you dont know what i want, just ask me!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    you should label the points instead of mentioning the colors (hard to see).

    anywayz i am not sure what is the relationship of (x,y) and (x2,y2) and the angle a (maybe its the angle bisector?)

    so i cant help you with x2.

    but for the distance d, you first need to find the equation of the line passing through (x2,y2) and the origin (cx,cy). obviously, this line has slope of tan(ca). we have slope and a point, so we have equation. say the equation is Ax+By+c=0

    then the distance d from (x,y) to that line is given by the formula:
    |Ax+By+c|
    -------------
    sqrt(A^2+B^2)
    Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!


    Did you know that...
    The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!

  4. #4

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    the origin is allways (0,0), but the (cx,cy) can be changed. the green line is stuck with the origin (0,0).
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    ok...i'll make it really simple this time and i'll probably figure out the rest:

    i know v and l and i want to know l2 or l3.


    Attached Images Attached Images  
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  6. #6
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    for the last Q if I understand you right:
    VB Code:
    1. l3 = l * Tan(V)
    2. l2 = Sqr((l^2) + (l3^2))
    3. 'Or
    4. l2 = l / Cos(V)
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  7. #7

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    thanks alot! finally someone answers me!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Originally posted by cyborg
    thanks alot! finally someone answers me!
    LOL
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241
    Electroman,


    You might be the man to help me.

    I have a program that works out (or rather attempts to!) the angle between two known points, given a fixed datum (similar to the previous bit by cyborg). I've done the code, but it seems that I simply cannot get a true result. Can you point me in the right direction, please (before I start loosing my sanity!)...
    [vb]
    Private Sub CLOCK_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'This section calculates the relevant time based on the location of the users click on the object, bearing in mind
    'that the hour clicked will determine the minutes also. The calculation uses basic trig to work out the time...
    'version 2.0
    '2.0: The initial version of this was a simple typed entry created many years ago and not used since. The new
    ' version includes this radically different GUI.
    '1.0: Initial version.

    'Divide the face into 90° segments & get eh angle to work out the hour, followed by fractional minutes...

    Dim sglX As Single
    Dim sglY As Single
    Dim sglHours As Single
    Dim sglLength As Single
    Dim sglAngle As Single
    Dim sglTotalAngle As Single
    Dim sglMinutes As Single
    Dim intQuarter As Integer
    Dim intPM As Integer
    Static intXYQ(3) As Integer

    'On Error GoTo CLOCK_MouseDown_Error


    'Get the AM/PM setting...
    'The user can specify the PM time by either clicking the am/pm button, or by holding down the SHIFT button
    'while clicking the time on the clock face.
    intPM = Abs(([CMDAMPM].Caption = "pm") Or (Shift And acShiftMask)) * 360 'Get the add on for PM if necessary
    [CMDAMPM].Caption = Mid("ampm", (intPM Mod 358) + 1, 2) 'Set the caption for the AM/PM button

    'The following array maps bitwise +/- X and Y values to the clock-wise quarters of the clock...
    If intXYQ(0) = 0 Then
    intXYQ(0) = 4
    intXYQ(1) = 3
    intXYQ(2) = 1
    intXYQ(3) = 2
    End If

    'Determine which quarter the click was located in...
    sglX = X - sglCentre 'Find datum x
    sglY = Y - sglCentre 'Find datum y
    intQuarter = intXYQ((sglX >= 0 And 2) Or (sglY >= 0 And 1)) 'Get the quarter number

    'Now get the time...
    sglLength = Sqr(Abs(sglX) ^ 2 + Abs(sglY) ^ 2) 'Get the hypoteneuse
    sglAngle = Cos(Abs(sglX) / sglLength) * RadToDeg 'Get the angle

    sglTotalAngle = (intQuarter - 1) * 90 + sglAngle + intPM 'Total up the angle
    sglHours = sglTotalAngle / 30 '30° in an hour
    sglMinutes = (sglHours - Int(sglHours)) * 60 'Get the remaining minutes

    'Position the hour hand on the clock...
    With [HOUR]
    .Height = Abs(sglHourLen * Sin(sglAngle * DegToRad)) 'Get the height of the hour hand
    .Width = Abs(sglHourLen * Cos(sglAngle * DegToRad)) 'Get the width of the hour hand
    .Left = sglCentre + [CLOCK].Left + (intQuarter Mod 2 <> 0) * .Width 'Set the position based on the quarter clicked
    .Top = sglCentre + (sglY < 0) * .Height + [CLOCK].Top 'Set the position based on the quarter clicked
    '.LineSlant = (intQuarter Mod 2) <> 0 'Switches the line direction based on the quarter
    End With

    'Position the minute hand on the clock...
    'With [MINUTE]
    ' .Height = Abs(sglMinuteLen * Sin(sglTotalAngle)) 'Get the height of the minute hand
    ' .Width = Abs(sglMinuteLen * Cos(sglTotalAngle)) 'Get the width of the minute hand
    ' .Left = sglCentre + (intQuarter > 2) * .Width 'Set the position based on the quarter clicked
    ' .Top = sglCentre + (intQuarter = 1 Or intQuarter = 4) * .Height 'Set the position based on the quarter clicked
    ' .LineSlant = (intQuarter Mod 2) = 0 'Switches the line direction based on the quarter
    'End With

    End Sub
    [/vb]


    Thanks,
    Paul.

  10. #10
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'll give it a go but could you draw a pic of what you mean cos you lost me a bit .
    Oh yea and the tags for code are meant to be [ vbcode ] [/ vbcode ] with out the spaces tho
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  11. #11
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241

    Lightbulb Cracked it!

    Electroman,


    It's alright - thanks anyway. Someone has already pointed out to me where I'm going wrong, and I probably owe them profuse amounts of alcohol now!

    I was using the wrong function - should have been Atn!


    Thank-you for reading the thread anyway.
    Paul.

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