Jump to content
  • Advertisement
Sign in to follow this  
MrPickle

Drawing a line at a certain angle

This topic is 3632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can do it, but not :3 I used that thing in my head called a brain to do this: (Language = lua)
Line = { x = 400, y = 300, x_2 = 0, y_2 = 0, Length = 100 }
Angle = 90
Line.x_2 = Line.x + math.cos(Angle)*Line.Length
Line.y_2 = Line.y + math.sin(Angle)*Line.Length

BUT it's not coming out at angle I've put in. This is with angle set to 90 (The straight line is at 0 degrees - the other was drew using method above): Image and video hosting by TinyPic I don't just want to have the line at 90 degress, otherwise I would of just drew normally. Sorry if this is an obvious question :3

Share this post


Link to post
Share on other sites
Advertisement
How do I convert degress to radians? I haven't done radians in school yet, I'm only 14 :/

I figured out after posting this that I had to make the degrees into 0.0-1.0, is that radians?

[Edit]
Google has told me 1 degree = pi radians/180

What do I put for the radians bit?

[Edit]
Luckily lua has a deg to radians and vica versa function, but I would still like to know how to convert them.

Also, Thank you Sneftel

[Edited by - MrPickle on July 14, 2008 11:26:24 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by MrPickle
How do I convert degress to radians? Luckily lua has a deg to radians and vica versa function, but I would still like to know how to convert them.

To convert degrees to radians: degrees * pi / 180
To convert radians to degrees: radians * 180 / pi

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!