试图根据点之间的距离绘制圆 [英] trying to draw circles based on distance between points

查看:140
本文介绍了试图根据点之间的距离绘制圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图画一些圆,我希望它们与某些点相交,a ...

I'm trying to draw some circles and I was sort of hoping they would intersect with some points, alas...

library(maptools)
library(plotrix)
xy <- matrix(runif(20, min = -100, max = 100), ncol = 2)
distance <- spDistsN1(xy, xy[1, ])
plot(0,0, xlim = c(-100, 100), ylim = c(-100, 100), type = "n")
points(data.frame(xy))
points(xy[1, 1], xy[1, 2], pch = 16)
draw.circle(xy[1, 1], xy[1, 2], radius = distance)

上面的代码执行以下操作:

The above code does the following:

  • 创建10个随机点,然后选择一个(第一个)点作为锚点".
  • 计算从锚点到所有其他点的距离.这将是我们的半径"
  • 使用以上计算的半径距离在锚点周围绘制圆.
  • 从头开始,为什么圆不与用于计算半径的点相交.
  • Create 10 random points and choose one (first) point that would serve as an "anchor".
  • Calculate distance from anchor to all other points. This will be our "radius"
  • Draw circles around anchor point using above calculated distances for radii.
  • Scratch head why circles don't intersect with points that were used to calculate radii.

推荐答案

这是老的长宽比问题,人们在绘制椭圆,圆等时不时出现.

This is the old aspect ratio problem that comes up from time to time when people are drawing ellipses, circles, etc.

MASS::eqscplot代替plot(编辑:或使用asp=1:参见?par)解决了该问题.

Substituting MASS::eqscplot for plot (edit: or using asp=1: see ?par) appears to solve the problem.

这篇关于试图根据点之间的距离绘制圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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