filburt1
11-25-2002, 10:57 PM
Let's say you're given angle from 0° to 360° and you want to draw a line from the center of a square to the edge of a virtual circle corresponding to the angle. How would you go about finding the (x, y) equivalent of that angle?
Or completely reworded: in this picture, the blue arrow indicates the exact center of the picture (the picture happens to be 200px by 200px). The green circle is the angle (happens to be 315°). Given the size of the image (it will always be a square) what's the method of finding the coordinates of the end of the line indicated by the red arrow?
This question is programming-related BTW, not related to any math class (because I'm not taking any math classes :D)
filburt1
11-25-2002, 10:58 PM
Whoopsies, here's the attachment:
filburt1
11-25-2002, 11:06 PM
Nearest pixel (i.e., integers).
edit: BTW the numbers I gave are just examples, they will always be different.
Zoltrix
11-25-2002, 11:24 PM
Lol, I was writing out how to do it, but I got lost in my own explanation. Seems to have been awhile since I have worked with real math questions.
But I can give you a few things, you need to know 2 points, we know that one is (0,0) this is in the center. The last one can be found by using the formula,
m = y1-y2 / x1-x2
I believe the slope is for 315 degrees -1/1
Formula should look something like
-1 = 0 – y2
-- ------
1 = 0 – x2
Ehhh… Wait… then well…
:eek: What kind of math question is this! :confused: :rolleyes: :D
(edited: forgot my negitive, fixed now)
Zoltrix
11-25-2002, 11:30 PM
AHHHH!!!!
Dug up something that may be more useful!
The distance of a line segment is = to the square root of x1 –x2 squared plus y1 - y2 squared. :eek: You just have to figure out how the hell to find the second point, I think you used the formula above.
:D lol... its a true formula... trust me... :rolleyes:
filburt1
11-25-2002, 11:32 PM
LOL, the second coordinate is what we're trying to get, the parser can figure out how to draw the line :stickout:
Zoltrix
11-25-2002, 11:34 PM
lol,
My simple answer is, I have no clue... ;)
cperciva
11-25-2002, 11:48 PM
the X coordinate is x0+sin(t)*r
the Y coordinate is y0-cos(t)*r
where (x0,y0) are the coordinates of the center, and r is the radius of the center.
filburt1
11-25-2002, 11:50 PM
Ah, some sanity! :D
Okay, will try that :)
filburt1
11-27-2002, 06:12 PM
Thanks, I got it :D
You can see the clock (what I was using this for) at http://www.webdesignforums.net/?styleid=3 :)