Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

circle rect collision

//Javascript
function rect_circle_collision(center, r, v1, v2){ //v1 and v2 must be opposite vertices
  let closest = {
    x : max(v1.x, min(center.x, v2.x)),
    y : max(v1.y, min(center.y, v2.y))
  };
  return (closest.x - center.x) ** 2 + (closest.y - center.y) ** 2 <= r; 
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript array negative index 
Javascript :: create array, fill with spaces, convert to string and concat 
Javascript :: Arrow Function Shorthand javascript 
Javascript :: why promise goes to microtask and settimeout to browser api 
Javascript :: convert datetime to milliseconds in javascript 
Javascript :: jquery swap table rows 
Javascript :: sequelize autocomplete vscode 
Javascript :: javascript unicode literal 
Javascript :: reload stylesheet with out refresh page 
Javascript :: how to press a button throught the dev tools console 
Javascript :: the key import is reserved 
Javascript :: id on delete action javascript react 
Javascript :: nodejs Websocket chat room 
Javascript :: provider._web3Provide.sendAsync as any 
Javascript :: load mulitple elements in route v6 
Javascript :: como tanformar um paraafrafo para maiusculaavascript 
Javascript :: error 28 mongodb 
Javascript :: how to detech my cosle errors in angualr 
Javascript :: strapi extend user model 
Javascript :: javascript condition based on table cell value 
Javascript :: on change jquery kendo switch 
Javascript :: javascript string to date format dd/mm/yyyy 
Javascript :: showing error for few seconds react 
Javascript :: Custom usePagination hook 
Javascript :: convert fetch in axios 
Javascript :: what is render in react native 
Javascript :: react native red Triangle Down 
Javascript :: polling interval javascript 
Javascript :: Safe Area View for android / Removing overflow of screen for android 
Javascript :: javascript return opposite boolean 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =