vendredi 27 août 2021

Exclude points from circle in javascript

to get a random point ona circle i use this code :

const position = randomCirclePoint(...)

const x = position.x;
const y = position.y;

function randomCirclePoint(circleRadius, circleX, circleY) {
    let ang = Math.random() * 2 * Math.PI,
        hyp = Math.sqrt(Math.random()) * circleRadius,
        adj = Math.cos(ang) * hyp,
        opp = Math.sin(ang) * hyp

        const x = circleX + adj;
        const y = circleY + opp;
        
    return {x, y}
}

But how can i exclude some points from it ?




Aucun commentaire:

Enregistrer un commentaire