计算圆的坐标 [英] Calculate the coordinates in a circle

查看:86
本文介绍了计算圆的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在按钮中间画了一个假想的圆圈.

I am drawing an imaginary circle around the middle of a button.

如果Height>Width,则圆的半径为Height/2;如果Width>Height,则圆的半径为Width/2. 现在,我必须计算该圆中的哪些坐标(以像素为单位). 这个想法是如果鼠标光标悬停在该圆圈上,就会发生某些情况.

The radius of the circle is the Height/2 if Height>Width or Width/2 if Width>Height. Now i have to calculate which coordinates (in pixels) are in this circle. The idea is that if e.g. the mouse cursor hovers over that circle, something happens.

推荐答案

当满足以下方程式时,您位于圆圈内:

You are inside the circle when this equation is satisfied:

Math.pow(mouse_pos_x-center_circle_x,2)+Math.pow(mouse_pos_y-center_circle_y,2)<Math.pow(radius,2)

这篇关于计算圆的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆