Click to See Complete Forum and Search --> : I need to create a specific line
Fierytycoon
May 30th, 2001, 10:12 AM
I need to create a line from the bottom left corner of an applet towards the mouse coordinate, but I want it a specified length, I do not want it to actually reach the mouse coordinates. Got any idea how? Please post here, thanks.
Norm
May 30th, 2001, 10:39 AM
Sounds like a geometry problem. You have two points: x1,y1 and x2,y2 and you want to draw a line of length L from point 1 towards point 2. Use the Pythagorean rule of
x*x + y*y = h*h to compute the intermediate point x3,y3 such that the distance from point 1 to point 3 is L.
I'll leave the details as an exercise.
Norm
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.