# JavaScript Calculate the x and y based on bearing

I have a screen where I would like to calculate the next x and y based on angle. The first footstep is this example starts at Step 1. How can I calculate the next footstep where I want to increase going forward by 120 and the side step needs to weave in and out of about 60. Please bear in mind that the starting point could be x = 100, y = 100 with the angle being 180 so the footsteps would have to then be going up the y axis.

I've attempted the following Javascript but the footsteps seem to get confused:

``````this.startingFootPrintX = Math.floor(Math.random() * 1000) + 20; //Random number between 20 and 1000
this.startingFootPrintY = Math.floor(Math.random() * 560) + 20; //Random number between 20 and 560
this.startingAngle = Math.floor(Math.random() * 340) + 20; //Random number between 20 and 340

startFootSteps();

startFootSteps(){
console.log(this.startingFootPrintX);
console.log(this.startingFootPrintY);

this.startingFootPrintX = Math.round(Math.cos(this.startingAngle * Math.PI / 180) * 120 + this.startingFootPrintX);
this.startingFootPrintY = Math.round(Math.sin(this.startingAngle * Math.PI / 180) * 60 + this.startingFootPrintY);

setInterval(function () {
startFootSteps();
}, 3000);
}
``````

## Getting the value of a button when the button is clicked, javascript

I have buttons that I make with an each sentence in jade each u in requests form.form-horizontal(method="post") input(type='button', value='Accept #{u.friend}', onclick='doAction(this....

I have buttons that I make with an each sentence in jade each u in requests form.form-horizontal(method="post") input(type='button', value='Accept #{u.friend}', onclick='doAction(this....

1. get value button jquery
2. get value button javascript
3. get value button
4. get value button php
5. get value button js
6. get value button onclick
7. get value button react
8. get value button click jquery
9. get value button submit jquery
10. get value button tkinter
11. get value button click
12. get value button android
13. get value button form
14. get value button jsp
15. getting button value html
16. get button value onclick javascript
17. get button value onclick react
18. get button value angular
19. get button value onclick jquery
20. get button value using jquery

## If I click, I want to move the box [duplicate]

It's a simple question. If I click the box , I want to move 200px to the left. but it's hard to me Please help me! where's the problem? <style> .box { width: 200px; height: 200px; ...

It's a simple question. If I click the box , I want to move 200px to the left. but it's hard to me Please help me! where's the problem? <style> .box { width: 200px; height: 200px; ...

1. mouse click wont move

## 'this' not selecting on jquery function

I have a function that is triggered when .btn is clicked, it will check if the input and text area with the class .req are filled or not. If not, its suppose to select only the empty elements and add ...

I have a function that is triggered when .btn is clicked, it will check if the input and text area with the class .req are filled or not. If not, its suppose to select only the empty elements and add ...

## How does A Node.js Web Server Keep Running Even When There Are No Callbacks To Be Executed In The Event Loop?

The code below is a simple Node.js web server that responds to a request when the URL is matched. Researching online about node.js it is stated that once you start your script (node index.js) ...

The code below is a simple Node.js web server that responds to a request when the URL is matched. Researching online about node.js it is stated that once you start your script (node index.js) ...

1. how does node server work
2. what server does node js use
3. does react need node server
4. what web server does node js use
5. does node.js need web server
6. how does node js server work
7. node server does not respond
8. node server does not start
9. does node.js replace web server
10. what does node server do
11. does nodejs need a server
1