Solved

# Converting Angle To Coordinates

Posted on 2003-11-06
1,107 Views
Last Modified: 2013-12-26
Hi, I need a formula, algorithm or a function("Visual Basic") that can take a position(X, Y), an angle(0-360) and a number, and based on these values it will give you a position(X, Y).
For example if I say:

Position: 1, 1
Angle: 90
Number: 2

it will return 1, 3, cause 90 degrees is up and 1, 3 is 3 steps from 1, 1.

Or another example:

Position: 1, 1
Angle: 180
Number: 7

it will return -6, 1. cause 180 degrees is left and -6, 1 is 7 steps from 1, 1.

- Julian
0
Question by:JulianS
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 2
3 Comments

LVL 45

Expert Comment

ID: 9694013
newx = oldx + length * cosine(angle)
newy = oldy + length * sine(angle)
0

LVL 45

Accepted Solution

sunnycoder earned 180 total points
ID: 9694220
A small explanation is in order

|
|
|
|
|                       B
|                     /|
|                   /  |
|              H /    |
|               /      |  O
|             /        |
|           /          |
|     A ./______|C
|             A
|_________________________________

A is your oldx,oldy .... B is the new location newx,newy .... you are given the angle CAB and length AB (denoted by H)

basically H - hypotenuse ... A - adjacent ... O - opposite

clearly co-ordinates of C are newx,oldy
also newx = oldx + A

now Cos(CAB) = A/H
or A = cos (CAB) * H
therefore newx = oldx + cos(CAB) * H

same applies to newy which will evaluate to
newy = oldy + H * sin(CAB)
0

LVL 31

Assisted Solution

GwynforWeb earned 70 total points
ID: 9727607
For this

Position: x, y
Angle: t
Number: n

As a subroutine

Sub newpos(x,y,t,n)
newXpos=x + round(n*cos(t))
newYpos=y + round(n*sin(t))
End Sub

or as a pair of functions

Function  newXpos(x,y,t,n)
newXpos=x + round(n*cos(t))
End Function

Function  newYpos(x,y,t,n)
newYpos=y + round(n*sin(t))
End Function
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
###### Suggested Courses
Course of the Month8 days, 17 hours left to enroll

#### 738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.