根据2个点和半径绘制圆弧 [英] Draw an arc based on 2 Points and radius

查看:117
本文介绍了根据2个点和半径绘制圆弧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在面板内绘制一个Arc2D对象.但是我不确定如何计算. 我给的是起点Point2D和终点Point2D和半径. 问题在于,当半径更改时,startAngle和AngleExtent参数每次都不同. 另一个问题是,由于半径发生变化,因此每次包含圆弧的拟"圆的中心都在一个不同的点,另一个参数根据输入而变化,所以我无法使用(或不知道如何)使用setCenter()方法.

I'm trying to draw an Arc2D object inside a panel. however I'm not sure how to calculate it. What I have given is starting Point2D and an end Point2D and a radius. The problem is that when the radius changes, the startAngle and AngleExtent parameters are different every time. another problem is that since the radius changes, the center of the 'to-be' circle containing the arc is in a different point every time, another parameter which changes based on input, so I can't use (or don't know how) to use setCenter() method.

感谢您的帮助!

推荐答案

两个点和一个半径定义了两个弧(二维).您可以通过计算以两个点为中心的半径r的两个Circle的交点(java.awt.geom.Area.intersects)来找到它们的中心点.圆弧的圆心将是该区域的周长上位于您的两个初始点中间的点.

Two points and a radius define two arcs (in 2D). You can find their center points by calculating the intersection (java.awt.geom.Area.intersects) of the two Circles of radius r centered at your two points. The center point of the arcs' circles will be the points on the perimeter of that area halfway between your two initial points.

这篇关于根据2个点和半径绘制圆弧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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