|
-
Nov 28th, 2001, 11:12 AM
#1
Thread Starter
PowerPoster
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?
-
Nov 28th, 2001, 11:16 AM
#2
Frenzied Member
its time for you to learn some TRIG
look into Cos, Tan, Sin and inverseof those
-
Nov 28th, 2001, 11:30 AM
#3
Thread Starter
PowerPoster
oh noooooooooooooo......
I don't know anything about them
-
Nov 29th, 2001, 09:19 AM
#4
Thread Starter
PowerPoster
-
Nov 29th, 2001, 10:07 AM
#5
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 )
-
Nov 29th, 2001, 11:25 AM
#6
Thread Starter
PowerPoster
I am using Turing to do that but the basic stuff (cos, sin...) is the same
I have now posted that in Graphics forum
-
Nov 29th, 2001, 04:11 PM
#7
Good Ol' Platypus
Here's a little function I've just written:
VB Code:
Private Sub DrawAngledLine(Angle As Long, Length As Single, Centre As PointAPI) As PointAPI
Dim Rad As Single
Rad = (PI / 180) * Angle
DrawAngledLine.X = Round(Centre.X + Cos(Rad) * Length)
DrawAngledLine.Y = Round(Centre.Y + Sin(Rad) * Length)
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)
-
Nov 29th, 2001, 04:53 PM
#8
Thread Starter
PowerPoster
Originally posted by Sastraxi
Here's a little function I've just written:
VB Code:
Private Sub DrawAngledLine(Angle As Long, Length As Single, Centre As PointAPI) As PointAPI
Dim Rad As Single
Rad = (PI / 180) * Angle
DrawAngledLine.X = Round(Centre.X + Cos(Rad) * Length)
DrawAngledLine.Y = Round(Centre.Y + Sin(Rad) * Length)
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|