I have some SVG arbitrary closed shapes composed of lines and curve paths. I want to check if some points are inside the shape. I have found Point in Polygon algorithm that seems to work well, but I will have to decompose my path into a multitude of lines. Is there a more direct solution to this problem? If not,

# Tag: math

## Generate random 6 characters based on input

Generate random 6 characters based on input. Like I want to turn 1028797107357892628 into j4w8p. Or 102879708974181177 into lg36k but I want it to be consistant. Like whenever I feed 1028797107357892628 in, it should always spit out j4w8p. Is this possible? (Without a database if possible.) I know how to generate random 6 characters but I dont know how to

## Only half of array gets raised to power

I wanted to create binary to decimal calculator. When i tried to console log both of arrays (binary is array of 0’s and 1’s, binarypos is array of numbers that are powers of 2. Screenshot Then i created simpler version, made in console so chance of making a mistake lowered to zero. But the bug appears again! I want it

## Percetange calculation wrong result

I want to calculate the percentage of a minute from a given number of hours. So let’s say I have 2 hours. That’s 2*60 minutes. And I want to know how much percent does 1 minute take from 2 hours. The value should be 0.833, because 0.833 * (2*60) = 100%. But how do I get this 0.833 number? (hours

## Convert 45 to 1 and 345 to 2 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 7 months ago. Improve this question I’m building a carousel with a swiping limit exceeding both left and right of 45px on each item has 300px width I wonder How to

## MYR Currency Rounding

Looking for help in rounding the money to the nearest 0.05 in js language. Input & Expected Output: From: https://www.bnm.gov.my/misc/-/asset_publisher/2BOPbOBfILtL/content/frequently-asked-questions-faqs-on-rounding-mechanism Answer You could take an offset and take a multiple floored value. If you need zeroes at the end take .toFixed(2).

## Cannot create type as specific number when number is in variable

I want to create a type that can be only 1 or root 2. This works: type OneOrRootTwo = 1 | 1.4142135623730951; But when I try to use Math.SQRT2, or any variable reference to the numeric value of root …

## How can I change the angle of a vector when hitting an obstacle

So, my issue concerns vectors, I don’t know where I’m going with that case. I’m building a pandemic simulation (using Javascript and the library p5.js), and I’m trying to add a lockdown feature. Here …

## Canvas zoom to cursor doesn’t work correct

I’m trying to scale canvas to/from mouse position, but it works not perfect (always goes few cells away from mouse pos). I’ve read all similar posts but i don’t know what’s wrong. https://jsfiddle.net/…

## Calculate the radius of an ellipse using Javascript [closed]

If I have the height and width of an ellipse and the angle from the center. How can I calculate the radius of the ellipse from that angle? I don’t understand the maths enough to understand how to make …