Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js cyclic motion based on cosine

let x = 100  // center x
let y = 50   // center y
let r = 50   // radius
let a = 0    // angle (from 0 to Math.PI * 2)

function rotate(a) {
  
  let px = x + r * Math.cos(a); 
  let py = y + r * Math.sin(a);
  
  console.log( px, py );
  
}

setInterval(function() {
  a = (a + Math.PI / 360) % (Math.PI * 2);
  rotate(a);
}, 5);
Comment

PREVIOUS NEXT
Code Example
Javascript :: Change tilte alert 
Javascript :: How to write "Hello World" 
Javascript :: alternative of tofixed javascript 
Javascript :: Plumsail To change the modal popup window size you can try injecting the CSS to the SharePoint list view page 
Javascript :: The complete map() method syntax 
Javascript :: ajax each 
Javascript :: html vue input enabled 
Javascript :: mongoose.js clause where 
Javascript :: filter by last month 
Javascript :: laravel data showing in single option instead of multiple option from json array 
Javascript :: javascript Why is this function working on second click only 
Javascript :: how to create your own event emitter in javascript 
Javascript :: angularjs Why does using .match inside of an ng-if seem to cause digest cycles 
Javascript :: angularjs Prevent from getting rendered 
Javascript :: Algolia backend search with Algolia Search Helper library for Angular.js 
Javascript :: set default value in dynamic dropdown angularjs 
Javascript :: Changing Component File location in React native does not show in main App 
Javascript :: react-native installation error with npx react-native 
Javascript :: how to add link during filter and mapping in javascript 
Javascript :: JOLT split flat object into key/value array 
Javascript :: to fix a broken class oop javascript 
Javascript :: export from json 
Javascript :: Modules: Remember All Strings Will Now Have a Property After You Use Require 
Javascript :: short-circuit evaluation , use of || operator 
Javascript :: for in loop of javascript 
Javascript :: underscore js filter array of objects 
Javascript :: react_devtools_backend.js:4026 Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Login`). 
Javascript :: prisma count non-null 
Javascript :: var logNums = function(num) {}; 
Javascript :: Control a progress bar for custom video player 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =