如何获得一个圆的x,y距离 [英] How to get x, y distance from a circle

查看:46
本文介绍了如何获得一个圆的x,y距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我画了一个正方形,其宽度为 &长度为20x或20y,然后我在半径为10x的正方形内绘制了一个圆.现在,来自圆心的光线以45度角(可以是38度或其他任何角度)穿过圆的边界.现在如何获得x&射线与放大器的连接地面的y距离从正方形变成圆形?

I've drawn a square shape whose width & length 20x, or 20y then I have drawn a circle inside the square whose radius 10x. Now a ray from the center of the circle went through the boundary of the circle at 45-degree angle (it can be 38 degrees or anything). Now how can i get x & y distance of connection ground of ray & circle from the square shape?

我尝试了以下代码:

var radius = 10 //radius,
    x = Math.cos(Math.PI * 45 / 180) * radius
    y = Math.sin(Math.PI * 45 / 180) * radius

我没有用这段代码得到确切的距离,什么是获得x&的正确方法?你的距离?

I'm not getting the exact distance with this code, what is the currect way to get this x & y distance?

推荐答案

您的座标原点似乎在包围的正方形的左上角,y轴向下.

It seems that your coord origin is the top left of the enclosing square and the y axis is oriented downwards.

在这种情况下,

var radius = 10 //radius,
    x = radius + Math.cos(Math.PI * 45 / 180) * radius
    y = radius - Math.sin(Math.PI * 45 / 180) * radius

这篇关于如何获得一个圆的x,y距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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