Get second point of line from its size and angle

BlitzMax Forums/BlitzMax Beginners Area/Get second point of line from its size and angle

christian223(Posted 2008) [#1]
I want to have a function that looks like this

Function XY_FromAngle(x1:Float, y1:Float, Distance:Float, Angle0:Float, x2:Float var, y2:Float var)


So it returns the x y coordinates of the second point of a line given its first point, its size (Hypotenuse ) and angle.
Maybe there is such a function floating in the internet and i didnt find it, any help is appreciated much, thanks a lot.


Jesse(Posted 2008) [#2]
I believe it's something like this:
Function XY_FromAngle(x1:Float , y1:Float , Distance:Float , Angle0:Float , x2:Float Var , y2:Float Var) 
	
	x2 = Cos(angle0) * Distance + x1 
	y2 = Sin(angle0) * Distance + y1
End Function

Untested.


christian223(Posted 2008) [#3]
Function point_FromAngle(x1:Float, y1:Float, Distance:Float, Angle0:Float, x2:Float var, y2:Float var)

	Local Ydist:Float = Sin(angle0)
	Local Xdist:Float = Cos(angle0)
	
	x2 = x1 + (Distance * xdist)
	y2 = y1 + (Distance * ydist)
End Function


Thanks!, i allready did it myself just before i saw your response, it works fine.
Thanks again :)