Checking given point in circle

5 vues (au cours des 30 derniers jours)
Muhammad Aliff Najmi bin Mohammad Remeli
Modifié(e) : DGM le 31 Mai 2022
How to write function for checking if a given point (x, y) is within the circle with a centre at (p, q) and radius, r?

Réponses (2)

Star Strider
Star Strider le 31 Mai 2022
I would begin with the inpolygon function.

DGM
DGM le 31 Mai 2022
Modifié(e) : DGM le 31 Mai 2022
Depending on the context, there are probably more purpose-built tools, but you can do it in a very basic manner just the same.
center = [5 5];
radius = 10;
points = [10 10; 10 15];
isincircle = sum((center-points).^2,2) <= radius^2
isincircle = 2×1 logical array
1 0

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by