Results 1 to 8 of 8

Thread: moving a line at a certain angle

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    moving a line at a certain angle

    I am drawing a stickman's body using "Line" tool. I have a function that can also move the body to a certain angle (90 degs is a straight line). Now, how the do I get the ending x and y positions of the line according to the angle?
    Does anybody have some code that take the starting x and positions, and the angle to which move the line, and then it gives me the ending x and y positions?
    Baaaaaaaaah

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    its time for you to learn some TRIG
    look into Cos, Tan, Sin and inverseof those

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    oh noooooooooooooo......



















    I don't know anything about them
    Baaaaaaaaah

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    anybody else????
    Baaaaaaaaah

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Did you try posting your question in the Graphics and Game Programming section? It would seem to me that more folks that would know how to do what you need would be found there. (The only lines I've ever used were the line control from the standard toolbox )

  6. #6

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I am using Turing to do that but the basic stuff (cos, sin...) is the same
    I have now posted that in Graphics forum
    Baaaaaaaaah

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Here's a little function I've just written:
    VB Code:
    1. Private Sub DrawAngledLine(Angle As Long, Length As Single, Centre As PointAPI) As PointAPI
    2. Dim Rad As Single
    3. Rad = (PI / 180) * Angle
    4. DrawAngledLine.X = Round(Centre.X + Cos(Rad) * Length)
    5. DrawAngledLine.Y = Round(Centre.Y + Sin(Rad) * Length)
    6. End Sub
    I believe that should work for your purposes.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by Sastraxi
    Here's a little function I've just written:
    VB Code:
    1. Private Sub DrawAngledLine(Angle As Long, Length As Single, Centre As PointAPI) As PointAPI
    2. Dim Rad As Single
    3. Rad = (PI / 180) * Angle
    4. DrawAngledLine.X = Round(Centre.X + Cos(Rad) * Length)
    5. DrawAngledLine.Y = Round(Centre.Y + Sin(Rad) * Length)
    6. End Sub
    I believe that should work for your purposes.
    Thanks a lot Sastraxi
    That's exactly what I was looking for. I had to just change it a bit to make it work in turing but its function does exactly what I need. Now I'll start working on my stickman again...

    Thanks again
    Baaaaaaaaah

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