Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing Lines

Status
Not open for further replies.

beck

Programmer
Mar 22, 1999
26
0
0
US
Please Help: I want to draw lines that have a specific length and angle. Specifically, I am trying to draw a line in a circle display that will project out from the center of the circle a specific length and specific angle. The circle represents a 360 degree turn with 0 off to the right of center, 90 to the top of center, 180 to the left of center and 270 bottom of center. An example would be something like an answer that is say 65 with an departure path of say 45 degrees from center. I want to be able to draw a line within the circle that would match the 45 degrees on the circle which would in fact be traveling left from 0 or more specifically be between 0 and 90 degrees. The length of the line would be dependent on the magnitude of the answer. Example would be a line that has an answer of 10 would be shorter then a line that has a magnitude of 65.

If anyone can help, I would greatly appreciate it. I have the circle drawn and the x and y lines also drawn. Cannot figure out the code to draw the angular lines based on results from mathamatical equations. The lines would change based on the results of the initial input.


accrec@intergrafix.net

 
So, Line(X1, Y1), (X2, Y2) doesn't compute for you?

X1, Y1 would be the Center of the circle?

X2, Y2 is computed from trig witht he angle and length (it is just a triangle).

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
MichaelRed is right...
Think simple.
x1,y1 is the center.

x2 = x1 + cos(ang) * length
y2 = y1 + sin(ang) * length

where length is the departure, and ang is angle in radians..

think simpler.
hope it works...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top