Angle to XY

Category:
Dates and Math
Type:
Snippets
Difficulty:
Intermediate

Author: LPChip Interactive

Version Compatibility:

More information:
This code is used for games or other applications where you'll need an corner with an angle. You can specify The Starting XY(center), the Length (up) and the Angle ofcource. Then you'll retrieve the XY of where it is. (this routine is 10 times faster than TAN, COS and SIN.

USAGE:
|Retrieved XY
|BR> | /Length
|/<- Angle
XY+

You'll Find the statement 'Buiging'. the default is 1.80 but changing this could create cool things.(if you'll draw a circle with this tool, you should be able to change the size of the circle without changing the width on the horizontal and vertical points of the circle. (so, you'll be able to draw ellipses)

Use as follows:

Angle = 20 'degrees
Length = 1000
NewX = CurX + GetXfromAngle(Angle, Length, 1.8)
NewY = CurY - Length + GetYfromAngle(Angle, Length, 1.8)

test on the form (form1)

Form1.Line(CurX,CurY)-(NewX,NewY)

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: